help with passing varable to next page, please!!
Posted: Mon Feb 03, 2003 5:09 pm
I am new to php, however, I am trying to make a series of pages work like this.... I have a picklist which links to a MySQL database for displaying certain results. of those results you can link to an "edit" screen where info can be updated in the database. I want to be able to return to the same selected list on the picklist when returning to the index after editing an entry. I have been trying to set a variable to session, however I am pretty sure the code used to develop the picklist cancels the variable... please help... I am including code I used for the picklist... and how I called variable...
<form method="post" action="<? echo $PHP_SELF; ?>">
<table border=0>
<tr>
<td>
<p>
<b>View Hospital:</b><br>
<select name="CatView">
<option value=0>Select
<?
// Here we generate the category picklist by running a subquery
// on a separate table and building a select widget one line at a time.
$typequery = "select * from type";
$typeresult = mysql_query($typequery) or die ( mysql_error() );
while ($row = mysql_fetch_array($typeresult, MYSQL_ASSOC))
{
$type_ID = $row["type_ID"];
$typename = $row["typename"];
echo "<option value=\"$type_ID\"";
// We also want the picklist to display the currently selected category,
// so we print "selected" when $CatView==$type_ID.
// Note the use of == rather = . This is a comparison, not an assignment!
if ($type_ID==$CatView) {
echo " selected";
}
echo ">$typename\n ";}
session_start();
session_register ("currenthosp");
$currenthosp = $CatView ;
?>
?>
<form method="post" action="<? echo $PHP_SELF; ?>">
<table border=0>
<tr>
<td>
<p>
<b>View Hospital:</b><br>
<select name="CatView">
<option value=0>Select
<?
// Here we generate the category picklist by running a subquery
// on a separate table and building a select widget one line at a time.
$typequery = "select * from type";
$typeresult = mysql_query($typequery) or die ( mysql_error() );
while ($row = mysql_fetch_array($typeresult, MYSQL_ASSOC))
{
$type_ID = $row["type_ID"];
$typename = $row["typename"];
echo "<option value=\"$type_ID\"";
// We also want the picklist to display the currently selected category,
// so we print "selected" when $CatView==$type_ID.
// Note the use of == rather = . This is a comparison, not an assignment!
if ($type_ID==$CatView) {
echo " selected";
}
echo ">$typename\n ";}
session_start();
session_register ("currenthosp");
$currenthosp = $CatView ;
?>
?>