Jump to content


Help with making database output into a link

  • Please log in to reply
1 reply to this topic

#1 Stevis2002

  • Members
  • PipPipPip
  • Advanced Member
  • 98 posts

Posted 07 May 2006 - 11:27 AM

Hi all,

I have a page (choice.php), with a dropdown menu, populated with categories, (A-Z).
When one is chosen, it populates the page, (view.php), with the contents of the category which has artists in.
The category is chosen when the selection is made from teh dropdown, which passes the appropiate id, (http://www.srtfdgtr.com/view.php?id=1, (A-1, Z-26)).
What i wish to know is how i can get the outputted artists names to make a link which will then go to another page which will display the appropiate info for each artist from the database fields, artist_name, album_title, and album info?

Here's the code for view.php

<?php require('Connections/xxxdb.php'); ?>
$maxRows_Recordset1 = 10;
$pageNum_Recordset1 = 0;
if (isset($_GET['pageNum_Recordset1'])) {
  $pageNum_Recordset1 = $_GET['pageNum_Recordset1'];
$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;

$colname_Recordset1 = "-1";
if (isset($_GET['category'])) {
  $colname_Recordset1 = (get_magic_quotes_gpc()) ? $_GET['category'] : addslashes($_GET['category']);
mysql_select_db($database_xxxdb, $xxxdb);
$query_Recordset1 = sprintf("SELECT id, artist_name, album_title, category FROM upload2 WHERE category = '%s' ORDER BY artist_name DESC", $colname_Recordset1);
$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
$Recordset1 = mysql_query($query_limit_Recordset1, $xxxdb) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);

if (isset($_GET['totalRows_Recordset1'])) {
  $totalRows_Recordset1 = $_GET['totalRows_Recordset1'];
} else {
  $all_Recordset1 = mysql_query($query_Recordset1);
  $totalRows_Recordset1 = mysql_num_rows($all_Recordset1);
$totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;
<link href="/standard.css" rel="stylesheet" type="text/css">

<style type="text/css">
.style10 {
    font-size: 14;
    color: #999933;
<title>xxx - Search Results</title><p>&nbsp;</p>
<div align="center" class="style1 style10">
  <p><?php echo $totalRows_Recordset1 ?> Category Result Found<br>
<table width="383" border="0" align="center" cellpadding="8" cellspacing="5">
    <td><div align="center" class="style5">Artist / Group </div></td>
    <td><div align="center" class="style5">Album Title </div></td>
  <?php do { ?>
      <td class="style6"><div align="center"><?php echo $row_Recordset1['artist_name']; ?>
      <td class="style6"><div align="center"><?php echo $row_Recordset1['album_title']; ?></div></td>

    <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>

Thanks all

#2 emehrkay

  • Staff Alumni
  • Advanced Member
  • 1,214 posts

Posted 07 May 2006 - 02:08 PM

this shouldnt be too difficult to do. you already have the page outputting data, you just need to edit a litle

this section here where you echo a td with the artist's name you can easily make it a link

<td class="style6"><div align="center"><?php echo $row_Recordset1['artist_name']; ?>

<td class="style6"><div align="center"><?php echo <a href\"=page.php?id=".$row_Recordset1['id']."\">".$row_Recordset1['artist_name']."</a>; ?>

then on page.php do

$id = $_GET['id];
and run a query based on that $id

$query = "SELECT * FROM table WHERE id = ". $id ."";

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users