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
https://forums.phpfreaks.com/topic/99318-passing-php-querrystring/
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

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";}
					}  ?>

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";
      }
  }
?>

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>');

?>

 

 

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.