November 4, 201114 yr Hi guys, I cant figure this one out. $result = mysql_query("SELECT jobalert.id, firstname, lastname, email, mobile, jobSectorid, location, date FROM jobalert WHERE jobalert.id IN(1,13,21) ORDER BY lastname"); Running this work fine, and three rows are selected, but I need to use a variable I have created for the in part like this $result = mysql_query("SELECT jobalert.id, firstname, lastname, email, mobile, jobSectorid, location, date FROM jobalert WHERE jobalert.id IN('$part') ORDER BY lastname"); $part = '1,13,21'; I only ever get the row with the ID of 1 returned using the last statement. How do I go about getting it to select 2 lines or more using the variable $part. Cheers Edited November 4, 201114 yr by tangerine_dreamer
November 4, 201114 yr you need to remove the ' from either side of the $part, as it thinks it's a string Be sure to sanitize your data since you are doing this, to avoid mysql injection in the real version
November 4, 201114 yr Author you need to remove the ' from either side of the $part, as it thinks it's a string Be sure to sanitize your data since you are doing this, to avoid mysql injection in the real version Thanks a lot for the quick response! So simple! Fully working now! Thanks again
Create an account or sign in to comment