sftl99
04-30-2007, 10:43 PM
The code below is a simplified version of code that is first creating a looping gallery of thumbnails based on the URL which would have ?c=Something. Then once the link is clicked, it adds &v=SKU. Based on the SKU, I am able to display the details of the selection. It all works just fine, however in the live version I have to work in some code to account for the page not having anything to display until a thumbnail is clicked.
What I want instead, is to pull the first record available in "Collection" and display the details for that selection. I know it has to be possible...can anyone let me know how?
<? $c = $_GET['c'];
$query = "SELECT * FROM $database WHERE `Collection` = '$c' ORDER BY `SKU`";
$result = mysql_query($query) or exit(mysql_error());
if( $result ) {
while( $row = mysql_fetch_assoc($result) )
{
?><p><a href="collection.php?c=<?=$c?>&v=<?=$row['SKU']?>"><img src="images/jewelry/thumbs/<?=$row['image']?>" border="0"></a></p><?
}
} else { die( "Trouble getting contacts from database: " . mysql_error() ); }
$v = $_GET['v'];
$query = "SELECT * FROM `$database` WHERE `SKU`='$v'";
$result = mysql_query( $query );
if( $result && $database = mysql_fetch_object( $result ) )
{
$Collection = $database -> Collection;
$Type = $database -> Type;
$SKU = $database -> SKU;
$Price = $database -> Price;
$Description = $database -> Description;
$image = $database -> image;
} ?>
<?=$Collection?><br>
<?=$Type?><br>
<?=$SKU?><br>
<?=$Price?><br>
<img src="images/jewelry/<?=$image?>"><br>
<?=$Description?>
What I want instead, is to pull the first record available in "Collection" and display the details for that selection. I know it has to be possible...can anyone let me know how?
<? $c = $_GET['c'];
$query = "SELECT * FROM $database WHERE `Collection` = '$c' ORDER BY `SKU`";
$result = mysql_query($query) or exit(mysql_error());
if( $result ) {
while( $row = mysql_fetch_assoc($result) )
{
?><p><a href="collection.php?c=<?=$c?>&v=<?=$row['SKU']?>"><img src="images/jewelry/thumbs/<?=$row['image']?>" border="0"></a></p><?
}
} else { die( "Trouble getting contacts from database: " . mysql_error() ); }
$v = $_GET['v'];
$query = "SELECT * FROM `$database` WHERE `SKU`='$v'";
$result = mysql_query( $query );
if( $result && $database = mysql_fetch_object( $result ) )
{
$Collection = $database -> Collection;
$Type = $database -> Type;
$SKU = $database -> SKU;
$Price = $database -> Price;
$Description = $database -> Description;
$image = $database -> image;
} ?>
<?=$Collection?><br>
<?=$Type?><br>
<?=$SKU?><br>
<?=$Price?><br>
<img src="images/jewelry/<?=$image?>"><br>
<?=$Description?>