0

In my MySQL table I have a column name, and there are various repeating names within the table. If I want to display all other column formation for all the people with name chris I can use:

$sql = mysql_query("SELECT * FROM favorites WHERE name='$name'")
if($info = mysql_fetch_assoc($sql))
echo {$info['name']}
echo {$info['age']}
echo {$info['address']}

But then I want to echo the details of the second chris, in the table who could be in any random row within the table I can't specify that information. Is there a way to accomplish this? Thank you.

4

2 回答 2

5

尝试这个:

while($row = mysql_fetch_assoc($sql)) {
    echo $row['name'];
    echo $info['age'];
    echo $row['address'];
}
于 2012-07-30T11:20:11.560 回答
-2
while ($row = mysql_fetch_assoc($sql)) 
{
            echo $row['name'];
            echo $row['age'];
            echo $row['address'];
}
于 2012-07-30T11:22:41.440 回答