Jump to content

If value is artist display title(s)


Boxerman

Recommended Posts

Hi guys,

 

I'm pretty much stuck and require someones help,

 

I've got this script:

 

<?PHP
$con = mysql_connect("localhost","****","*****");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
  
mysql_select_db("samdb", $con);

/* check to see if an artist has been selected */
if(!$_GET['artist']) {
$artist = 0;
}else{
$artist = $_GET['artist'];
}

/* if artist is set display the artist */
if($artist>0) {
$query = "SELECT * FROM songlist WHERE artist='$artist' ORDER BY id DESC";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
$artist = $row['artist'];
$song = $row['title'];
?><p>
<b><font size="5"><?PHP echo $artist; ?></font> </b><br />
Songs: <?PHP echo $song; ?></p>
<br>
<br>
<a href="artist.php">Back to artist listings</a>
<?PHP
}else{
/* create query */
$query = "SELECT * FROM songlist GROUP BY artist ORDER BY artist DESC LIMIT 10";
/* execute the query */
$result = mysql_query($query);
while($row=mysql_fetch_array($result)) {
$artist = $row['artist'];
$song = $row['title'];
?><p>
<b><font size="5"><?PHP echo $artist; ?></font></b> <br>
<a href="artist.php?artist=<?PHP echo $row['artist']; ?>">See more</a></p>
<?PHP
} }
?>

 

It lists the artist right and thats great, however when i click on a artist's name it shows the same page does not go anywhere?

I've tired everything, it might be so simple its infront of me.. any help will be great!

 

Thanks

J

Link to comment
Share on other sites

is the value for artist sent in the link here actually a number?

<a href="artist.php?artist=<?PHP echo $row['artist']; ?>">

I see you use the same part row here for the artist name

<b><font size="5"><?PHP echo $artist; ?></font></b> <br>

so if the value are sending is not a number this will fail

if($artist>0) {

 

Link to comment
Share on other sites

remove this bit

/* check to see if an artist has been selected */
if(!$_GET['artist']) {
$artist = 0;
}else{
$artist = $_GET['artist'];
}

and change your if($artist>0) { to

if(isset($_GET['artist']) && $_GET['artist'] != '') {
  $artist = mysql_real_escape_string($_GET['artist']);

//rest of your code here

 

Link to comment
Share on other sites

I am still getting the same issue :(

 

<?PHP
$con = mysql_connect("localhost","****","***");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
  
mysql_select_db("samdb", $con);

/* check to see if an artist has been selected */
if(isset($_GET['artist']) && $_GET['artist'] != '') {
  $artist = mysql_real_escape_string($_GET['artist']);
}
/* if artist is set display the artist */
if($artist="") {
$query = "SELECT * FROM songlist WHERE artist='$artist'";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
$artist = $row['artist'];
$song = $row['title'];
?><p>
<b><font size="5"><?PHP echo $artist; ?></font> </b><br />
Songs: <?PHP echo $song; ?></p>
<br>
<br>
<a href="artist.php">Back to artist listings</a>
<?PHP
}else{
/* create query */
$query = "SELECT * FROM songlist GROUP BY artist ORDER BY artist DESC LIMIT 10";
/* execute the query */
$result = mysql_query($query);
while($row=mysql_fetch_array($result)) {
$artist = $row['artist'];
$song = $row['title'];
?><p>
<b><font size="5"><?PHP echo $artist; ?></font></b> <br>
<a href="artist.php?artist=<?PHP echo $row['artist']; ?>">See more</a></p>
<?PHP
} } 
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.