function Type_son_id_finder ($type _id) { $query =mysql_query ("Select id from ' protduct_type ' WHERE ' f_id ' = ' $type _ Id ' "); while ($row =mysql_fetch_assoc ($query)) { return $all _son = $row ["id"]. ","; }}
This method is to enter a parent column ID to find out what the sub-column ID
The above method
should be the output
1, 2,
But only output
1,
But if you put
return $all _son = $row ["id"]. ",";
Switch
echo $all _son = $row ["id"]. ",";
Can normally show 1, 2,
Why is this?
How do I fix it?
I'm trying to get this method out to the end.
The
Let me in the where ID in MySQL
But now you can only output the first one, you can't use return, only echo?
Solving!
Reply to discussion (solution)
We recommend that you learn the basics first.
function Type_son_id_finder ($type _id) {
$query =mysql_query ("Select id from ' protduct_type ' WHERE ' f_id ' = ' $type _id '");
$all _son = ";
while ($row =mysql_fetch_assoc ($query)) {
$all _son. = $row ["id"]. ",";
}
return $all _son;
}
Return is placed in the loop and it jumps out of the current loop, so it ends with a loop, so you get only one result. 1
The correct result can refer to # # return after the loop
function Type_son_id_finder ($type _id) {
$query =mysql_query ("Select id from ' protduct_type ' WHERE ' f_id ' = ' $type _id '");
$all _son = ";
while ($row =mysql_fetch_assoc ($query)) {
$all _son. = $row ["id"]. ",";
}
return $all _son;
}
Thank you so much for knowing that I didn't turn back.
return $all _son = $row ["id"]. ",";
??? Every time? $all _son so just go back to the last??? The value,
Change to $all _son. = $row ["id"]. ",";
In the follow-up?? and return $all _son;