Page 1 of 1

Help please... I need a few lines to display an image...

Posted: Fri Jul 20, 2007 1:02 pm
by l0lek
I'm a PHP n00b, just started learning it, I'm trying to create a module for my Joomla based site...

I've been trying this for a week, but I simply can't figure it out...

What I want is the module to display a title, and then an image below it...

Here's the SQL Query:
SELECT title, image, category
FROM photos
WHERE date = ( SELECT Max( date ) FROM photos )";

That works perfectly, I just need a few lines of PHP to show this on my site...

So:
Show $title
Display Image <img src=mysite/folder/$category/$image>

Help me please :( :( :(
Thank You

Posted: Fri Jul 20, 2007 1:54 pm
by boo
This is a pretty simple example so you can get the idea. You are able to do much more than this but here is a good starting point

Code: Select all

$query_image= "SELECT title, image, category FROM photos WHERE date = ( SELECT Max( date ) FROM photos )"; 
$image = mysql_query($query_image, $db) or die("Error Connection to DB");
$row_image = mysql_fetch_assoc($image);

do { 

echo '<img src="imagepath/'.  $row_image['image']. ' " border="0" />';
echo '<br>';
echo $row_image['title'];
echo '<br>';


} while ($row_image = mysql_fetch_assoc($image));