Jump to content

[SOLVED] mysql_result - alt tag


Siggles

Recommended Posts

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>";

}

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.