horrible problem carrying over a variable
Posted: Sun Jun 12, 2005 9:48 pm
Hi guys,
I'm working on a "shopping cart" like system for around campus and the make a long story short, people are presented with a drop down option menu for their school. The school name is there but the value for each one is a number (1, 2, 3...), the number is known as the variable $school.
So then they click "Next" after choosing their school. Only problem is, the variable wont carry over no matter what unless I make it a set variable by typing somewhere in the code: or whatever
Here's the code below for index.php with the drop down menu for the schools:
and then when you click NEXT it takes you to university.php:
This is KILLING ME. I've literally been spending hours each day trying to find out why it won't even display the variable. It's killing me! Any help or suggestions are much appreciated from the bottom of my heart! Argh! 
JCART | Please use
I'm working on a "shopping cart" like system for around campus and the make a long story short, people are presented with a drop down option menu for their school. The school name is there but the value for each one is a number (1, 2, 3...), the number is known as the variable $school.
So then they click "Next" after choosing their school. Only problem is, the variable wont carry over no matter what unless I make it a set variable by typing somewhere in the code:
Code: Select all
$school = "e;1"e;Here's the code below for index.php with the drop down menu for the schools:
Code: Select all
What school are you ordering from?<BR>
<?php
echo "e;
<FORM ACTION='university.php' METHOD=POST>
<select name='school'>
<option value='1'>Drexel University
<option value='2'>University of Pennsylvania
<option value='3'>Temple University
</select><BR><BR>
<INPUT TYPE='SUBMIT' NAME='SUBMIT' VALUE='>>Next'>
</FORM>
"e;;
$items = "e;0"e;;
?>Code: Select all
<?php
///Connection Stuff
$host = "e;localhost"e;;
$user = "e;myuser"e;;
$pass = "e;pass"e;;
$db = "e;food"e;;
$table = "e;places"e;;
mysql_connect ($host,$user,$pass) or die ( mysql_error ());
mysql_select_db ($db)or die ( mysql_error ());
$query = "e;select places.* from schools, places where places.pid = '$school' AND places.pid = schools.pid"e;;
$result = mysql_query($query)
or die(mysql_error());
?>
<table cellspacing="e;2"e; cellpadding="e;2"e;>
<tr> <td>Name</td> <td>Address</td> <td>Hours</td></tr>
<?php
while($row = mysql_fetch_array( $result )) {
echo "e;<tr><td>"e;;
echo $rowї'name'];
echo "e;</td><td>"e;;
echo $rowї'address'];
echo "e;</td><td>"e;;
echo $rowї'hours'];
echo "e;</td></tr>"e;;
}
echo "e;</table>"e;;
?>
Your school is:<?php echo "e;<b>$school</b>\n"e;; ?> (<a href="e;index.php"e;>change</a>)<BR>
Please choose from a list of stores/restaurants below:<BR>
<?php
echo "e;
<form action='store.php?school=$myschool&store=$store' method=POST>
<select name='store'>
<option value='Wawa'>Wawa</option>
<option value='CVS'>CVS</option>
<option value='McDonalds'>McDonalds</option>
<option value='7-Eleven'>7-Eleven</option>
<option value='The Fresh Grocer'>The Fresh Grocer</option>
<option value='Ben & Jerrys'>Ben & Jerrys</option>
<option value='Evans Varsity Pizza'>Evans Varsity Pizza</option>
<option value='Taco Lous'>Taco Lous Restaurante/Cart</option>
<option value='Custom'>Custom Orders</option>
</select><BR><BR>
<input type='submit' name='submit' value='>>Next'>"e;;
?>JCART | Please use
Code: Select all
tags when posting php code. Review [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color][/size]