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.

Link to comment
Share on other sites

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'";

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.