ROCKINDANO Posted February 27, 2009 Share Posted February 27, 2009 Hello all, i have a problem, i am working on project, and i have a table for events (event_id, title, short description, full description). i have a page that list all the events and its working fine. if i click on a event's read more link it takes me to that event's full description when i have 9 records. now the problem is here. when i insert the 10th record, and display all events, it points to record one description. my code is right cause it works with the max of nine records, but when i have 10 records, it doesn't get the event_id for that 10 record it gets the first event_id which is 1. any help. this is my list all events if event_id is not set (newsevents.php) <!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=utf-8" /> <title>Events</title> </head> <body class="newsrelease"> <div id="cmain_wrapper"> <?php include ('header.php');?> </div> <div class="padding"> <div id="cmain_content"> <p style="padding-bottom:0"><font style="font-family: Arial, Helvetica, sans-serif; color:#0066CC; font-size:18px">City Headlines</font></p> <?php if(!($db = @ mysql_connect('localhost', 'user', 'password))) { echo 'Error: Could not connect to our database sorry for any inconvience.<br /> Please try at a later time.'; exit; } //select which database you want to edit mysql_select_db("news_db"); $news_id = $_GET["news_id"]; if(!isset($news_id)) { $query = "SELECT * FROM news ORDER BY news_id DESC"; $result = mysql_query($query); //goes through all records in database and retrieves the need ones. while($r=mysql_fetch_array($result)) { //the format is $variable = $r["nameofmysqlcolumn"]; $news_id=$r["news_id"]; //displays all info only first three print "<p><b style='color:#9F0000'>".$title=$r["title"]."</b><br />"; print $description=$r["description"]; print "… <br /><a href='newsevents.php?news_id={$news_id['news_id']}'>read more »</a></p>"; }//end while loop }//end if else{ $query="SELECT * FROM news WHERE news_id='$news_id'"; $result = mysql_query($query); //putting all fiels into array to display them. print "<table width='200' border='0'> <tr><td><form method='get' action='newsevents.php'><input type='submit' value='News Archives' /> </form></td></tr></table><br /><br />"; while($r=mysql_fetch_array($result)) { //the format is $variable = $r["nameofmysqlcolumn"]; //modify these to match your mysql table columns $title=$r["title"]; $fulldesc=$r["fulldesc"]; print "<p style=\"padding-bottom: 0\"><b style='color:#9F0000'>".$title."</b><br />"; print $fulldesc."</p>"; } } ?> <br /><br /> </div> <div id="cleft_bar"> <?php include ('links.php');?> </div> </div> <?php include('footer.php');?></div> </body> </html> PLEASE HELP, don't know if its the way my tables are set up or what. Quote Link to comment https://forums.phpfreaks.com/topic/147201-inserting-into-table-help/ Share on other sites More sharing options...
ricek85 Posted February 28, 2009 Share Posted February 28, 2009 Hi, Could you please post the SQL code you used to create your tables? From the looks of the code you posted, I pretty much think its an issue with the way you set up the tables. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/147201-inserting-into-table-help/#findComment-772957 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.