这是代码示例,请在此处添加,以解析$ name只是最后一个蔬菜:((( 我需要链接中的所有内容:
<?php
$mike = mysql_query('SELECT vegetables FROM nature');
while($subfile = mysql_fetch_assoc($mike))
{
$jack = $subfile['vegetables'];
$name = $jack;
}
//while ends
echo ('<span><a href="index.php?='.$name.'">Vegetables</a>
|
Fruits
|
Suggestions </span>');
?>
答案 0 :(得分:1)
假设你想要的东西都是西红柿,黄瓜,沙拉, 在循环结果时将它们堆叠在一个数组中,然后将它们粘合在一起。
<?php
$mike = mysql_query('SELECT vegetables FROM nature');
$names = array();
while($subfile = mysql_fetch_assoc($mike)) {
$jack = $subfile['vegetables'];
$names[] = $jack;
}
//while ends
$list = join(',',$names);
echo ('<span><a href="index.php?='.$list.'">Vegetables</a>
|
Fruits
|
Suggestions </span>');
?>
答案 1 :(得分:0)
将以下代码放入while循环中,
echo ('<span><a href="index.php?='.$name.'">Vegetables</a>
|
Fruits
|
Suggestions </span>');
答案 2 :(得分:0)
<?php
$mike = mysql_query('SELECT vegetables FROM nature');
while($subfile = mysql_fetch_assoc($mike))
{
$name = $subfile['vegetables'];
echo ('<span><a href="index.php?='.$name.'">'.$name.'</a>
|
Fruits
|
Suggestions </span>');
}
//while ends
?>