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

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
l0lek
Forum Newbie
Posts: 1
Joined: Fri Jul 20, 2007 12:48 pm

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

Post 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
User avatar
boo
Forum Commoner
Posts: 42
Joined: Mon Jul 02, 2007 11:30 am
Location: NY

Post 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));
Post Reply