PHP script not passing url with a array variable
This code is not passing URL to make topic clickable main problem is in third line after while loop. I got this error :
Parse error: syntax error, unexpected 'id' (T_STRING), expecting ',' or ';' in D:xmapphtdocsforummain_forum.php on line 37
Code :
while($rows=mysql_fetch_array($result))
{
echo "<tr>";
echo "<td align='center' bgcolor=#FFFFFF>",$rows['id'],"</td>";
echo "<td bgcolor='#FFFFFF'>",'<a href="$view_topic.php?id=$rows['id']">$rows['topic']. </a>',"</td>";
echo "<td align='center' bgcolor='#FFFFFF'>",$rows['view'],"</td>";
echo "<td align='center' bgcolor='#FFFFFF'>",$rows['reply'],"</td>";
echo "<td align='center' bgcolor='#FFFFFF'>",$rows['datetime'],"</td>";
}
Please try this. there is syntax error in your code.
echo "<tr>";
echo "<td align='center' bgcolor=#FFFFFF>",$rows['id'],"</td>";
echo "<td bgcolor='#FFFFFF'>",'<a href="$view_topic.php?id='.$rows[id].'">'.$rows[topic]. ' </a>',"</td>";
echo "<td align='center' bgcolor='#FFFFFF'>",$rows['view'],"</td>";
echo "<td align='center' bgcolor='#FFFFFF'>",$rows['reply'],"</td>";
echo "<td align='center' bgcolor='#FFFFFF'>",$rows['datetime'],"</td>";
This should correct your problem, Use
echo "<td bgcolor='#FFFFFF'><a href='".$view_topic.".php?id=".$rows['id']."'>".$rows['topic']."</a></td>";
instead of
echo "<td bgcolor='#FFFFFF'>",'<a href="$view_topic.php?id=$rows['id']">$rows['topic']. </a>',"</td>";
One more thing, Why dont you use php tag only when needed. If you do like this it will be clean and easy.
<?php
while($rows=mysql_fetch_array($result))
{
?>
<tr>
<td><a href ="<?php $view_topic.".php?id=".$rows['id']; ?>"> <?php $rows['topic']; ?> </a></td>
.......
.......
</tr>
<?php } ?>
尝试这个 :
while($rows = mysql_fetch_array($result)){
echo "<tr>";
echo "<td align='center' bgcolor=#FFFFFF>".$rows['id']."</td>";
echo "<td bgcolor='#FFFFFF'><a href='".$view_topic.".php?id=".$rows['id']."'>".$rows['topic']."</a></td>";
echo "<td align='center' bgcolor='#FFFFFF'>".$rows['view']."</td>";
echo "<td align='center' bgcolor='#FFFFFF'>".$rows['reply']."</td>";
echo "<td align='center' bgcolor='#FFFFFF'>".$rows['datetime']."</td>";
}
链接地址: http://www.djcxy.com/p/59078.html
上一篇: (function(){})(); 和function(){}();
下一篇: PHP脚本不传递数组变量的URL