sectachrome Posted September 10, 2007 Share Posted September 10, 2007 Hey guys, Im building a news site for a class. One page has all the news stories listed, each of which links to their respective stories in their entirety. I have the main news page working, but I cannot get the information to pass on to the story page from the links. Main news page <?php include ("connect.php"); $query = "SELECT * FROM News"; $result = mysql_query($query); if(!$result) { die("Could not query the database:<br />". mysql_error()); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>BusinessLink</title> <link href="styles.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="container"> <div id="header"> </div> <div id="bodymain"> <div id="menu"> <ul> <li>Home</li> <li>|</li> <li>Jobs</li> <li>|</li> <li>Calendar</li> </ul> </div> <div id="hometext"> <h2>News</h2> <?php while($row = mysql_fetch_assoc($result)) { ?> <div id="newsbox"> <p><h1><?php echo $row["Title"];?></h1></p> <p><?php echo $row["Date"];?>, <?php echo $row["Author"];?></p> <p><?php echo $row["Blurb"];?></p> <p><a href="story.php?which=<?php echo $row["ID"];?>">Read More</a> </p> </div> <?php } ?> </div> <div id="homenewscol"> </div> </div> </div> </body> </html> <?php mysql_close($connection); ?> Story details page <?php include("connect.php"); $iID = $_GET["which"]; $query = "SELECT * FROM News WHERE ID = $iID"; $result = mysql_query($query); if(!$result) { die("Could not query the database:<br />". mysql_error()); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>BusinessLink</title> <link href="styles.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="container"> <div id="header"> </div> <div id="bodymain"> <div id="menu"> <ul> <li><a href="index.php">Home</a></li> <li>|</li> <li><a href="news.php">News</a></li> <li>|</li> <li><a href="jobs.php">Jobs</a></li> <li>|</li> <li><a href="calendar.php">Calendar</a></li> </ul> </div> <div id="hometext"> <p><h1><?php echo $row["Date"];?></h1></p> <p><a href="news.php">Back To News</a> </p> </div> <div id="homenewscol"> <h2>Top Stories</h2> </div> </div> </div> </body> </html> <?php mysql_close($connection); ?> Everything seems right to me and it is passing on the ID to the story page but nothing will show up ??? I want the story to come up in the "hometext" div. Thanks in advance! Quote Link to comment https://forums.phpfreaks.com/topic/68648-theres-probably-a-simple-solution-to-this/ Share on other sites More sharing options...
pocobueno1388 Posted September 10, 2007 Share Posted September 10, 2007 Does it work when you echo out $row["ID"] somewhere else on the page? From a glance, I don't see any reason why it shouldn't be working. I would assume it has something to do with your database. Check for spelling and make sure your table has a row named "ID". Quote Link to comment https://forums.phpfreaks.com/topic/68648-theres-probably-a-simple-solution-to-this/#findComment-345087 Share on other sites More sharing options...
AdRock Posted September 10, 2007 Share Posted September 10, 2007 while($row=mysql_fetch_array($result)) { echo "<div id=\"hometext\"> <p><h1>".$row["Date"]."</h1></p>" echo "<p><a href="news.php">Back To News</a> </p></div>"; //and for any other divs with content from database } Quote Link to comment https://forums.phpfreaks.com/topic/68648-theres-probably-a-simple-solution-to-this/#findComment-345090 Share on other sites More sharing options...
sectachrome Posted September 10, 2007 Author Share Posted September 10, 2007 Yeah, Ive tried putting it elsewhere on the page and still get nothing. The database works, everything comes up on the main news page. And I do have a row called ID. When I mouse over the "Read more" links on the main news page you can see its picking up the ID in the link, and the correct ID also shows in the URL of the story detail page. Sorry, Im not too good at the technical jargon. Quote Link to comment https://forums.phpfreaks.com/topic/68648-theres-probably-a-simple-solution-to-this/#findComment-345091 Share on other sites More sharing options...
AdRock Posted September 10, 2007 Share Posted September 10, 2007 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>BusinessLink</title> <link href="styles.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="container"> <div id="header"> </div> <div id="bodymain"> <div id="menu"> <ul> <li><a href="index.php">Home</a></li> <li>|</li> <li><a href="news.php">News</a></li> <li>|</li> <li><a href="jobs.php">Jobs</a></li> <li>|</li> <li><a href="calendar.php">Calendar</a></li> </ul> </div> while($row=mysql_fetch_array($result)) { echo "<div id=\"hometext\"><p><h1>".$row["Date"]."</h1></p>" echo "<p><a href="news.php">Back To News</a> </p></div>"; } <div id="homenewscol"> <h2>Top Stories</h2> </div> </div> </div> </body> </html> <?php mysql_close($connection); ?> Quote Link to comment https://forums.phpfreaks.com/topic/68648-theres-probably-a-simple-solution-to-this/#findComment-345094 Share on other sites More sharing options...
sectachrome Posted September 10, 2007 Author Share Posted September 10, 2007 while($row=mysql_fetch_array($result)) { echo "<div id=\"hometext\"> <p><h1>".$row["Date"]."</h1></p>" echo "<p><a href="news.php">Back To News</a> </p></div>"; //and for any other divs with content from database } AH! Right you are. D'oh! Thanks a lot man. You saved me another 30 mins of staring at the screen in bewilderment. Quote Link to comment https://forums.phpfreaks.com/topic/68648-theres-probably-a-simple-solution-to-this/#findComment-345096 Share on other sites More sharing options...
AdRock Posted September 10, 2007 Share Posted September 10, 2007 Glad I could help someone instead of someone helping me for once Quote Link to comment https://forums.phpfreaks.com/topic/68648-theres-probably-a-simple-solution-to-this/#findComment-345099 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.