Search code examples
phphtmlmysqlhref

How to submit parameters by hyperlink-url and retrieve them in php?


Carrying values in a while cycle, each value is extracted from a SQL table, and I need to carry em in a since I'm making a list of items purchased from a specific client. I'm using this line for the href url:

    echo "<table width=1200 style align=left>";
while($row3 = mysqli_fetch_array($rs3)){
$space = array("");
$text=$row3['description'];
$dash="_";
$url = preg_replace("![^a-z0-9]+!i", "_", $text);
$url= "".$url.".php";

echo "<tr><td colspan=2 style align=center><span class=font>" . $row3['relid'] . "</span></td><td width=132 style align=center><span class=font>" . $row3['invoiceid'] . "</span></td><td width=400 style align=center <span class=font><a href=$url>" . $row3['description'] . "</span></A></td><td width=132 style align=right><span class=font>" . $row3['amount'] . "</span></td><td width=132 style align=center><span class=font>Pendiente</span></td><td width=132 style align=left><span class=font>" . $row3['duedate'] . "</span></td></tr>";
}
mysqli_close($con3);
echo "</table>";
echo"<table width=1200>";
echo "  <tr class=font>
<td width=1200 height=22 colspan=7  background=border-green-horizontal.png>&nbsp;</td>

";

I'm generating the url from the Description I extract from the database but I need to carry the Order ID, Client ID, etc from the specific row. Each variable is needs to be carried to a form where the user will fill some fields regarding the product the client bought (Medical Test Results), and I need those variables to mark as "Done" so It won't show up again on the list.


Solution

  • Fix these syntax errors, report back if still broken.

    <td width=400 style align=center <span class=font><a href=$url>" . $row3['description'] . "</span></a></td>
    

    -->

    "<td width=400 style align='center'><span class='font'><a href='$url'>" . $row3['description'] . "</span></a></td>"
    

    EDIT:

    Do you mean how to append a var to an url, so it can be retrived on the called page? You can append the var to the url by echo "<a href='{$url}?id={$var}'>.

    On the called page, you can read it by $_GET['id']