Current location: Hot Scripts Forums » Programming Languages » PHP » display data based on form submission


display data based on form submission

Reply
  #1 (permalink)  
Old 02-09-06, 07:29 PM
panqueconpasas panqueconpasas is offline
New Member
 
Join Date: Feb 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
display data based on form submission

I am pretty new to this (PHP & mySQL). I tried looking all over the hotscripts site but wasn't quite sure what i was looking for would be called. I need to display data from a mySQL table (dynamically?) on a website based on drop down boxes in a form. Does anyone know where i might find such a script?

for example: if i had a table with fields "name", "city", "date", and "site_name", and wanted to have drop down boxes for city and date, on submission of the form, a table would show the matching records.

I saw a few PHP scripts on this site, but they all had options to edit or add/delete records... all i want is to display them based on the form input. i know it is probably simple, but i am more of a code "borrower and modifier" than a code "author." Thank you for any help!!!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 02-10-06, 04:43 AM
FiRe FiRe is offline
Code Guru
 
Join Date: Oct 2004
Location: UK
Posts: 801
Thanks: 0
Thanked 0 Times in 0 Posts
drop down boxes:
Code:
<form action="submit.php" method="post">
City: <select name="city"><option value="london">london</option><option value="paris">paris</option><option value="hamburg">hamburg</option></select>
Date: <select name="date"><option value="01/01/06">01/01/06</option><option value="02/01/06">02/01/06</option><option value="03/01/06">03/01/06</option></select>
<input type="submit" value="Submit">
</form>
Now in submit.php:
PHP Code:

// Get the city

$city $_POST['city'];

// Get the date
$date $_POST['date'];

// Form the query
$query "SELECT * FROM table WHERE city='$city' AND date='$date'";
$query mysql_query($query);

// Start looping through each result
while ($r mysql_fetch_array($query)) {

// Set the other information into variables
$name $r['name'];
$site_name $r['site_name'];

// Output the results (name and site name)
echo "Name: $name - Site Name: $site_name <br />";

__________________
Alexa Share <-- Trade virtual shares in websites with this online game.

codR.us <-- Submit and vote for your favorite code snippets with codR.us.

XEWeb.net <-- The ultimate PHP resource network.

Last edited by FiRe; 02-10-06 at 04:51 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 02-10-06, 04:51 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,074
Thanks: 11
Thanked 88 Times in 83 Posts
You forgot an "r" here:

PHP Code:

$site_name $r['site_name']; 

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 02-10-06, 04:52 AM
FiRe FiRe is offline
Code Guru
 
Join Date: Oct 2004
Location: UK
Posts: 801
Thanks: 0
Thanked 0 Times in 0 Posts
my bad :-p
__________________
Alexa Share <-- Trade virtual shares in websites with this online game.

codR.us <-- Submit and vote for your favorite code snippets with codR.us.

XEWeb.net <-- The ultimate PHP resource network.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 02-27-06, 10:19 PM
panqueconpasas panqueconpasas is offline
New Member
 
Join Date: Feb 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
thanks... i will try it out as soon as i finish my midterms...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Php Form + mysql + display data sent needed TheRaider Script Requests 3 10-07-04 02:30 AM
Limit the form submission according to time bionicsamir PHP 7 05-10-04 12:10 AM
Declared Functions skipper23 PHP 4 12-17-03 11:06 AM
index page not showing up skipper23 PHP 3 12-15-03 02:10 PM


All times are GMT -5. The time now is 01:53 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.