$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
Reply to discussion (solution)
$sql 1= "SELECT * from Y_cate ORDER by ASC"; $result 1 = mysql_query ($sql 1), while ($row = mysql_fetch_array ($result 1)) { F Oreach ($row as $ke = + $a) { echo $a. "
"; }}
$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 answer 1. Your SQL statement will not get an error? ORDER by ASC, no sort field;
2. No SQL statement executed. mysql_query ($sql 1).
$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 answer 1. Your SQL statement will not get an error? ORDER by ASC, no sort field;
2. No SQL statement executed. mysql_query ($sql 1). Hand wrong hand?
SELECT * FROM Y_cate ORDER by ASC problem
The order by does not specify a field and will error: #1064-you has an error in your SQL syntax; Check the manual, corresponds to your MySQL server version for the right syntax to use near ".....
$sql 1= "SELECT * from Y_cate ORDER by ASC"; $result 1 = mysql_query ($sql 1), while ($row = mysql_fetch_array ($result 1)) { F Oreach ($row as $ke = + $a) { echo $a. "
"; }}
Do you have to use while?
If you use while,
[Code] $sql 1= "SELECT * from Y_cate ORDER by px ASC";
$US =mysql_query ($sql 1);
while ($result 1=mysql_fetch_array ($US)) {
echo $result 1[' name '];
}[/code]
This is not a more concise way?? And it looks like you're going to have to repeat the output when you output it, here's the output data, repeat
43
43
Website Home
Website Home
50b5b9555f97e.png
50b5b9555f97e.png
0
0
0
0
SELECT * FROM Y_cate ORDER by ASC problem
The order by does not specify a field and will error: #1064-you has an error in your SQL syntax; Check the manual, corresponds to your MySQL server version for the right syntax to use near ".....
Pro, hand-knock code, hand missed out. May I ask the question how to solve
$sql 1= "SELECT * from Y_cate ORDER by ASC"; $result 1 = mysql_query ($sql 1), while ($row = mysql_fetch_array ($result 1)) { F Oreach ($row as $ke = + $a) { echo $a. "
"; }}
Do you have to use while?
If you use while,
[Code] $sql 1= "SELECT * from Y_cate ORDER by px ASC";
$US =mysql_query ($sql 1);
while ($result 1=mysql_fetch_array ($US)) {
echo $result 1[' name '];
}[/code]
This is not a more concise way?? And it looks like you're going to have to repeat the output when you output it, here's the output data, repeat
43
43
Website Home
Website Home
50b5b9555f97e.png
50b5b9555f97e.png
0
0
0
0
Repeat is because you use the Mysql_fetch_array replaced MYSQL_FETCH_ASSOC after not repeat, specific reasons please Baidu under these two functions, a look on the understanding.
Version of the big give the method is correct, you want to output each record of each item, this is two loops, while take each one, foreach take each item. Once you've changed it, you're circulating it. Of course, you can't fulfill your needs.
while ($row = mysql_fetch_array ($result 1,mysql_assoc)) {
foreach ($row as $ke = = $a) {
echo $a. "
";
}
}
or just use Mysql_fetch_assoc/mysql_fetch_row.