Jump to content


This topic is now archived and is closed to further replies.


Help with making database output into a link

Recommended Posts

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

Share this post

Link to post
Share on other sites
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 ."";

Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.