Siggles Posted December 7, 2007 Share Posted December 7, 2007 Hi, I am using a gallery script (see below). It uses a lot of global variables created by the script designer and the function below is the function that displays all the galleries images on one page. I am trying to take data from the dbase (that has the pics name) from the gallery mysql dbase and make it the alt tag of the individual pics. If I had written the script myself I would use a simple Mysql_query and then call the row['title'] from the result or something similar but becauase of the nature of the script I am having problems. I have altered the script below in two places (see where I have marked) and now get the title of the first pic for all pics (for example every pic has name Frank). Is there an easier way to do this. I thought about using a $alttag++ type counter thingy on the id$ of the pic but some ids are missing in the tables. Eg, id 18 doesn't exist. Can you help? echo "<a href='./submit.php'><u>Submit an Image to the Gallery</u></a>"; // added heading echo "<br>"; if (!$from) $from = 0; $result = mysql_query("SELECT * FROM $table_images WHERE $querystring ORDER BY id DESC LIMIT $from, $numimages"); $hello = mysql_query("SELECT title FROM sylverblog_images"); // I ADDED THIS LINE AND THE NEXT.... $helloyou = mysql_result($hello, 0, 0); $cnt = mysql_num_rows($result); if ($in_row) $resultstring .= "<table><tr>"; for($x=0;$x<$cnt;$x++){ $file = mysql_result($result,$x, "$table_images.file"); $num = mysql_result($result,$x, "$table_images.id"); if (!$in_row) { $resultstring = $resultstring . "<a href=\"$namesite?" . $gallerystr . "id=" . $num . "\"><img class=\"$thclass\" border=\"0\" src=\"$imagedir/$thumbdir/" . $file . "\" alt=\"\" /></a> \n"; } else { // $in_row is not 0 $resultstring = $resultstring . "<td align=\"center\"><a href=\"$namesite?" . $gallerystr . "id=" . $num . "\"><img class=\"$thclass\" border=\"0\" src=\"$imagedir/$thumbdir/" . $file . "\" alt=\"" .$helloyou. "\" /></a> \n </td>"; if (($x+ 1) % $in_row== 0) $resultstring .= " </tr><tr>\n "; } } if ($in_row) $resultstring .= "</tr></table>"; } Quote Link to comment https://forums.phpfreaks.com/topic/80626-solved-mysql_result-alt-tag/ Share on other sites More sharing options...
Siggles Posted December 7, 2007 Author Share Posted December 7, 2007 I should trust myself more. I figured it out. For those who can make sense of my post above.... $helloyou = mysql_result($result,$x, "$table_images.title"); $file = mysql_result($result,$x, "$table_images.file"); $num = mysql_result($result,$x, "$table_images.id"); alt=\"" .$helloyou. "\" I call the title field from thedbase in the first row in the code above then echo it in the bottom row. Quote Link to comment https://forums.phpfreaks.com/topic/80626-solved-mysql_result-alt-tag/#findComment-408859 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.