How do I send in a "multi"-string variable(looking like this: 1,2.3,4) into a php through a parameter which goes through an url.
Lets say some of the php that is connected to the mysql server looks something like this
`$id_ = $_GET['id'];`
`$q=mysql_query("SELECT * FROM brain WHERE braincell_id in ('$id_');`
And the variable that goes into it is: id = 1,2,3,4
How can I make this work?
What I am using currently and that does work:
$q=mysql_query("SELECT * FROM brain WHERE braincell_id in ("$_GET['id']");
EDIT. Sorry it's me being stupid, it is way to late for me to be doing this stuff..... I missed a parentheses please remove this post.
Pass $q
, your result resource. It references all the data returned from MySQL, and you can use the usual mysql_*
functions on it (eg. mysql_fetch_array()
).
Alternatively, call mysql_fetch_array()
(or similar) and pass the resultant array to your function.
The only solution that I know that will work out of the box is to pass each element of array as an separate parameter.
Here is my example:
get.php:
$arr = $_GET['id'];
echo '<ul>';
foreach($arr as $id)
{
echo "<li>{$id}</li>";
}
echo '</ul>';
URL:
get.php?id[]=1&id[]=2&id[]=3
Also you can pass key for each element:
get.php?id[0]=1&id[1]=2&id[2]=3
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.