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

ty
Mike

Recommended Answers

All 3 Replies

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.

you have mixed PHP tags. revisit your file please

Member Avatar for diafol

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.