sillysillysilly Posted February 26, 2009 Share Posted February 26, 2009 I am trying to write something that based on the drop down it selects data from a db. the results I want to be a link that when clicked on will open another page that has form information its submit then inserts into the database the request. Most of it I have done. The problem is I don't know how to make the result array be a link that will pass the needed data to a page. here is a little of the necessary code. $result = mysql_query("SELECT * FROM property WHERE area = '$area'");while($row = mysql_fetch_array($result)) { echo $row['propertyid'] . " " . $row['propertyname']; echo "<br />"; } that outputs a list of results. How do I make those results links to a new page (as if it were a form submit) Link to comment https://forums.phpfreaks.com/topic/146977-solved-turning-returned-array-into-a-link-that-will-post-data-to-a-form-on-another-page/ Share on other sites More sharing options...
trq Posted February 26, 2009 Share Posted February 26, 2009 if ($result = mysql_query("SELECT * FROM property WHERE area = '$area'")) { if (mysql_num_rows($result)) { while ($row = mysql_fetch_array($result)) { echo "<a href='yourpage.php?id={$row['propertyid']}'>{$row['propertyname']}</a><br />"; } } } Link to comment https://forums.phpfreaks.com/topic/146977-solved-turning-returned-array-into-a-link-that-will-post-data-to-a-form-on-another-page/#findComment-771607 Share on other sites More sharing options...
sillysillysilly Posted February 26, 2009 Author Share Posted February 26, 2009 Thanks, I get the links to work but what I am not getting is the data to display on the next page. I think I might just be tired, or drunk, or dumb, or all of the above. Link to comment https://forums.phpfreaks.com/topic/146977-solved-turning-returned-array-into-a-link-that-will-post-data-to-a-form-on-another-page/#findComment-771626 Share on other sites More sharing options...
trq Posted February 26, 2009 Share Posted February 26, 2009 What code have you got in yourpage.php ? Link to comment https://forums.phpfreaks.com/topic/146977-solved-turning-returned-array-into-a-link-that-will-post-data-to-a-form-on-another-page/#findComment-771628 Share on other sites More sharing options...
sillysillysilly Posted February 26, 2009 Author Share Posted February 26, 2009 I have tried a couple of things, I have stripped it down to this <? echo "here is something good"; echo $_GET['propertyid']; ?> Link to comment https://forums.phpfreaks.com/topic/146977-solved-turning-returned-array-into-a-link-that-will-post-data-to-a-form-on-another-page/#findComment-771630 Share on other sites More sharing options...
trq Posted February 26, 2009 Share Posted February 26, 2009 If your using the example I posted this will display the propertyid passed to it via get. <?php echo "here is something good"; echo $_GET['id']; ?> You can then use $_GET['id'] within your query to get the data you want from the database. Link to comment https://forums.phpfreaks.com/topic/146977-solved-turning-returned-array-into-a-link-that-will-post-data-to-a-form-on-another-page/#findComment-771633 Share on other sites More sharing options...
sillysillysilly Posted February 26, 2009 Author Share Posted February 26, 2009 Thanks a lot I really appreciate it. Why is it $_GET['id'] instead of $_GET['propertyid']? Link to comment https://forums.phpfreaks.com/topic/146977-solved-turning-returned-array-into-a-link-that-will-post-data-to-a-form-on-another-page/#findComment-771635 Share on other sites More sharing options...
sillysillysilly Posted February 26, 2009 Author Share Posted February 26, 2009 I really have had a blond moment here tonight. I think I really am tired. I just answered my own question. thank you for your help. Link to comment https://forums.phpfreaks.com/topic/146977-solved-turning-returned-array-into-a-link-that-will-post-data-to-a-form-on-another-page/#findComment-771636 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.