Connecting Tech Pros Worldwide Forums | Help | Site Map

Trouble extracting info from database

Ian Rastall
Guest
 
Posts: n/a
#1: Jul 17 '05
Ah, I hope it's okay to keep posting questions, and sorry for the
vague subject line. This is my problem: I've got a database set
up with 7 fields: ID, Album, Year, Type, Songs, Members,
Production. I've built a dynamic table that list Album, Year and
Type, and when you click on Album, the other info is supposed to
appear to the left. Well, it does, for the first entry, but not
for subsequent entries. Here's the code from the top of the page:

***

<?php require_once('Connections/gong.php'); ?>
<?php
$order=$_GET['order'];
$sort_order = 'Year';
if($order == 'Album'){
$sort_order = 'Album';
}else if($order == 'Year') {
$sort_order = 'Year';
}else if($order == 'Type'){
$sort_order = 'Type';
}

$album=$_GET['album'];

mysql_select_db($database_gong, $gong);
$query_rsGongBand = "SELECT * FROM gong_band ORDER BY $sort_order
ASC";
$rsGongBand = mysql_query($query_rsGongBand, $gong) or die
(mysql_error());
$row_rsGongBand = mysql_fetch_assoc($rsGongBand);
$totalRows_rsGongBand = mysql_num_rows($rsGongBand);
?>

***

And here's the code from the body section:

***

<?php if ($album) { ?>
<h3><?php echo $row_rsGongBand['Album']; ?></h3>
<?php
echo $row_rsGongBand['Songs'];
echo $row_rsGongBand['Members'];
echo $row_rsGongBand['Production'];
?>

<?php } ?>

***

And the sort table:

***

<thead>
<tr>
<td><a href="<?php print $_SERVER['PHP_SELF']."?order=Album";
?>">Album</a></td>
<td><a href="<?php print $_SERVER['PHP_SELF']."?order=Year";
?>">Year</a></td>
<td><a href="<?php print $_SERVER['PHP_SELF']."?order=Type";
?>">Type</a></td>
</tr>
</thead>
<tbody>
<?php do { ?>
<?php
$class = ($class == 'odd') ? 'even' : 'odd';
?>
<tr class="<?php echo $class ?>">
<td><a href="<?php print $_SERVER['PHP_SELF']."?album=".
$row_rsGongBand['Album'];
?>">
<?php echo $row_rsGongBand['Album']; ?></a></td>
<td><?php echo $row_rsGongBand['Year']; ?></td>
<td><?php echo $row_rsGongBand['Type']; ?></td>
</tr>
<?php } while ($row_rsGongBand = mysql_fetch_assoc
($rsGongBand)); ?>
</tbody>

***

What I need is to pull information from a specific row of the
database, based on what the album name is in the URL, but instead
it's giving me the information from the first row. I think the
$album variable is the key, but at the moment I don't seem to be
using it, as it was left over from a different version of the
page.

Thanks for answering all my numerous questions. :-) I'm slowly
getting my mind around all of this.

Ian
--
http://www.bookstacks.org/

Ian Rastall
Guest
 
Posts: n/a
#2: Jul 17 '05

re: Trouble extracting info from database


Okay, I've solved that problem and moved on to an entirely different
one! I won't trouble the group with it, though. Just wanted to say I
don't need an answer, and do appreciate the other help I've gotten.
Diving right in to PHP has its benefits, but it's times like this I
wish I were a comp sci student rather than self-taught. :-)

Ian
--
http://www.bookstacks.org/
Closed Thread


Similar PHP bytes