Jump to content

[SOLVED] turning returned array into a link that will post data to a form on another page


sillysillysilly

Recommended Posts

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)

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 />";
    }
  }
}

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.