mnybud Posted November 11, 2007 Share Posted November 11, 2007 I have the following code: <?php mysql_connect("localhost", "root", "password") or die(mysql_error()); mysql_select_db("transmission") or die(mysql_error()); $ID=$_GET['ID']; $query = "SELECT * FROM Auto_database_final ORDER BY ID ASC LIMIT $ID, $ID"; $result = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_array($result) or die(mysql_error()); print "<h1>" . $row['year_maker_model']. " </H1><P><b>Model:</b> ". $row['submodel']. " <BR><br /><b>Body Style:</b> ". $row['body_style']. " <BR><br /><b>Engine:</b> ". $row['engines']. " <BR><br /> <b>". $row['year_maker_model']. " Transmission: </b>" . $row['transmissions']. " <BR><br /><b>DriveTrain:</b> ". $row['drivetrains']. " <BR><BR><b>Performance and Efficiency:</b> ". $row['performance_efficiency']. " <BR><br /><b>Handling and Breaking:</b> ". $row['handling_riding_beaking']. " <BR><br /><b>Exterior:</b> ". $row['exterior_aerodymamics']. " <br /><BR><b>Interior:</b> ". $row['interior']; ?> It should display the data by the ID in the mysql database but it is always one off.....so page.php?ID=1 displays ID2 content and page.php?ID=2 displays ID3 content and so on. You can see it here... http://www.rebuilt-transmissions-fast.com/database3.php?page=1 I am assuming I have something wrong but I cant figure it out for the life of me....any help? Quote Link to comment Share on other sites More sharing options...
nuxy Posted November 11, 2007 Share Posted November 11, 2007 Hello there mnybud, I could be wrong on this one, but try the sql query as: $query = "SELECT * FROM Auto_database_final ORDER BY ID ASC LIMIT 0, $ID"; Also try the following: $query = "SELECT * FROM Auto_database_final ORDER BY ID ASC LIMIT $ID"; Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted November 11, 2007 Share Posted November 11, 2007 actually the first one will display nothing the second query is right $query = "SELECT * FROM Auto_database_final ORDER BY ID ASC LIMIT $ID"; Quote Link to comment Share on other sites More sharing options...
mnybud Posted November 11, 2007 Author Share Posted November 11, 2007 Thanks but neither of those work for me. When I use either one I just get the 1st record no matter what ID I put in the url. I left it broke so you could look.... http://www.rebuilt-transmissions-fast.com/database3.php?page=1 http://www.rebuilt-transmissions-fast.com/database.php?ID=8 http://www.rebuilt-transmissions-fast.com/database.php?ID=22 Quote Link to comment Share on other sites More sharing options...
Daukan Posted November 11, 2007 Share Posted November 11, 2007 Why are you putting the id in the LIMIT function? That doesn't seem like it will work. Just try it without the LIMiT or if you want just one row put LIMIT 1 Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted November 11, 2007 Share Posted November 11, 2007 so you want to limit it by ID correct? so you would do it like ORDER BY ID ASC LIMIT 1 or as duakan said dont use it Quote Link to comment Share on other sites More sharing options...
mnybud Posted November 11, 2007 Author Share Posted November 11, 2007 I thought the same but if I do that it returns ID1 no matter what url I use. This... ORDER BY ID ASC LIMIT 1 Also returns ID1 each time. Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted November 11, 2007 Share Posted November 11, 2007 right it only returns one row in the database please specify how many rows you wish to return Quote Link to comment Share on other sites More sharing options...
mnybud Posted November 11, 2007 Author Share Posted November 11, 2007 This is what I am trying to do.... I have this page setup which is working fine to display the links to the specific cars details. http://www.rebuilt-transmissions-fast.com/database3.php?page=1 If you click one though you will see it displays the wrong car data, ID1 shows ID2, etc. I tried all the solutions posted and many of my own and they all return just ID1 data not the correct ID's data. That make sense? the closest I have come to getting it right is with the code on my first post which is what is currently live. Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted November 11, 2007 Share Posted November 11, 2007 $query = "SELECT * FROM Auto_database_final ORDER BY ID ASC " take out the limit then Quote Link to comment Share on other sites More sharing options...
Daukan Posted November 11, 2007 Share Posted November 11, 2007 If you want a specific id $query = " SELECT * FROM Auto_database_final WHERE id='$ID' " ; Quote Link to comment Share on other sites More sharing options...
mnybud Posted November 11, 2007 Author Share Posted November 11, 2007 $query = " SELECT * FROM Auto_database_final WHERE id='$ID' " ; Thats it....Thanks so much!! Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted November 11, 2007 Share Posted November 11, 2007 topic solved please Quote Link to comment 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.