Reputation: 49
I m passing the value in the href attribute by using a variable, but the value of variable is not getting passed, either it passes nothing or the variable name itself.
How do I use quotes and variables in order to pass the value of variable successfully? Below is the code:
<?php
for ($x = 0; $x < $count; $x++)
{
$html= '<a href="productTest.php?pro='".$out[$x][2]."'>'.$out[$x][0].'</a>: added on-'.date('M j Y g:i A', strtotime($out[$x][1]));
//<a href="productDisplay.php">Products</a>
echo $html;
echo "<br><br>";
}
?>
Upvotes: 3
Views: 58
Reputation: 1792
This should work:
<?php
for ($x = 0; $x < $count; $x++)
{
$html= '<a href="productTest.php?pro='.$out[$x][2].'">'.$out[$x][0].'</a>: added on-'.date('M j Y g:i A', strtotime($out[$x][1]));
//<a href="productDisplay.php">Products</a>
echo $html;
echo "<br><br>";
}
?>
I replaced '".$out[$x][2]."'
with '.$out[$x][2].'
Upvotes: 1