I use:
foreach($image_files as $index=>$file)}
to loop between pictures in a directory and list them in a webpage, every picture has three related column in the database (ID, NAME, DESCRIPTION) ... so I used
SELECT `NAME`, `DESCRIPTION` FROM `pic_info` WHERE `ID`= '$counter' ...
but i don't know how can I split the
$rows = mysql_fetch_array($result, MYSQL_ASSOC)
to 2 variable for each picture ... for example : for the first pic I need
$name[0] = pic1 and $description[0] = blahblahblah1 ...
$name[1] = pic2 , $description[1] = blahblahblah2 ...
using
foreach ($rows as $key => $value) {$$key = $value; }
just gives me a combined data like $name[0] and $description[0] that I don't know how can I split it to two variable ... and it'll be appreciated if someone show another ways to SELECT two column in a table and assign it to two variables .
mysql_fetch_array(), usemysql_fetch_assoc()instead, that way you can fetch the single entries one by one in a while loop. This is shown in millions of examples out there on the net. Plus it scales better, since it processes sequencially instead of loading all entries into RAM, that might be thousands of entries. That said: the oldmysqlextension has been deprecated log ago, this is documented, you should switch to either the newermysqliextension orPDOand make use of prepared statements.