lilwing Posted August 28, 2007 Share Posted August 28, 2007 well i have this search query, it returns results by title and a little bit of the article. each article has a number id. i want the links to take you to a page where you can edit the article. i have the edit page, but i don't know how to link to it so that you're editing the query you selected from the search. i am stumped. please help! Quote Link to comment https://forums.phpfreaks.com/topic/67109-really-need-some-help/ Share on other sites More sharing options...
Jessica Posted August 28, 2007 Share Posted August 28, 2007 make your link something like this: edit.php?id=4 Quote Link to comment https://forums.phpfreaks.com/topic/67109-really-need-some-help/#findComment-336554 Share on other sites More sharing options...
lilwing Posted August 28, 2007 Author Share Posted August 28, 2007 how would that work when the links are assigned to generated results?? Quote Link to comment https://forums.phpfreaks.com/topic/67109-really-need-some-help/#findComment-336571 Share on other sites More sharing options...
fekaduw Posted August 28, 2007 Share Posted August 28, 2007 I think you have got a page that could be used to edit the content of the retrieved info. Let's assume that the page is named as edit.php. Then on the link (that will take u to this page), specify the path as <a href="edit.php?id=4">Link</a>. Then in the edit.php page use $id=$_GET['id'] method to access the id no. Then, write a query that will retrieve the info identified by the id. It could look like. $SQL="SELECT * FROM tblSample WHERE id=".$id; Hope this will help Quote Link to comment https://forums.phpfreaks.com/topic/67109-really-need-some-help/#findComment-336586 Share on other sites More sharing options...
lilwing Posted August 28, 2007 Author Share Posted August 28, 2007 that made it a little more clear, but i don't think i described my situation well: so there is a database with 4 fields; id, updated_by, date, pagecontent. the id is autoincremented, updated_by is the person who updated it, date is the date it was last modified, and pagecontent is what is displayed on the website. the search query searches by date, with the 'LIKE' clause. it returns results, the date is the heading and it displays a little of the pagecontent. i'd like to make the heading into a link, programmed similar with the edit.php?id=4, but i would like that to be this: edit.php?id=[dependent variable that changes according to the id assigned to the row of the result that is selected] but i am not sure how to make it a dependent variable. Quote Link to comment https://forums.phpfreaks.com/topic/67109-really-need-some-help/#findComment-336600 Share on other sites More sharing options...
peterbarone Posted August 29, 2007 Share Posted August 29, 2007 Try something like this <a href=\"youreditpage.php?id=$row[id]\">$row[pagecontent]</a> Quote Link to comment https://forums.phpfreaks.com/topic/67109-really-need-some-help/#findComment-336804 Share on other sites More sharing options...
lilwing Posted August 30, 2007 Author Share Posted August 30, 2007 here is what i have, however it is not working. not sure what to do... echo '<br /><a href="editcurrent.php?id=$row[id]">Click here to edit</a>'; Quote Link to comment https://forums.phpfreaks.com/topic/67109-really-need-some-help/#findComment-337674 Share on other sites More sharing options...
Jessica Posted August 30, 2007 Share Posted August 30, 2007 echo '<br /><a href="editcurrent.php?id='.$row['id'].'">Click here to edit</a>'; Variables inside single quoted strings will not be seen as variables. Quote Link to comment https://forums.phpfreaks.com/topic/67109-really-need-some-help/#findComment-337677 Share on other sites More sharing options...
lilwing Posted August 30, 2007 Author Share Posted August 30, 2007 thanks jesi, that gave me the right idea Quote Link to comment https://forums.phpfreaks.com/topic/67109-really-need-some-help/#findComment-337683 Share on other sites More sharing options...
Jessica Posted August 30, 2007 Share Posted August 30, 2007 Good Quote Link to comment https://forums.phpfreaks.com/topic/67109-really-need-some-help/#findComment-337686 Share on other sites More sharing options...
lilwing Posted August 30, 2007 Author Share Posted August 30, 2007 ran into another problem. on the edit page, i have this: $id = $_GET['id']; $table2 = $_GET['$table']; $sql = "SELECT pagecontent FROM $table2 WHERE id = $id"; $query = mysql_query($sql); while($row = mysql_fetch_array($query)) { $current = $row['pagecontent']; echo $current; } i keep getting the error that mysql_fetch_array(); is not a valid mysql resource. i think that the problem is my WHERE argument.. Quote Link to comment https://forums.phpfreaks.com/topic/67109-really-need-some-help/#findComment-337872 Share on other sites More sharing options...
Jessica Posted August 30, 2007 Share Posted August 30, 2007 Anytime you do a query you can debug it with this: $query = mysql_query($sql) OR die('Error: '.mysql_error().' with query: '.$sql); Quote Link to comment https://forums.phpfreaks.com/topic/67109-really-need-some-help/#findComment-337908 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.