search returns same result each time
Firstly - apologies for this being a real newbie question/problem: been banging my head against this for so long I can't see what's what. I have two pages - one lists a group of artists pulled from a MySQL db table. That bit works fine. What I'm trying to do is have these click through to the appropriate detail in the db, but what's happening each time is that the same record (the first in the table) gets returned. The first page is pre-test.php and the code is as follows:
-------------------------
<?php require_once('Connections/album.php'); ?><?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
mysql_select_db($database_album, $album);
$query_rsListing = "SELECT * FROM albumlist";
$rsListing = mysql_query($query_rsListing, $album) or die(mysql_error());
$row_rsListing = mysql_fetch_assoc($rsListing);
$totalRows_rsListing = mysql_num_rows($rsListing);
$query_rsListing = "SELECT artist FROM albumlist";
$rsListing = mysql_query($query_rsListing, $album) or die(mysql_error());
$row_rsListing = mysql_fetch_assoc($rsListing);
$totalRows_rsListing = mysql_num_rows($rsListing);
?><?php
// RepeatSelectionCounter_1 Initialization
$RepeatSelectionCounter_1 = 0;
$RepeatSelectionCounterBasedLooping_1 = false;
$RepeatSelectionCounter_1_Iterations = "4";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Album Auction</title>
<style type="text/css">
<!--
.style1 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
}
-->
</style>
</head>
<body>
<form action="test.php" name="albumselect" id="albumselect">
<table width="600" align="left" cellpadding="6">
<?php do { ?>
<tr>
<?php
// RepeatSelectionCounter_1 Begin Loop
$RepeatSelectionCounter_1_IterationsRemaining = $RepeatSelectionCounter_1_Iterations;
while($RepeatSelectionCounter_1_IterationsRemaining--){
if($RepeatSelectionCounterBasedLooping_1 || $row_rsListing){
?>
<td><div align="center"><a href="test.php" class="style1"><?php echo $row_rsListing['artist']; ?></a> </div></td>
<?php
} // RepeatSelectionCounter_1 Begin Alternate Content
else{
?>
<td> </td>
<?php } // RepeatSelectionCounter_1 End Alternate Content
if(!$RepeatSelectionCounterBasedLooping_1 && $RepeatSelectionCounter_1_IterationsRemaining != 0){
if(!$row_rsListing && $RepeatSelectionCounter_1_Iterations == -1){$RepeatSelectionCounter_1_IterationsRemaining = 0;}
$row_rsListing = mysql_fetch_assoc($rsListing);
}
$RepeatSelectionCounter_1++;
} // RepeatSelectionCounter_1 End Loop
?>
</tr>
<?php } while ($row_rsListing = mysql_fetch_assoc($rsListing)); ?>
</table>
</form>
<p> </p>
</body>
</html>
<?php
mysql_free_result($rsListing);
mysql_free_result($rsListing);
?>
-------------------------
and the "results" page is called test.php and the code for this is as follows:
-------------------------
<?php require_once('Connections/album.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
mysql_select_db($database_album, $album);
$query_rsAlbums = "SELECT DISTINCT artist, title, `description`, signedby, certification, reserveprice, insurance, smallphoto, largephoto, mtTitle, mtKeywords, mtDescription FROM albumlist";
$rsAlbums = mysql_query($query_rsAlbums, $album) or die(mysql_error());
$row_rsAlbums = mysql_fetch_assoc($rsAlbums);
$totalRows_rsAlbums = mysql_num_rows($rsAlbums);
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Record Auctions | <?php echo $row_rsAlbums['mtTitle']; ?> Fundraising Auction Prize To Use At Your Fundraising Event</title>
<meta name="description" content="<?php echo $row_rsAlbums['mtDescription']; ?>" />
<meta name="keywords" content="<?php echo $row_rsAlbums['mtKeywords']; ?>" />
<style type="text/css">
<!--
.style1 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-weight: bold;
font-size: 12px;
}
.style4 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; }
.style6 {font-family: Verdana, Arial, Helvetica, sans-serif; font-weight: bold; font-size: 14px; color: #FF0000; }
-->
</style>
</head>
<body>
<table width="100%">
<tr>
<td width="50%" rowspan="7"><a target="_blank"></a><a href="<?php echo $row_rsAlbums['largephoto']; ?>" target="_blank"><img src="<?php echo $row_rsAlbums['smallphoto']; ?>" border="0" /></a></td>
<td width="50%"><div align="center" class="style6"><?php echo $row_rsAlbums['artist']; ?></div></td>
</tr>
<tr>
<td><div align="center"><?php echo $row_rsAlbums['title']; ?></div></td>
</tr>
<tr>
<td><div align="center"><?php echo $row_rsAlbums['description']; ?></div></td>
</tr>
<tr>
<td><div align="center"><span class="style1">Personally signed by: </span><?php echo $row_rsAlbums['signedby']; ?></div></td>
</tr>
<tr>
<td><div align="center"><?php echo $row_rsAlbums['certification']; ?></div></td>
</tr>
<tr>
<td><div align="center"><?php echo $row_rsAlbums['reserveprice']; ?></div></td>
</tr>
<tr>
<td><div align="center"><?php echo $row_rsAlbums['insurance']; ?></div></td>
</tr>
<tr>
<td><div align="center" class="style4"><a href="<?php echo $row_rsAlbums['largephoto']; ?>" target="_blank">click to enlarge</a> </div></td>
<td><div align="center"></div></td>
</tr>
</table>
</body>
</html>
<?php
mysql_free_result($rsAlbums);
?>
-------------------------
It's probably glaringly obvious to anyone what I'm doing wrong here but for the life of me I can't see it. Any assistance appreciated... thanks in advance.
Jeff