amin1982 Posted August 2, 2007 Share Posted August 2, 2007 Hey Guys, Need some help here! I'm building a site at the moment which is database driven. I have a menu which lists about 20 or so clubs in london. When each of these clubs are clicked the user should be taken to a page which shows content about that club. However this works when I tested it with two venues on the database but when I added more the links kept showing the same data on each page even if the URL would change. if you go to: http://www.omaraguestlist.co.uk/test/database/londonclub3.php You will see a list of 4 venues. If you click on "24 London" everything is ok... as is when you click on funkybuddha (these were the initial two venues in the database) however when I click on Amika or Paper I simply get the same info thats for funkybuddha!!! The URL changes as you would expect so you are taken to a new page! This is driving me nuts! The database has been populated correctly and I cant see whats wrong with the code. <?php require_once ('includes/buffer.php'); require_once ('includes/config.inc.php'); require_once ('includes/mysql_connect.php'); // Connect to the database. ?> <?php $query = "SELECT * FROM `londonclubs2` WHERE active='1' ORDER BY londonclub"; $result = mysql_query($query) or die('Error, query failed'); while ($list = mysql_fetch_array($result)) { echo "<a href ='londonclub3.php?londonclub={$list['londonclub']}' class='Text' >{$list['clubName']}</a> <br>"; } ?> <?php $problem = FALSE; if (isset($_GET['londonclub'])) { $londonclub= (int) $_GET['londonclub']; $sql = "SELECT * FROM londonclubs2 WHERE londonclub = $londonclub"; $result = mysql_query ($sql, $dbc); if (mysql_num_rows($result)) { // Good to go! $row = mysql_fetch_array ($result, MYSQLI_ASSOC); echo "{$row['image001']}"; echo "{$row['image002']}"; echo "{$row['image003']}"; echo "{$row['image004']}"; echo "{$row['heading']}"; echo "{$row['description']}"; echo "{$row['reviewform']}"; } } ?> Could there be something missing or incorrect with the code? Or is the database set up incorrectlty? Please help... Link to comment https://forums.phpfreaks.com/topic/62982-solved-problem-with-showing-records-from-database/ Share on other sites More sharing options...
marcus Posted August 2, 2007 Share Posted August 2, 2007 1. Why do you have (int) in your $londonclub variable 2. Add an or die statemeont on your second result [before the //good to go! comment] 3. Why waste space, just use mysql_fetch_assoc($result) Link to comment https://forums.phpfreaks.com/topic/62982-solved-problem-with-showing-records-from-database/#findComment-313651 Share on other sites More sharing options...
harristweed Posted August 2, 2007 Share Posted August 2, 2007 $londonclub= (int) $_GET['londonclub']; will produce a '0' try: $londonclub= trim($_GET['londonclub']); Link to comment https://forums.phpfreaks.com/topic/62982-solved-problem-with-showing-records-from-database/#findComment-313654 Share on other sites More sharing options...
Crew-Portal Posted August 2, 2007 Share Posted August 2, 2007 <table width="575" border="0"> <tr bgcolor="#999999"> <td><strong>Colum Number 1:<strong></td> <td><strong>Colum Number 2:</strong></td> <td><strong>Colum Number 3:</strong></td> <td><strong>Colum Number 4:</strong></td> <td><strong>Colum Number 5:</strong></td> </tr> <?php $query="select * from database"; // query string stored in a variable $rt=mysql_query($query); // query executed echo mysql_error(); // if any error is there that will be printed to the screen while($nt=mysql_fetch_array($rt)){ echo " <tr bgcolor=#990000> <td><strong><span class=white>$nt[colum1]</span></strong></td> <td><strong><span class=white>$nt[colum2]</span></strong></td> <td><strong><span class=white>$nt[colum3]</span></strong></td> <td><strong><span class=white>$nt[colum4]</span></strong></td> <td><strong><span class=white>$nt[colum5]</span></strong></td> </tr> "; } ?> </table> ^^^ Is the easiest way to do it! Link to comment https://forums.phpfreaks.com/topic/62982-solved-problem-with-showing-records-from-database/#findComment-313707 Share on other sites More sharing options...
amin1982 Posted August 2, 2007 Author Share Posted August 2, 2007 hey guys just wanted to say a big thank you to you all! i took abit of advice from all of you and its seemed to have worked! thanks Link to comment https://forums.phpfreaks.com/topic/62982-solved-problem-with-showing-records-from-database/#findComment-313861 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.