Jump to content

How to send data in a form


geroido

Recommended Posts

Hi

Can anyone help me with this. I'm pulling data from a database and displaying it on the webpage with a 'View menu details' submit button. There will be many hits from the database resulting in many 'view menu details' buttons. When the user clicks on any button I want to send the 'clientID, value retrieved for every record over in the form to menulist.php. Can you please tell me how to do this. The code is below:

 

 

<form id="form1" method="post" action="menulist.php">

<TABLE cellspacing="10">

<TR><TD></TD><TD><font color="black" size=4>Name</TD><TD><font color="black" size=4>Address</TD></font></font></TR>

 

<?php

 

 

$query = "select clientID, busname, strAddr1, strAddr2, towncity, county FROM clientdetails where towncity = '".$_SESSION['town']."' order by busname asc";

$results = mysql_query($query, $link) or die("Error performing query");

 

if(mysql_num_rows($results) > 0){

 

while($row = mysql_fetch_object($results)){

echo ("<tr>");

echo ("<td>");

?>

<input type="submit" name="Submit" value="View menu details">

 

<?

 

echo ("</td>");

echo ("<td>");

echo $row->busname;

echo ("</td>");

echo ("<td>");

echo $row->strAddr1 . " " . $row->strAddr2 . " " . $row->towncity . " " . $row->county;

echo ("</td>");

echo("</tr>");

}

}

else{

echo("<i>No values found</i>");

}

?>

 

 

 

 

</TR>

</TABLE></form>

 

Link to comment
https://forums.phpfreaks.com/topic/116161-how-to-send-data-in-a-form/
Share on other sites

Instead of a form use a link?

 

Like Project fear said, so you would have

 

echo "<a href='menulist.php?busname=" .$row->busname. "' />";

 

Then on menulist.php:

 

$busname = $_GET['busname'];

mysql_query("SELECT ... WHERE busname=" .mysql_real_escape_string($busname). "");

 

Possible?

 

I've adjusted my code to the following to include a href option but it's not passing the value for $row->clientID over to the menulist.php page. Can you help

 

 

<?php

 

 

$query = "select clientID, busname, strAddr1, strAddr2, towncity, county FROM clientdetails where towncity = '".$_SESSION['town']."' order by busname asc";

$results = mysql_query($query, $link) or die("Error performing query");

 

if(mysql_num_rows($results) > 0){

 

while($row = mysql_fetch_object($results)){

$id = $row->clientID;

?><form id="form1" method="post" action="menulist.php?resid=$id"><?

echo ("<tr>");

echo ("<td>");

?><a href='menulist.php?resid=" .$row->clientID. "'>View menu</a><?

echo ("</td>");

echo ("<td>");

echo $row->busname;

echo ("</td>");

echo ("<td>");

echo $row->strAddr1 . $row->strAddr2 . " " . $row->towncity . " " . $row->county . " " . $row->clientID;

echo ("</td>");

echo("</tr>");

echo("</form>");

}

}

else{

echo("<i>No values found</i>");

}

?>

 

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.