if $(action) { doesnt work

This is a discussion on if $(action) { doesnt work within the PHP General forums, part of the PHP Programming Forums category; Hello, For lots of you this might be a simple question, but i lost sweat and tears searching for the ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 05-09-2006
vinnie
 
Posts: n/a
Default if $(action) { doesnt work

Hello,

For lots of you this might be a simple question, but i lost sweat and
tears searching for the answer.
I want to show some newsrecords from a database. But when i click on a
link with action="all" all the records have to show. Problem is that
when i dont give action in my tag it says variable action is not
declared. Strange is that i start my IF with if ($action) {

I give you code under this, if someone could help me i would be very
gratefull.

<?php
if ($action) // als er een actie ondergaan wordt
{ if ($action=="all")
{
$SQL_statement="SELECT * FROM nieuws ORDER BY news_id DESC";
$resultset=mysql_query($SQL_statement);
while ($data=mysql_fetch_array($resultset))
{
echo "<strong>".$data['news_date']."</strong><br/>";
echo $data['news_main']."<br/><hr/>";
}
} else
{
$SQL_statement="SELECT * FROM nieuws ORDER BY news_id DESC";
$resultset=mysql_query($SQL_statement);
while ($data=mysql_fetch_array($resultset))
{
echo "<strong>".$data['news_date']."</strong><br/>";
echo $data['news_main']."<br/><hr/>";
}
}
} else {

$SQL_statement="SELECT * FROM nieuws ORDER BY news_id DESC";
$resultset=mysql_query($SQL_statement);
while ($data=mysql_fetch_array($resultset))
{
echo "<strong>".$data['news_date']."</strong><br/>";
echo $data['news_main']."<br/><hr/>";

}
}
mysql_close();
?>

Reply With Quote
  #2 (permalink)  
Old 05-09-2006
Kieran.Hall@gmail.com
 
Posts: n/a
Default Re: if $(action) { doesnt work

Hi,

Try wrapping the variable $action with the isset() function. Like
so...

if(isset($action)

Regards,

Kieran.

vinnie wrote:
> Hello,
>
> For lots of you this might be a simple question, but i lost sweat and
> tears searching for the answer.
> I want to show some newsrecords from a database. But when i click on a
> link with action="all" all the records have to show. Problem is that
> when i dont give action in my tag it says variable action is not
> declared. Strange is that i start my IF with if ($action) {
>
> I give you code under this, if someone could help me i would be very
> gratefull.
>
> <?php
> if ($action) // als er een actie ondergaan wordt
> { if ($action=="all")
> {
> $SQL_statement="SELECT * FROM nieuws ORDER BY news_id DESC";
> $resultset=mysql_query($SQL_statement);
> while ($data=mysql_fetch_array($resultset))
> {
> echo "<strong>".$data['news_date']."</strong><br/>";
> echo $data['news_main']."<br/><hr/>";
> }
> } else
> {
> $SQL_statement="SELECT * FROM nieuws ORDER BY news_id DESC";
> $resultset=mysql_query($SQL_statement);
> while ($data=mysql_fetch_array($resultset))
> {
> echo "<strong>".$data['news_date']."</strong><br/>";
> echo $data['news_main']."<br/><hr/>";
> }
> }
> } else {
>
> $SQL_statement="SELECT * FROM nieuws ORDER BY news_id DESC";
> $resultset=mysql_query($SQL_statement);
> while ($data=mysql_fetch_array($resultset))
> {
> echo "<strong>".$data['news_date']."</strong><br/>";
> echo $data['news_main']."<br/><hr/>";
>
> }
> }
> mysql_close();
> ?>


Reply With Quote
  #3 (permalink)  
Old 05-11-2006
vinnie
 
Posts: n/a
Default Re: if $(action) { doesnt work

Tnx Kieran, it worked with the isset function but now he doesnt do the
trick when the action is given )-; , i ll keep on searching, maybe i
have to $get the action variable?

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 02:23 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0