Jump to content

Lost Variable


brax23

Recommended Posts

I have some code that I'm using to produce a drop down menu that is populated by a database table.  When I pick one of the drop down items it directs me to the next page.  The drop down menu is working.  I'm trying to pass a variable (which is the value picked in the drop down) to the next page so I can simply echo the value on the page.  It seems that I've tried echoing every variable I can think of but I can't get the value/variable to pass from one page to the next.  The items I'm trying to echo on the next page are the 'ProjectNumber' and 'ProjectName' values that are in the drop down menu.  Any suggestions please?  Here's the code:

echo "<h1 align='center'>SELECT PROJECT</h1>";
$members_list = "<select name='name' onChange='this.form.submit();'>";
$members_list .= "<option selected></option>";
$query_members = "SELECT ProjectNumber,ProjectName FROM projects ORDER BY ProjectNumber";
$result_members = mysql_query($query_members) or die("QUERY MEMBERS FAILED: ".mysql_error());
while ($line = mysql_fetch_array($result_members)) {
$itemnumber = $line['ProjectNumber'];
$description = $line['ProjectName'];
$members_list .= "<option value='$itemnumber'>$itemnumber ".ucwords($description)."</option>";
}

$members_list .= "</select>";

echo "<form method='get' action='Time_3.php'>";
echo "<table border='0' width='50%' cellspacing='0' cellpadding='8'>";
echo "	<tr>";
echo "		<td><table border='0' width='100%' cellspacing='0'>";
echo "			<tr>";
echo "				<td width='5%'> </td>";

echo "			</tr>";
echo "			<tr>";
echo "				<td width='5%'> </td>";
echo "				<td width='95%'> </td>";
echo "			</tr>";
echo "			<tr>";
echo "				<td colspan='2'><table border='0' width='100%'>";
echo "					<tr>";
echo "						<td  align='right' >Project: </td>";
echo "						<td>$members_list</td>";
echo "					</tr>";
echo "				</table></td>";
echo "			</tr>";
echo "		</table></td>";
echo "	</tr>";
echo "</table>";
echo "</form>";

?>
</div>
</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/118801-lost-variable/
Share on other sites

in your Time_3.php

<?php

echo $_GET['name'];

?>

 

for debugging form issues, place this at the top of your code (on the processing page):

 

<? 
echo "<hr><pre>";
echo "GET:\n";
print_r($_GET);
echo "\nPOST:\n";
print_r($_POST);
echo "</pre><hr>";
?>

 

to see all form data being passed

 

Link to comment
https://forums.phpfreaks.com/topic/118801-lost-variable/#findComment-611715
Share on other sites

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.