I want to echo out multiple lines in the array but it only outputs one line: PHP
$query = "SELECT * FROM user WHERE Category = 'Men'";
$result = mysql_query($query);
while ($row1 = mysql_fetch_array($result)) {
$fname1 = $row1['FName'];
$sname1 = $row1['SName'];
}
$result2 = mysql_query($query);
while ($row2 = mysql_fetch_array($result2)) {
$fname2 = $row2['FName'];
$sname2 = $row2['SName'];
}
HTML
<h2>First Name: <?php echo "$fname1"; ?></h2>
<h2>Second Name: <?php echo "$sname1"; ?></h2>
<h2>First Name: <?php echo "$fname2"; ?></h2>
<h2>Second Name: <?php echo "$sname2"; ?></h2>
but it gives me the same output when both should be different. The output is:
First Name: John Second Name: Smith
First Name: John Second Name: Smith
When i want the output to be:
First Name: John Second Name: Smith
First Name: Bob Second Name: Marley
Can anyone help me to fix this problem please?\
The data in the database is:
User_ID| FName |SName| Category
1 John Smith Men
2 Bob Marley Men