supposed a variable named $xlnum value is as this 20,4,56,987,68,96.....the variable $xlnum value is input by the vistor.
the next i will passed the value to a sql query. if the value is one. that i can know how to do it. eg:
$result=mysql_query("select nid,title form node where nid=20");
while($row = mysql_fetch_object($result)) {
echo $row->nid;
echo $row->title;
}
but now the value is 20 4 56...,i want to loop out all the nid and title of 20,4,56,987,68,96.....how do i do.
In short:
But you need to validate that it contains sane values.
Assume
$xlnum = '20,4,56,987,68,96';in these examples. Both end up with$sqlthat you can pass tomysql_query.Option 1
Option 2
These are just two different ways to make sure the input is valid. The second is slightly different in that it will just ignore the pieces that are invalid.
I prefer something more like the second since it’s easy to accidentally mess up a regular expression.