Jump to content

[SOLVED] pass variable to page prior to populating data from the DB


CurrierSites

Recommended Posts

I have a query page which displays the contents of a table

 

name, age, sport

---------------------

bob, 30, baseball

jim, 34, football

steve, 23, hockey

 

I want to be able to edit these entries by passing the name of an individual to a new page where where I can edit that individuals information.

 

My goal is to pass the name of one person as a variable that will be used by the next page to query the DB and display the fields to be edited.

 

Im not quite sure to get that variable passed to the next page so it can be used in query (i.e. select * from DATABASE where name='PASSED VARIABLE'

 

I would appreciate any suggestions on this problem.

You can do it through the URL using GET.

 

So your URL to the page should look something like this

www.yourdomain.com/page.php?name=steve

 

Then on that page, you could retrieve the information and do your query like so

 

<?php

$name = mysql_real_escape_string($_GET['name']);
$query = "SELECT* FROM table WHERE name='$name'";

?>

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.