I have a form to upload pictures and add relative info into a database (title, filename, comments etc.). What I want to do is output all images and make their correspondent title the ALT tag. This is what I've got so far (which is close to nothing), where "name" is the column containing file names (ex.: "test.jpg"):
Obs.: I don't want to change file names.
<?php
include "header.inc";
include "open_db.inc";
$handle=opendir('thumbs');
while (false!==($file = readdir($handle))) {
if ($file != "." && $file != "..") {
$h = mysql_query ("SELECT * from gallery where (gallery.name=$file)");
$g = mysql_fetch_array($h);
$tre = $g['title'];
echo "<a href=\"images/$file\"><img src=\"thumbs/$file\" alt=\"$tre\"</a>";
}
}
closedir($handle);
include "footer.inc";
?>
Any help?
Thanks in advance,
helil