I can’t figure this out. How do I do something like:
[php]$query = “SELECT fname FROM table LIMIT 4”;
$result = mysql_query($query) or die(mysql_error());
while ($row = mysql_fetch_assoc($result)) {
$result1 = “Bob”;
$result2 = “Sue”;
$result3 = “Ganesh”;
$result4 = “Ali”;
}[/php]
I need to get four id numbers/names (whatever) from a table and assign those to four distinct variables so I can use those later on the same page to perform other queries like this:
[php]$query = “SELECT * FROM access WHERE userID = ‘$result1’”;
$result = mysql_query($query) or die(mysql_error());
while ($row = mysql_fetch_assoc($result)) {
$id = $row[‘id’];
$lastDate = $row[‘date’];
}
$query = “SELECT * FROM access WHERE userID = ‘$result2’”;
$result = mysql_query($query) or die(mysql_error());
while ($row = mysql_fetch_assoc($result)) {
$id = $row[‘id’];
$lastDate = $row[‘date’];
}
$query = “SELECT * FROM access WHERE userID = ‘$result3’”;
$result = mysql_query($query) or die(mysql_error());
while ($row = mysql_fetch_assoc($result)) {
$id = $row[‘id’];
$lastDate = $row[‘date’];
}
$query = “SELECT * FROM access WHERE userID = ‘$result4’”;
$result = mysql_query($query) or die(mysql_error());
while ($row = mysql_fetch_assoc($result)) {
$id = $row[‘id’];
$lastDate = $row[‘date’];
}[/php]