Boxerman Posted April 5, 2012 Share Posted April 5, 2012 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 Quote Link to comment https://forums.phpfreaks.com/topic/260382-if-value-is-artist-display-titles/ Share on other sites More sharing options...
dragon_sa Posted April 5, 2012 Share Posted April 5, 2012 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) { Quote Link to comment https://forums.phpfreaks.com/topic/260382-if-value-is-artist-display-titles/#findComment-1334567 Share on other sites More sharing options...
Boxerman Posted April 5, 2012 Author Share Posted April 5, 2012 I see so i need to remove <0? If so what will it need to be changed too? as Artist in the db is a name, i.e rizzle kicks etc.. Quote Link to comment https://forums.phpfreaks.com/topic/260382-if-value-is-artist-display-titles/#findComment-1334573 Share on other sites More sharing options...
dragon_sa Posted April 5, 2012 Share Posted April 5, 2012 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 Quote Link to comment https://forums.phpfreaks.com/topic/260382-if-value-is-artist-display-titles/#findComment-1334575 Share on other sites More sharing options...
Boxerman Posted April 5, 2012 Author Share Posted April 5, 2012 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 } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/260382-if-value-is-artist-display-titles/#findComment-1334580 Share on other sites More sharing options...
dragon_sa Posted April 5, 2012 Share Posted April 5, 2012 remove this bit } /* if artist is set display the artist */ if($artist="") { That is already handled in the if statement I gave you be sure to remove all the code I showed eg including the curly braces Quote Link to comment https://forums.phpfreaks.com/topic/260382-if-value-is-artist-display-titles/#findComment-1334585 Share on other sites More sharing options...
Boxerman Posted April 5, 2012 Author Share Posted April 5, 2012 Thank you for your time buddy! Great stuff! Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/260382-if-value-is-artist-display-titles/#findComment-1334586 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.