How to generate a link that can pass on a variable?

Ok here is what i am trying to do!

I have a customer database and i want to make somethign that prints all the customers to the screen so that you can click on a customer and edit their information.  I know how to do this using a combo box and a form but i am looking for a more intuitive way of acomplishing this task.
LVL 2
mightofnightAsked:
Who is Participating?
 
weznmeConnect With a Mentor Commented:
$customer_id = 1; // get from database
echo '<a href="edit_customer.php?customer_id=' . $customer_id . '">' . $customer_name . '</a>';

edit_customer.php:
echo $customer_id;
0
 
mightofnightAuthor Commented:
That was so easy it’s disgusting :P

Thanks a lot dude
0
 
minichickenCommented:
Hi

This way will display all customers in a HTML table, with one customer in each row and a edit link for each of the customers under appropriate table headers. When click on the "Edit" link, you will get redirected to the edit page and the customer id will also get passed to the edit page, so the system knows which customer to edit.

DISPLAY CUSOMTER IN TABLE**********************************************
<?
//DO DATABASE CONNECTION HERE

$query = mysql_query("SELECT * FRIN customer");
?>

<TABLE WIDTH ="100%" BORDER ="1">
<TR>
<TD>Customer Name</TD>
<TD>Customer Surname</TD>
<TD>Customer Email</TD>
<TD>Edit Customer</TD>
</TR>

<?

while ($row = mysql_fetch_assoc($query))
{
      echo "<TR>";
      echo "<TD>" . $row['customer_name'] . "</TD>";
      echo "<TD>" . $row['customer_surname'] . "</TD>";
      echo "<TD>" . $row['customer_email'] . "</TD>";
      echo "<TD><a A HREF ='edit_customer.php?id=" . $row['customer_id'] . "'>Edit</TD>";
      echo "</TR>";
}
?>

</TABLE>

EDIT CUSTOMER**********************************************
<?
//on this page you will do a query with something like this:
$query = mysql_query("SELECT * FROM customer WHERE customer_id = '$_GET[id]'");
?>
0
[Webinar] Improve your customer journey

A positive customer journey is important in attracting and retaining business. To improve this experience, you can use Google Maps APIs to increase checkout conversions, boost user engagement, and optimize order fulfillment. Learn how in this webinar presented by Dito.

 
mightofnightAuthor Commented:
Thanks for the code you saved me some time... if i could i would give you some points to!

not that i need to do this right now but how do you do multiable variables?  Exp

the galleary i use on my website
http://www.mightofnight.com/wallpaper/index.php?album=1024x768%2F&pic=4K1-0.JPG

in this link it appears that there are two variables
album=1024x768%2F
pic=4K1-0.JPG
and that & is the seperator of the two variables? am i right in thinking this?
0
 
mightofnightAuthor Commented:
I know i just posted but just wanted to thank you guys again for the help, i feal like a little kid i am so excited. I was expecting to spend most of the day doing this and now i will be able to have this part of my form done in a couple of hours!
0
 
minichickenCommented:
no prob :)
0
All Courses

From novice to tech pro — start learning today.