About the foreach output problem
$sql 1= "SELECT * from Y_cate ORDER by ASC";
$result 1=mysql_fetch_array (mysql_query ($sql 1));
Var_dump ($result 1);
foreach ($result 1 as $ke = = $a) {
echo $a. "
";
}
?>
I want to use foreach to loop through the output of all the data in the Cate table, why just output one piece of data? Ask for answers
Share to:
------Solution--------------------
$sql 1= "SELECT * from Y_cate ORDER by ASC";
$result 1 = mysql_query ($sql 1);
while ($row = mysql_fetch_array ($result 1)) {
foreach ($row as $ke = = $a) {
echo $a. "
";
}
}
------Solution--------------------
Reference:
$sql 1= "SELECT * from Y_cate ORDER by ASC";
$result 1=mysql_fetch_array (mysql_query ($sql 1));
Var_dump ($result 1);
foreach ($result 1 as $ke = = $a) {
echo $a. "
";
}
?>
I want to use foreach to loop through the output of all the data in the Cate table, why just output one piece of data? Ask for answers
1. Your SQL statement will not get an error? ORDER by ASC, no sort field;
2. No SQL statement executed. mysql_query ($sql 1).
------Solution--------------------
reference:
Quote: reference:
$sql 1= "SELECT * from Y_cate ORDER by ASC";
$result 1 = mysql_query ($sql 1);
while ($row = mysql_fetch_array ($result 1)) {
foreach ($row as $ke = + $a) {
echo $a.
";
}
}
Do I have to use while?
If using while,
[code] $sql 1= "SELECT * from Y_cate ORDER by px ASC";
$US =mysql_query ($sql 1);
while ($result 1=mysql_fetch_array ($US)) {