I'm probably missing something easy...all help welcomed.
I am currently creating an 'Images' page which displays a thumbnail (url), the image title, and the image caption.
These all live in a table called 'portfolio' - the the relevant fields:
imagethumb, imagetitle and imagecaption.
Here is where I get lost...
...there is also a PRIMARY Key, Integer, auto_increment set as 'id' - with the plan to increase as the rows in the database do.
I've thought about giving each field a UNIQUE name - imagethumb1 --> imagethumb21
ut as you can imagine the database would soon get 'messy'
Is there a way for me to access a particluar row by using the 'id' as the reference.
This is what I have so far:
<?php
@ require_once("db_connect.php");
$query = "SELECT id,imagethumb,imagetitle,imagecaption FROM portfolio";
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
$id = mysql_result ( $result, 0, "id" );
$imagethumb = mysql_result ( $result, 0, "imagethumb" );
$imagetitle = mysql_result ( $result, 0, "imagetitle" );
$imagecaption = mysql_result ( $result, 0, "imagecaption" );
And to display the data:
Image Number: <?php echo ($imagethumb); ?>
Image Title: <?php echo($imagetitle); ?>
Image Thumbnail: <?php echo("<img src=\"../portfolio/".$imagethumb.".jpg\""); ?>
Image Caption:<?php echo($imagecaption); ?>
This as you can imagine works fine for the first row in the database....
...what I would I have to do to make the unique 'id' from each row change so I can call up whatever $variable I want.
I think I need to make the 'id' into an array - e.g: $imagethumb['12']
But I don't have a clue how to do this.
Any help?