Im new at PHP but learning fast,

I need help on getting the mysql result into the $imagedir value

//Select Query for images from db
$query="SELECT id, fld_imagename FROM tbl_banner";
$result = mysql_query($query) or die(mysql_error());   

//Loop to get path from query
while($row = mysql_fetch_array( $result )) 

$mydir = "imge_uploads/".$row['fld_imagename']. ",";?>

<?php } 

// Image directory - HERE THE RESULT MUST BE
$imageDir = $mydir;

Maybe im just a bit uneducated thus far .. lol $imageDir should get the path that is stored in mysql ...

This method does not work


Ideally saying this code should work (just tried this). Are you sure, that SELECT query is returning any data.

Do one thing, write something like

echo "blabla..";

Inside the while loop to check if it is really returning any rows.

Member Avatar

If you are expecting a single result, you don't need the while loop. Check for any result with mysql_num_rows().