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?
 
weznmeCommented:
$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
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.