Jump to content

Passing PHP querrystring


arunkar

Recommended Posts

Hi,

 

Being new to php I'm unable to get this right.

 

I'm trying to pass a dynamic value generated by SQL to another page on clicking the value. the value is stored in the variable $field (below). Now I get the varible in the next page and not the value how do I do it?

 

<?php  foreach($rowTotJoyCard as $field){ 
					 if($field >0){?> <a href="javascript:popUp([b]'details2.php?MR=TotJoyCard&Reg=Total Joy Card Signups&Tot=$field')[/b]"><?php echo $field; ?></a><?php }
						 else{echo "0";}
					}  ?>

 

is there a way?

 

thanks :)

Link to comment
Share on other sites

Caesar , I'm passing the value generated by MySQL query. its the $field value that Im passing to the next page. below is the code does the passing of the value.

 

<?

$NewJoyCard = mysql_query("SELECT count(*) FROM subscribers WHERE formid = 4 and DATE(FROM_UNIXTIME(requestdate)) = CURRENT_DATE()");


php  foreach($rowTotJoyCard as $field){ 
					 if($field >0){?> <a href="javascript:popUp('details2.php?MR=TotJoyCard&Reg=Total Joy Card Signups&Tot=$field')"><?php echo $field; ?></a><?php }
						 else{echo "0";}
					}  ?>

 

Thanks

Link to comment
Share on other sites

Is it Tot getting lost?  Is it being assigned as "$field"?

 

If so, fix is below, $field is being printed in the javascript popUp literally.

 

<?

$NewJoyCard = mysql_query("SELECT count(*) FROM subscribers WHERE formid = 4 and DATE(FROM_UNIXTIME(requestdate)) = CURRENT_DATE()");


php  foreach($rowTotJoyCard as $field){ 
					if($field >0){?> <a href="javascript:popUp('details2.php?MR=TotJoyCard&Reg=Total Joy Card Signups&Tot=<?php echo $field; ?>')"><?php echo $field; ?></a><?php }
						 else{echo "0";}
					}  ?>

Link to comment
Share on other sites

The page isn't right.

 

<?

$NewJoyCard = mysql_query("SELECT count(*) FROM subscribers WHERE formid = 4 and DATE(FROM_UNIXTIME(requestdate)) = CURRENT_DATE()");


php  foreach($rowTotJoyCard as $field){ 
					 if($field >0){?> <a href="javascript:popUp('details2.php?MR=TotJoyCard&Reg=Total Joy Card Signups&Tot=$field')"><?php echo $field; ?></a><?php }
						 else{echo "0";}
					}  ?>

 

What's with the php before your foreach loop?

 

<?php

$NewJoyCard = mysql_query("SELECT count(*) FROM subscribers WHERE formid = 4 and DATE(FROM_UNIXTIME(requestdate)) = CURRENT_DATE()");

  foreach($rowTotJoyCard as $field) { 
    if($field >0){
      echo'<a href="javascript:popUp(\'details2.php?MR=TotJoyCard&Reg=Total Joy Card Signups&Tot=$field\')">'.$field.'</a>';
    }
      else
      {
        echo "0";
      }
  }
?>

Link to comment
Share on other sites

Anyway, if I'm seeing this right...your loop is wrong. $rowTotJoyCard isn't an array. You can't loop it.

 

P.S....print out the $rowTotJoyCard and see what it outputs before your loop.

 

<?php

  $NewJoyCard = mysql_query("SELECT count(*) FROM subscribers WHERE formid = 4 and DATE(FROM_UNIXTIME(requestdate)) = CURRENT_DATE()");

  print('<pre>');
  print_r($rowTotJoyCard);
  print('</pre>');

?>

 

 

 

 

Link to comment
Share on other sites

Thanks devstudio and Caesar, it was not printing the value of $field and printing $field it self.

 

 

Now it works like charm... :)

 

btw,

 

actually I'm using a while loop to run the query.

 

thanks again Caesar.

 

cheers

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.