asmith Posted December 11, 2007 Share Posted December 11, 2007 hey guys ! i have an array like : $a = array( "1" ,"5" , "8" ,"12"); and a table in mysql which a lot of columns , one of the columns is "id" which is int. table like this : id aa bb cc dd 1 12 45 454 45 2 34 34 76 45 . . . my question is how can i show a list of this table rows which the id is values in my array ? then again i mean if i want to show my mysql table in a html table exactlly like above, but only showing the rows which is in my array. thanks Link to comment https://forums.phpfreaks.com/topic/81159-solved-array-item-in-a-table/ Share on other sites More sharing options...
rajivgonsalves Posted December 11, 2007 Share Posted December 11, 2007 something like this should work on the sql part $a = array( "1" ,"5" , "8" ,"12"); $sql = "select * from table where id in (".implode(",",$a).")"; then you can use the mysql functions to fetch the data and display it accordingly Link to comment https://forums.phpfreaks.com/topic/81159-solved-array-item-in-a-table/#findComment-411823 Share on other sites More sharing options...
asmith Posted December 11, 2007 Author Share Posted December 11, 2007 whoa man !! i was going to code 5 or 6 line about it ! you taught me a new line in mysql too !!! thanks a bunch ! again you ( i have 2 big question waiting ! big question for me of course , don't know when to ask ! lol ) Link to comment https://forums.phpfreaks.com/topic/81159-solved-array-item-in-a-table/#findComment-411833 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.