Forum Moderators: coopster

Message Too Old, No Replies

PHP to search on query results

php search mySQL query results

         

kenkobiz

12:36 am on Apr 3, 2008 (gmt 0)

10+ Year Member



Hello Everyone!

I am new to the forum, but have been reading posts for a couple of weeks. I am the webmaster for my son's youth football league, and this year we are implementing online registration. I have it all set up and working, writing to the database with the correct information and redirecting parents to our shopping cart to pay.

I have been setting up a restricted section of the website for board members where they can search through the online registrations. I have a login page that works, a search page that works, and a result page that displays information from the database.

We collect a lot of information for each child, and what I would like to do is this: When the results come back in a table, make it where a board member could click on the child's name, and be able to view a page that displays all the information in the database for that particular row. Right now only limited information is displayed in the search results.

How is this done?

Any help you can give would be appreciated.

formasfunction

1:03 am on Apr 3, 2008 (gmt 0)

10+ Year Member



I'm not exactly sure how your site and tables are set up but the most barebones way to spit this stuff out would be to link the child's name like so:

<a href="info.php?player_id=1">John Smith</a>

And then the code for info.php would be something along the lines of:

$query = "SELECT * FROM player WHERE id = ".$_GET['player_id'];
$result = $database->query($query); //your DB call may work differently
while($array = @mysql_fetch_assoc($result)) {
foreach($array as $key=>$value){
echo $key." = ".$value."<br />";
}
}

You'll obviously want to check for login before giving out info, that sort of thing.

kenkobiz

9:52 pm on Apr 6, 2008 (gmt 0)

10+ Year Member



Thank you so much - that was exactly what I needed!