Saturday, 10 January 2015

Submit a form with PHP using a href link – php MySql

If you are trying to submit information from a database using a link here is a method I used in a project recently.  This may or may not be the answer to your needs but give it a go.  Just so you know it is manipulating the url like using the $_GET global.

<?php
  $query = "SELECT id, name FROM folder WHERE parent=0";
 $result = mysql_query ($query);
 while ($row = mysql_fetch_array ($result, MYSQL_ASSOC)) {
  echo ( "<li><a href="/sportpix/view_gallery.php?type=".($row['id'])."" > ". ($row['name']) ." </a></li>");
 
 }//end while loop
?>

Here is a little explanation of the code.
It goes without saying that you need to connect to your database. You can read about thishere.
We are connecting to the database and selecting the table and columns that we need.

1
2
 $query = "SELECT id, name FROM Table1 WHERE parent=0";
 $result = mysql_query ($query);

echo ( "<li><a href="/sportpix/view_gallery.php?type=".($row['id'])."" > ". ($row['name']) ." </a></li>");

No comments:

Post a Comment