View Full Version : use GET command not in a form
Greenmethod
07-12-2007, 03:14 PM
I have a search page that outputs a list of customers as such...
echo "<center>" . "<td>" . "<p>" . "<b>" . "<a href='edit_cust.php'>" . $row["Shop"] . "</a>" . "</b>" . "</br>" . $row["Address"] . " </br>" . $row["City"] . ", " . $row["State"] . " ";
my question is this..
the "Shop" links to edit_cust.php and i would like it to go to edit_cust.php?Shop=Shopname using the GET command but I am not sure how to "name" the link. Any suggestions?
<a href='edit_cust.php?Shop={$row['Shop']}'>" . $row["Shop"] . "</a>
something like that?
Greenmethod
07-13-2007, 08:48 AM
no, i think I have found what how I want to do it.. i can put a hidden form in it and then call it from the linked page. Does that sound like it would work?
Yes hidden form fields are very useful in including variables in requests sent via forms
Why did i got an impression he didint want to send a form?
Greenmethod
07-13-2007, 10:02 AM
I didn't want to send a form because I didn't know that you could do a hidden form and I didn't want to show the info on the page. Since I can do a hidden form, it will work great but for some reason I can't get it to work right...
Here is my code that links to the next page and has the hidden form...
function display_cust($result,$num_rows)
{
$num_rows = mysql_num_rows($result);
echo "<center>" . "<p>" . $num_rows . " customer(s) found." . "</center>";
while($row = mysql_fetch_array($result,MYSQL_BOTH))
{
echo "<center>" . "<td>" . "<p>" . "<b>" . "<a href='cust_info.php'>" . $row["Shop"] . "</a>" . "</b>" . "</br>" . $row["Address"] . " </br>" . $row["City"] . ", " . $row["State"] . " ";
if(strlen($row["Zip"]) != 5)
{
echo Zip($row["Zip"]) . "<br>" . phone_number($row["Shop_num"]) . "<p>" . "<td>" . "</center>";
}
else
{
echo $row["Zip"] . "<br>" . phone_number($row["Shop_num"]) . "<p>" . "<td>" . "</center>";
}
echo "<form method='GET'>";
echo "<input type='hidden' name='cust_no' value={$row["Cust_No"]}>";
echo "</form>";
}
}
and here is the next page...
<?php
include("index.php");
require_once('db_con.php');
$cust_no = $_GET["cust_no"];
echo "Customer Number: " . "$cust_no";
?>
Greenmethod
07-13-2007, 11:15 AM
ok... so i guess i've figured out that it isn't passing the data because there is no "submit" button, just a link. My question is.. how would I do this?
I have a page that searches for customers by the city and brings up all customers in my database with that city. I want to link the customer's name to a page, cust_info.php, that i can look at the customers information, but I don't want to have a page for every single customer.
Greenmethod
07-13-2007, 02:15 PM
did everybody go to lunch?
Horus_Kol
07-13-2007, 08:29 PM
1. you can have a link which triggers an onclick event calling a javascript function to submit the hidden form.
2. the cust_info.php can be called with the customer name or other unique identifier in the querystring (e.g., cust_info.php?name=Bob%20Terwilliger) and pulled out using the GET array (e.g., $_GET['name']) so it can then be used as part of the database query which pulls the customer info out.
3. please don't bump threads...
vBulletin® v3.6.7, Copyright ©2000-2010, Jelsoft Enterprises Ltd.