php while loop with row variable
Not sure why this will not 开发者_JAVA百科work? Does the loop not like my variable? If I hard code this workings...
while($row = mysql_fetch_array($resultno))
{
echo "<tr>";
echo "<td><a href=reportip.php?prov=&date1=$date1&starthour=$hour1&endhour=$hour2&prov=$prov&date2=$date2&$hour2&$prov=13&lookup=" . $row['$radio'] . ">" . $row['$radio'] . "</a></td>";
echo "<td>" . $row['count'] . "</td>";
echo "</tr>";
}
'$radio'
is a string, not a variable. Remove the apostrophes and make it into $radio
:
$row[$radio]
This will make it possible to choose a column from the MySQL resultset by setting $radio to the chosen value.
Your row is not likely to have a $radio
key; maybe you meant $row['radio']
. Or $row[$radio]
.
Your array referencing is wrong:
$row['$radio']
should be written as follows, when referencing an array element using another variable
$row[$radio]
or as follows when accessing an element name
$row['radio']
$row['$radio']
seems to be a problem. Is $radio
a variable with a value you would like to use as index for the $row
then write $row[$radio]
otherwise if the table column is named "radio" only write $row['radio']
.
精彩评论