Jump to content

[SOLVED] array, item in a table


asmith

Recommended Posts

hey guys ! :D

 

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

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

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.