Jump to content

[SOLVED] Problem With Showing Records From Database


amin1982

Recommended Posts

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
Share on other sites

<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
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.