Hey all I am wondering how I could get ALL queries from a table, it only gets the first one and stops
My code:
$result1 = mysql_query("SELECT `to` FROM transactions WHERE `from` = '$user'");
$row = mysql_fetch_row($result1);
$result2 = mysql_query("SELECT `amount` FROM transactions WHERE `from` = '$user'");
$row2 = mysql_fetch_row($result2);
echo "<li>TO</li>";
echo "<li>AMOUNT</li>";
echo "<li>$row[0]</li>";
echo "<li>$row2[0]</li>";
echo "<li>$row[1]</li>";
echo "<li>$row2[1]</li>";
echo "<li>$row[2]</li>";
echo "<li>$row2[2]</li>";
echo "<li>$row[3]</li>";
echo "<li>$row2[4]</li>";
echo "<li>$row[4]</li>";
echo "<li>$row2[5]</li>";
My Database:
$row = mysql_fetch_row($result1); will only fetch one row
You need to use while
$query = mysql_query("SELECT `to`, `amount` FROM transactions WHERE `from` = '$user'");
echo "<li>TO</li>";
echo "<li>AMOUNT</li>";
while ($row = mysql_fetch_assoc($query)) {
echo "<li>{$row['to']}</li>";
echo "<li>{$row['amount']}</li>";
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.