phpwiz Posted July 28, 2009 Share Posted July 28, 2009 ok, i have a Current_news.php and a Post_news.php i will post both below just incase you need them to help me, i want to make a news archive, it stores all the past news posts and, i kinda know how to do that BUT i need to get it so when the user goes to the news, the url looks like Current_news.php?id=1 i know you are suppose to use $_GET but i have absolutely no idea how to do this, can you please explain IN DETAIL how i can make this happen, thankyou, i am posting the codes below Current_news.php <?php $connect = mysql_connect('xxxxxx', 'xxxxxx', 'xxxxxx') or die("Couldnt connect"); mysql_select_db('xxxxxx') or die("Couldn't find db"); $namecheck = mysql_query("SELECT username FROM Users"); $count = mysql_num_rows($namecheck); if ($_SESSION['username']) { //query the db $getnews = mysql_query ("SELECT * FROM News ORDER BY id DESC LIMIT 1") or die(mysql_query ()) ; while ($row = mysql_fetch_assoc ($getnews) ) { //get data $id = $row ['id'] ; $title = $row ['title'] ; $body = $row ['body'] ; $date = $row ['date'] ; $postee = $row ['postee'] ; $avatar = $row ['avatar'] ; echo "<table border='1' width='400px'>"; echo "<tr> <td bgcolor='#E7E29A' colspan='2'><div align='center'><font color='#000000'>Subject: $title</font></div></td> </tr>"; echo "<tr> <td bgcolor='#FFFFFF'><div align='center'><text align='left'><font color='#000000'><img src='$avatar'></td> <td bgcolor='#FFFFFF'><div align='center'><text align='left'><font color='#000000'><br><br><br><div class='text'>"; echo nl2br($body); echo"</div><br><br><br></font></div></td> </td> </tr> <tr> <td bgcolor='#E7E29A' colspan='2'><div align='center'><font color='#000000'>Posted On <i>$date</i></font></div></td> </tr> <tr> <td bgcolor='#E7E29A' colspan='2'><div align='center'><font color='#000000'>Posted By: <b>$postee</b></font></div></td> </tr> </table>"; echo "<br>"; echo " <table border='1' width='400px'> <tr> <td bgcolor='#E7E29A' colspan='2'><div align='center'><font color='#000000'>General Options</font></div></td> </tr> <tr> <td bgcolor='#FFFFFF' colspan='2'><div align='center'><font color='#000000'><a href='News_comments.php'>[ View Comments ]</a></font></div></td> </tr> <tr> <td bgcolor='#FFFFFF' colspan='2'><div align='center'><font color='#000000'><a href='Post_comment.php'>[ Create a comment ]</a></font></div></td> </tr> </table> <br> "; } } else die("Sorry you are not logged in <a href='login.php'> Click here</a> to login"); ?> Post_news.php <?php include("admin.php"); $connect = mysql_connect('xxxxxx', 'xxxxxx', 'xxxxxx') or die("Couldnt connect"); mysql_select_db('xxxxxx') or die("Couldn't find db"); $namecheck = mysql_query("SELECT username FROM Users"); $count = mysql_num_rows($namecheck); if ($_SESSION['username']) { if ($_POST ['post']) { //get data $title = $_POST ['title']; $body = $_POST ['body']; $date = $_POST ['date']; $postee = $_SESSION['username']; $avatar = $_POST ['avatar']; //check for existance if ($title&&$body&&$avatar) { $date = date ("Y-m-d"); //insert data $insert = mysql_query ("INSERT INTO News VALUES ('','$title','$body','$date','$postee','$avatar')") or die (mysql_error ()); echo "Your news has been posted! Go <a href='Current_news.php'>HERE</a> to view it!"; } else { echo "Please fill out title and body!<p>"; } } else { echo "<form action='Post_news.php' method='GET'>"; echo "Title:"; echo "<input type='text' name='title'><p>"; echo "Avatar link:"; echo "<input type='text' name='avatar'><p>"; echo "Body:<br>"; echo "<textarea rows='6' cols='35' name='body'></textarea><p>"; echo "<input type='submit' name='post' value='Post this news!'>"; echo "</form>"; } } else die("Sorry you are not logged in <a href='login.php'> Click here</a> to login"); ?> i also have a News_comments.php and Post_comment.php i want to delete the news comments everytime i make a new news post, but i do not want to "Erase" them i want to store them somewhere so like on my News_archive.php when i put a link to view the news and you will be able to see the comments too. Please help Quote Link to comment https://forums.phpfreaks.com/topic/167716-help-with-_get/ Share on other sites More sharing options...
slapdashwebdesigner Posted July 28, 2009 Share Posted July 28, 2009 <?php $connect = mysql_connect('xxxxxx', 'xxxxxx', 'xxxxxx') or die("Couldnt connect"); mysql_select_db('xxxxxx') or die("Couldn't find db"); $namecheck = mysql_query("SELECT username FROM Users"); $count = mysql_num_rows($namecheck); if ($_SESSION['username']) { if(isset($_GET['id'])){ //if the id is set in the url dislpay the selected id $query='"SELECT * FROM News ORDER BY id DESC LIMIT 1 WHERE id=\''.$_GET['id'].'\''; }else{ //if the id is not set in the url just display latest news $query='"SELECT * FROM News ORDER BY id DESC LIMIT 1'; } //query the db $getnews = mysql_query ($query) or die(mysql_query ()) ; while ($row = mysql_fetch_assoc ($getnews) ) { //get data $id = $row ['id'] ; $title = $row ['title'] ; $body = $row ['body'] ; $date = $row ['date'] ; $postee = $row ['postee'] ; $avatar = $row ['avatar'] ; echo "<table border='1' width='400px'>"; echo "<tr> <td bgcolor='#E7E29A' colspan='2'><div align='center'><font color='#000000'>Subject: $title</font></div></td> </tr>"; echo "<tr> <td bgcolor='#FFFFFF'><div align='center'><text align='left'><font color='#000000'><img src='$avatar'></td> <td bgcolor='#FFFFFF'><div align='center'><text align='left'><font color='#000000'><br><br><br><div class='text'>"; echo nl2br($body); echo"</div><br><br><br></font></div></td> </td> </tr> <tr> <td bgcolor='#E7E29A' colspan='2'><div align='center'><font color='#000000'>Posted On <i>$date</i></font></div></td> </tr> <tr> <td bgcolor='#E7E29A' colspan='2'><div align='center'><font color='#000000'>Posted By: <b>$postee</b></font></div></td> </tr> </table>"; echo "<br>"; echo " <table border='1' width='400px'> <tr> <td bgcolor='#E7E29A' colspan='2'><div align='center'><font color='#000000'>General Options</font></div></td> </tr> <tr> <td bgcolor='#FFFFFF' colspan='2'><div align='center'><font color='#000000'><a href='News_comments.php'>[ View Comments ]</a></font></div></td> </tr> <tr> <td bgcolor='#FFFFFF' colspan='2'><div align='center'><font color='#000000'><a href='Post_comment.php'>[ Create a comment ]</a></font></div></td> </tr> </table> <br> "; } that should do the first problem, for the comments i would have it so in the database it had a row that was newsid which told the comment what news story it was for, so the newsid would be the id number of the news story the comment is for. then on the news_comments.php have the query be <?php query='SELECT * FROM comments WHERE newsid=\''.$_GET['id'].'\''; ?> Quote Link to comment https://forums.phpfreaks.com/topic/167716-help-with-_get/#findComment-884429 Share on other sites More sharing options...
phpwiz Posted July 28, 2009 Author Share Posted July 28, 2009 Ok, well with my Current_news.php i have an error here it is: Warning: Wrong parameter count for mysql_query() in /home/www/tpnrpg.awardspace.biz/Current_news.php on line 134 here is the code: <?php $connect = mysql_connect('fdb2.awardspace.com', 'gdgsdhsgg', 'fhffhfgdj') or die("Couldnt connect"); mysql_select_db('hdfhdjdfhjj') or die("Couldn't find db"); $namecheck = mysql_query("SELECT username FROM Users"); $count = mysql_num_rows($namecheck); if ($_SESSION['username']) { if(isset($_GET['id'])){ //if the id is set in the url dislpay the selected id $query='"SELECT * FROM News ORDER BY id DESC LIMIT 1 WHERE id=\''.$_GET['id'].'\''; }else{ //if the id is not set in the url just display latest news $query='"SELECT * FROM News ORDER BY id DESC LIMIT 1'; } //query the db $getnews = mysql_query ($query) or die(mysql_query ()) ; while ($row = mysql_fetch_assoc ($getnews) ) { //get data $id = $row ['id'] ; $title = $row ['title'] ; $body = $row ['body'] ; $date = $row ['date'] ; $postee = $row ['postee'] ; $avatar = $row ['avatar'] ; echo "<table border='1' width='400px'>"; echo "<tr> <td bgcolor='#E7E29A' colspan='2'><div align='center'><font color='#000000'>Subject: $title</font></div></td> </tr>"; echo "<tr> <td bgcolor='#FFFFFF'><div align='center'><text align='left'><font color='#000000'><img src='$avatar'></td> <td bgcolor='#FFFFFF'><div align='center'><text align='left'><font color='#000000'><br><br><br><div class='text'>"; echo nl2br($body); echo"</div><br><br><br></font></div></td> </td> </tr> <tr> <td bgcolor='#E7E29A' colspan='2'><div align='center'><font color='#000000'>Posted On <i>$date</i></font></div></td> </tr> <tr> <td bgcolor='#E7E29A' colspan='2'><div align='center'><font color='#000000'>Posted By: <b>$postee</b></font></div></td> </tr> </table>"; echo "<br>"; echo " <table border='1' width='400px'> <tr> <td bgcolor='#E7E29A' colspan='2'><div align='center'><font color='#000000'>General Options</font></div></td> </tr> <tr> <td bgcolor='#FFFFFF' colspan='2'><div align='center'><font color='#000000'><a href='News_comments.php'>[ View Comments ]</a></font></div></td> </tr> <tr> <td bgcolor='#FFFFFF' colspan='2'><div align='center'><font color='#000000'><a href='Post_comment.php'>[ Create a comment ]</a></font></div></td> </tr> </table> <br> "; } } else die("Sorry you are not logged in <a href='login.php'> Click here</a> to login"); ?> Please help thanks Quote Link to comment https://forums.phpfreaks.com/topic/167716-help-with-_get/#findComment-884434 Share on other sites More sharing options...
.josh Posted July 28, 2009 Share Posted July 28, 2009 $getnews = mysql_query ($query) or die(mysql_query ()) ; You are passing mysql_query in the die. I believe you meant to do mysql_error(). Quote Link to comment https://forums.phpfreaks.com/topic/167716-help-with-_get/#findComment-884436 Share on other sites More sharing options...
phpwiz Posted July 28, 2009 Author Share Posted July 28, 2009 Grrrr Um that what you told me to do worked xD lol but i have ANOTHER error here it is You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"SELECT * FROM News ORDER BY id DESC LIMIT 1' at line 1 Quote Link to comment https://forums.phpfreaks.com/topic/167716-help-with-_get/#findComment-884439 Share on other sites More sharing options...
Bendude14 Posted July 28, 2009 Share Posted July 28, 2009 you shouldn't use $_GET variables straight into your query and there is no need for numeric values to be in quotes... $id = mysql_real_escape_string($_GET['id']); $query='SELECT * FROM comments WHERE newsid=' . $id; you could also just check to make sure the ID was numeric, presuming it can only every contain numbers. Quote Link to comment https://forums.phpfreaks.com/topic/167716-help-with-_get/#findComment-884440 Share on other sites More sharing options...
Bendude14 Posted July 28, 2009 Share Posted July 28, 2009 you had an extra double quote in this line $query='SELECT * FROM News ORDER BY id DESC LIMIT 1'; Quote Link to comment https://forums.phpfreaks.com/topic/167716-help-with-_get/#findComment-884443 Share on other sites More sharing options...
phpwiz Posted July 28, 2009 Author Share Posted July 28, 2009 Ok, another error on my site here http://tpnrpg.awardspace.biz/Current_news.php?id=1 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"SELECT * FROM News ORDER BY id DESC LIMIT 1 WHERE id='1'' at line 1 ------------------------------------------------------------ Ok, so i dont have to post another message, On my Navigation bar how do i make it , do it dosent go to Current_news.php, i want it to go to the current news Quote Link to comment https://forums.phpfreaks.com/topic/167716-help-with-_get/#findComment-884450 Share on other sites More sharing options...
Bendude14 Posted July 28, 2009 Share Posted July 28, 2009 $query='SELECT * FROM News ORDER BY id DESC LIMIT 1 WHERE id=' . $_GET['id']; Quote Link to comment https://forums.phpfreaks.com/topic/167716-help-with-_get/#findComment-884452 Share on other sites More sharing options...
phpwiz Posted July 28, 2009 Author Share Posted July 28, 2009 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE id=6' at line 1 another error Quote Link to comment https://forums.phpfreaks.com/topic/167716-help-with-_get/#findComment-884455 Share on other sites More sharing options...
slapdashwebdesigner Posted July 28, 2009 Share Posted July 28, 2009 post your complete code again so i can see what you have on your end. it should look like this <?php $connect = mysql_connect('xxxxxx', 'xxxxxx', 'xxxxxx') or die("Couldnt connect"); mysql_select_db('xxxxxx') or die("Couldn't find db"); $namecheck = mysql_query("SELECT username FROM Users"); $count = mysql_num_rows($namecheck); if ($_SESSION['username']) { if(isset($_GET['id'])){ $id = mysql_real_escape_string($_GET['id']); //if the id is set in the url dislpay the selected id $query='SELECT * FROM News ORDER BY id DESC LIMIT 1 WHERE id='.$id; }else{ //if the id is not set in the url just display latest news $query='"SELECT * FROM News ORDER BY id DESC LIMIT 1'; } //query the db $getnews = mysql_query ($query) or die(mysql_error ()) ; while ($row = mysql_fetch_assoc ($getnews) ) { //get data $id = $row ['id'] ; $title = $row ['title'] ; $body = $row ['body'] ; $date = $row ['date'] ; $postee = $row ['postee'] ; $avatar = $row ['avatar'] ; echo "<table border='1' width='400px'>"; echo "<tr> <td bgcolor='#E7E29A' colspan='2'><div align='center'><font color='#000000'>Subject: $title</font></div></td> </tr>"; echo "<tr> <td bgcolor='#FFFFFF'><div align='center'><text align='left'><font color='#000000'><img src='$avatar'></td> <td bgcolor='#FFFFFF'><div align='center'><text align='left'><font color='#000000'><br><br><br><div class='text'>"; echo nl2br($body); echo"</div><br><br><br></font></div></td> </td> </tr> <tr> <td bgcolor='#E7E29A' colspan='2'><div align='center'><font color='#000000'>Posted On <i>$date</i></font></div></td> </tr> <tr> <td bgcolor='#E7E29A' colspan='2'><div align='center'><font color='#000000'>Posted By: <b>$postee</b></font></div></td> </tr> </table>"; echo "<br>"; echo " <table border='1' width='400px'> <tr> <td bgcolor='#E7E29A' colspan='2'><div align='center'><font color='#000000'>General Options</font></div></td> </tr> <tr> <td bgcolor='#FFFFFF' colspan='2'><div align='center'><font color='#000000'><a href='News_comments.php'>[ View Comments ]</a></font></div></td> </tr> <tr> <td bgcolor='#FFFFFF' colspan='2'><div align='center'><font color='#000000'><a href='Post_comment.php'>[ Create a comment ]</a></font></div></td> </tr> </table> <br> "; } Quote Link to comment https://forums.phpfreaks.com/topic/167716-help-with-_get/#findComment-884464 Share on other sites More sharing options...
phpwiz Posted July 28, 2009 Author Share Posted July 28, 2009 post your complete code again so i can see what you have on your end. it should look like this <?php $connect = mysql_connect('xxxxxx', 'xxxxxx', 'xxxxxx') or die("Couldnt connect"); mysql_select_db('xxxxxx') or die("Couldn't find db"); $namecheck = mysql_query("SELECT username FROM Users"); $count = mysql_num_rows($namecheck); if ($_SESSION['username']) { if(isset($_GET['id'])){ $id = mysql_real_escape_string($_GET['id']); //if the id is set in the url dislpay the selected id $query='SELECT * FROM News ORDER BY id DESC LIMIT 1 WHERE id='.$id; }else{ //if the id is not set in the url just display latest news $query='"SELECT * FROM News ORDER BY id DESC LIMIT 1'; } //query the db $getnews = mysql_query ($query) or die(mysql_error ()) ; while ($row = mysql_fetch_assoc ($getnews) ) { //get data $id = $row ['id'] ; $title = $row ['title'] ; $body = $row ['body'] ; $date = $row ['date'] ; $postee = $row ['postee'] ; $avatar = $row ['avatar'] ; echo "<table border='1' width='400px'>"; echo "<tr> <td bgcolor='#E7E29A' colspan='2'><div align='center'><font color='#000000'>Subject: $title</font></div></td> </tr>"; echo "<tr> <td bgcolor='#FFFFFF'><div align='center'><text align='left'><font color='#000000'><img src='$avatar'></td> <td bgcolor='#FFFFFF'><div align='center'><text align='left'><font color='#000000'><br><br><br><div class='text'>"; echo nl2br($body); echo"</div><br><br><br></font></div></td> </td> </tr> <tr> <td bgcolor='#E7E29A' colspan='2'><div align='center'><font color='#000000'>Posted On <i>$date</i></font></div></td> </tr> <tr> <td bgcolor='#E7E29A' colspan='2'><div align='center'><font color='#000000'>Posted By: <b>$postee</b></font></div></td> </tr> </table>"; echo "<br>"; echo " <table border='1' width='400px'> <tr> <td bgcolor='#E7E29A' colspan='2'><div align='center'><font color='#000000'>General Options</font></div></td> </tr> <tr> <td bgcolor='#FFFFFF' colspan='2'><div align='center'><font color='#000000'><a href='News_comments.php'>[ View Comments ]</a></font></div></td> </tr> <tr> <td bgcolor='#FFFFFF' colspan='2'><div align='center'><font color='#000000'><a href='Post_comment.php'>[ Create a comment ]</a></font></div></td> </tr> </table> <br> "; } here it is <?php $connect = mysql_connect('fdb2.awardspace.com', '', '') or die("Couldnt connect"); mysql_select_db('') or die("Couldn't find db"); $namecheck = mysql_query("SELECT username FROM Users"); $count = mysql_num_rows($namecheck); if ($_SESSION['username']) { if(isset($_GET['id'])){ //if the id is set in the url dislpay the selected id $query='SELECT * FROM News ORDER BY id DESC LIMIT 1 WHERE id=' . $_GET['id']; }else{ //if the id is not set in the url just display latest news $query='SELECT * FROM News ORDER BY id DESC LIMIT 1'; } //query the db $getnews = mysql_query ($query) or die(mysql_error()) ; while ($row = mysql_fetch_assoc ($getnews) ) { //get data $id = $row ['id'] ; $title = $row ['title'] ; $body = $row ['body'] ; $date = $row ['date'] ; $postee = $row ['postee'] ; $avatar = $row ['avatar'] ; echo "<table border='1' width='400px'>"; echo "<tr> <td bgcolor='#E7E29A' colspan='2'><div align='center'><font color='#000000'>Subject: $title</font></div></td> </tr>"; echo "<tr> <td bgcolor='#FFFFFF'><div align='center'><text align='left'><font color='#000000'><img src='$avatar'></td> <td bgcolor='#FFFFFF'><div align='center'><text align='left'><font color='#000000'><br><br><br><div class='text'>"; echo nl2br($body); echo"</div><br><br><br></font></div></td> </td> </tr> <tr> <td bgcolor='#E7E29A' colspan='2'><div align='center'><font color='#000000'>Posted On <i>$date</i></font></div></td> </tr> <tr> <td bgcolor='#E7E29A' colspan='2'><div align='center'><font color='#000000'>Posted By: <b>$postee</b></font></div></td> </tr> </table>"; echo "<br>"; echo " <table border='1' width='400px'> <tr> <td bgcolor='#E7E29A' colspan='2'><div align='center'><font color='#000000'>General Options</font></div></td> </tr> <tr> <td bgcolor='#FFFFFF' colspan='2'><div align='center'><font color='#000000'><a href='News_comments.php'>[ View Comments ]</a></font></div></td> </tr> <tr> <td bgcolor='#FFFFFF' colspan='2'><div align='center'><font color='#000000'><a href='Post_comment.php'>[ Create a comment ]</a></font></div></td> </tr> </table> <br> "; } } else die("Sorry you are not logged in <a href='login.php'> Click here</a> to login"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/167716-help-with-_get/#findComment-884465 Share on other sites More sharing options...
slapdashwebdesigner Posted July 28, 2009 Share Posted July 28, 2009 well you forgot 2 things that i can see, the string $id = mysql_real_escape_string($_GET['id']); (this means you have to change the query from $_GET['id'] to $id) and a } at the end both which i added in to this version <?php $connect = mysql_connect('fdb2.awardspace.com', '', '') or die("Couldnt connect"); mysql_select_db('') or die("Couldn't find db"); $namecheck = mysql_query("SELECT username FROM Users"); $count = mysql_num_rows($namecheck); if ($_SESSION['username']) { if(isset($_GET['id'])){ //if the id is set in the url dislpay the selected id $id = mysql_real_escape_string($_GET['id']); $query='SELECT * FROM News ORDER BY id DESC LIMIT 1 WHERE id=' . $id; }else{ //if the id is not set in the url just display latest news $query='SELECT * FROM News ORDER BY id DESC LIMIT 1'; } //query the db $getnews = mysql_query ($query) or die(mysql_error()) ; while ($row = mysql_fetch_assoc ($getnews) ) { //get data $id = $row ['id'] ; $title = $row ['title'] ; $body = $row ['body'] ; $date = $row ['date'] ; $postee = $row ['postee'] ; $avatar = $row ['avatar'] ; echo "<table border='1' width='400px'>"; echo "<tr> <td bgcolor='#E7E29A' colspan='2'><div align='center'><font color='#000000'>Subject: $title</font></div></td> </tr>"; echo "<tr> <td bgcolor='#FFFFFF'><div align='center'><text align='left'><font color='#000000'><img src='$avatar'></td> <td bgcolor='#FFFFFF'><div align='center'><text align='left'><font color='#000000'><br><br><br><div class='text'>"; echo nl2br($body); echo"</div><br><br><br></font></div></td> </td> </tr> <tr> <td bgcolor='#E7E29A' colspan='2'><div align='center'><font color='#000000'>Posted On <i>$date</i></font></div></td> </tr> <tr> <td bgcolor='#E7E29A' colspan='2'><div align='center'><font color='#000000'>Posted By: <b>$postee</b></font></div></td> </tr> </table>"; echo "<br>"; echo " <table border='1' width='400px'> <tr> <td bgcolor='#E7E29A' colspan='2'><div align='center'><font color='#000000'>General Options</font></div></td> </tr> <tr> <td bgcolor='#FFFFFF' colspan='2'><div align='center'><font color='#000000'><a href='News_comments.php'>[ View Comments ]</a></font></div></td> </tr> <tr> <td bgcolor='#FFFFFF' colspan='2'><div align='center'><font color='#000000'><a href='Post_comment.php'>[ Create a comment ]</a></font></div></td> </tr> </table> <br> "; } } else die("Sorry you are not logged in <a href='login.php'> Click here</a> to login"); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/167716-help-with-_get/#findComment-884468 Share on other sites More sharing options...
.josh Posted July 28, 2009 Share Posted July 28, 2009 You need to step back and take the time to learn proper code syntax. Really, it's not that hard. Once you learn it, you will be able to understand what the error messages are telling you and fix them yourself easy enough. There is no reason for something like this to be a constant crutch for you. Quote Link to comment https://forums.phpfreaks.com/topic/167716-help-with-_get/#findComment-884469 Share on other sites More sharing options...
Bendude14 Posted July 28, 2009 Share Posted July 28, 2009 CV is right about learning the code, this should fix your current error though change $query='SELECT * FROM News ORDER BY id DESC LIMIT 1 WHERE id=' . $id; to $query='SELECT * FROM News WHERE id= ' . $id . ' ORDER BY id DESC LIMIT 1'; Quote Link to comment https://forums.phpfreaks.com/topic/167716-help-with-_get/#findComment-884475 Share on other sites More sharing options...
slapdashwebdesigner Posted July 28, 2009 Share Posted July 28, 2009 CV is right about learning the code, this should fix your current error though change $query='SELECT * FROM News ORDER BY id DESC LIMIT 1 WHERE id=' . $id; to $query='SELECT * FROM News WHERE id= ' . $id . ' ORDER BY id DESC LIMIT 1'; that was my fault, i wrote that too quickly. the where clause must come after the from and before order and limit Quote Link to comment https://forums.phpfreaks.com/topic/167716-help-with-_get/#findComment-884481 Share on other sites More sharing options...
phpwiz Posted July 28, 2009 Author Share Posted July 28, 2009 Ok, in my nav bar i want it to go to the most current news like it only goes to Current_news.php i want it to go Current_news.php?id= most current Quote Link to comment https://forums.phpfreaks.com/topic/167716-help-with-_get/#findComment-884485 Share on other sites More sharing options...
slapdashwebdesigner Posted July 28, 2009 Share Posted July 28, 2009 Ok, in my nav bar i want it to go to the most current news like it only goes to Current_news.php i want it to go Current_news.php?id= most current just leave of the appended ?id= clause and the script uses the most current one. this code section here checks to see if the id is set in the url, if it is the code uses that id in the query, if it is not set it just uses the most current like you had before if(isset($_GET['id'])){ //if the id is set in the url dislpay the selected id $id = mysql_real_escape_string($_GET['id']); $query='SELECT * FROM News ORDER BY id DESC LIMIT 1 WHERE id=' . $id; }else{ //if the id is not set in the url just display latest news $query='SELECT * FROM News ORDER BY id DESC LIMIT 1'; } i believe that is what you are asking Quote Link to comment https://forums.phpfreaks.com/topic/167716-help-with-_get/#findComment-884492 Share on other sites More sharing options...
phpwiz Posted July 28, 2009 Author Share Posted July 28, 2009 Ok, again i have no idea what that means xD can u please keep it simple since i just started coding aboout 1 month ago. Ok i thought that over and i fixed another error but when i dont do the ?id= it is still Current_news.php i want the url to look like Current_news.php?id= most current Quote Link to comment https://forums.phpfreaks.com/topic/167716-help-with-_get/#findComment-884495 Share on other sites More sharing options...
phpwiz Posted July 28, 2009 Author Share Posted July 28, 2009 Can anyone help me with this o_O? Quote Link to comment https://forums.phpfreaks.com/topic/167716-help-with-_get/#findComment-884518 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.