Nikos7 Posted July 10, 2007 Share Posted July 10, 2007 i have 2 forms that communicate each other. the 1st has a drop down list with the categories and the 2nd form has another drop down list that i want to take values depends on the selection at the first drop down list. i have created this with get method. the data that the drop down lists have are in 2 different tables in mysql server. i want retrieve data and update them with new but when i change the selection at the first drop down list all data at the second form are gone. what i can do to keep data in position? i attach you the code if you dont understand somethng. ps: plz help me cuz i must give this site for my lab exams at uni <? require ("scripts/admin_auth.php"); require ("scripts/db_connection.php"); $query_bathmida='SELECT * FROM 32495_bathmida ORDER BY bathmida ASC'; $query_sxoli='SELECT * FROM 32495_sxoli'; if(isset($_GET['sxoli'])){ $query_tmima='SELECT * FROM 32495_tmima where sid="'.$_GET['sxoli'].'" ORDER BY tmima ASC'; // $query='SELECT * FROM 32495_contacts WHERE cid="'.$_GET["cid"].'"'; }else{ $query_tmima='SELECT * FROM 32495_tmima ORDER BY tmima ASC'; // $query='SELECT * FROM 32495_contacts WHERE cid="'.$_GET["cid"].'"'; } $result_bathmida=mysql_query($query_bathmida); $result_sxoli=mysql_query($query_sxoli); $result_tmima=mysql_query($query_tmima); $query='SELECT * FROM 32495_contacts WHERE cid="'.$_GET["cid"].'"'; $result=mysql_query($query); $row=mysql_fetch_assoc($result); /* $query_bathmida='SELECT * FROM 32495_bathmida'; $query_sxoli='SELECT * FROM 32495_sxoli'; $query_tmima='SELECT * FROM 32495_tmima'; $result_bathmida=mysql_query($query_bathmida); $result_sxoli=mysql_query($query_sxoli); $result_tmima=mysql_query($query_tmima);*/ ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1253" /> <title>ΥΠΗΡΕΣΙΑ ΚΑΤΑΛΟΓΟΥ</title> <link rel="stylesheet" type="text/css" href="css/base.css" /> <link rel="stylesheet" type="text/css" href="css/menu.css" /> <link rel="stylesheet" type="text/css" href="css/forms.css" /> <script type="text/javascript"> function ValidateForm() { if ((document.addcontact.onoma.value.length < 1)|| (document.addcontact.eponumo.value.length < 1)|| (document.addcontact.bathmida.value.length < 1)|| (document.addcontact.sxoli.value.length < 1)|| (document.addcontact.tmima.value.length < 1)|| (document.addcontact.tilefono.value.length < 1)) { alert("ΠΡΟΣΟΧΗ!\n\nΣυμπληρώστε όλα τα απαραίτητα πεδία."); return false; } return true; } function TilCk() { if (document.addcontact.tilefono.value.length <10) { alert("Δώστε σωστό τηλέφωνο"); return false; } return true; } </script> </head> <body> <table class="tb" cellspacing="0"> <tr> <td colspan="2"><? include "header.php" ?></td> </tr> <tr> <td width="30%"><table cellspacing="0" class="menu"> <tr> <td class="td"><img src="photos/til.JPG" class="img" /></td> </tr> <tr> <td class="td"><a href="scripts/test.php"/>Αρχική Σελίδα</td> </tr> <tr> <td class="td"><a href=""/>Αναζήτηση</td> </tr> <tr> <td class="td"><a href="addmenu.php"/>Προσθήκη</td> </tr> <tr> <td class="sub_menu">Επεξεργασία</td> </tr> <tr> <td class="sub_menu1"><a href="editcontact.php"/><span class="style3"/>Επεξεργασία επαφής</td> </tr> <tr> <td class="sub_menu1"><a href="editadmin.php"/><span class="style3"/>Επεξεργασία διαχειριστή</td> </tr> <tr> <td class="td"><a href="scripts/logout.php"/>Αποσύνδεση</td> </tr> </table></td> <td width="68%"> <form name="sxoli" method="get" action="<?=$_SERVER['PHP_SELF']?>"> <table border="0" cellpadding="1" cellspacing="1" class="center_tb1"> <tr> <td width="107">Σχολή</td> <td width="192"> <select name="sxoli" onchange="document.sxoli.submit();"> <!-- <option value="">Επιλέξτε ένα</option>--> <? while($row_sxoli=mysql_fetch_assoc($result_sxoli)) {?> <option <? if ($row_sxoli['sid']==$_GET['sxoli']) echo 'selected="selected"';?> value="<?=$row_sxoli['sid']?>"><?=$row_sxoli["sxoli"]?></option> <? } ?> </select> </td> <td width="16"><img src="photos/required_field.gif" width="8" height="9" /></td> </tr> </table> </form> <form id="editcontact" name="editcontact" method="post" action="upcon.php" onsubmit="return(ValidateForm() && TilCk());"> <table border="0" cellpadding="1" cellspacing="1" class="center_tb1" > <tr> <td width="112">Όνομα</td> <td width="192"><input type="text" name="onoma" value="<?=$row['onoma'] ?>" /></td> <td width="16"><img src="photos/required_field.gif" width="8" height="9" /></td> </tr> <tr> <td>Επώνυμο</td> <td><input type="text" name="eponumo" value="<?=$row['eponumo'] ?>" /></td> <td><img src="photos/required_field.gif" width="8" height="9" /></td> </tr> <tr> <td>Βαθμίδα</td> <td><select name="bathmida"> <? while($row_bathmida=mysql_fetch_assoc($result_bathmida)) {?> <option <? if ($row_bathmida['bid']==$row['bathmida']) echo 'selected="selected"';?> value="<?=$row_bathmida['bid']?>"><?=$row_bathmida["bathmida"]?></option> <? } ?> </select></td> <td><img src="photos/required_field.gif" width="8" height="9" /></td> </tr> <tr> <td>Τμήμα</td> <td><select name="tmima"> <? while($row_tmima=mysql_fetch_assoc($result_tmima)) {?> <option <? if ($row_tmima['tid']==$row['tmima']) echo 'selected="selected"';?> value="<?=$row_tmima['tid']?>"><?=$row_tmima["tmima"]?></option> <? } ?> </select></td> <td><img src="photos/required_field.gif" width="8" height="9" /></td> </tr> <tr> <td>e-mail</td> <td><input type="text" name="email" value="<?=$row['email'] ?>" /></td> <td> </td> </tr> <tr> <td>Τηλέφωνο</td> <td><input type="text" name="tilefono" value="<?=$row['tilefono'] ?>"/></td> <td><img src="photos/required_field.gif" width="8" height="9" /></td> </tr> <tr> <td>Fax</td> <td><input type="text" name="fax" value="<?=$row['fax'] ?>" /></td> <td> </td> </tr> <tr> <td>Αίθουσα</td> <td><input type="text" name="aithousa" value="<?=$row['aithousa'] ?>" /></td> <td> </td> </tr> <tr> <td>Ιστοσελίδα</td> <td><input type="text" name="web" value="<?=$row['web'] ?>" /></td> <td> </td> </tr> <tr> <td colspan="2" align="center"><input type="submit" name="Submit" value="Ενημέρωση" /></td> </tr> <input type="hidden" name="cid" value="<?=$_GET['cid']?>" /> <input type="hidden" name="sxoli" value="<?=$_GET['sxoli'] ?>" /> </table> </form> </td> </tr> <tr> <td colspan="2"><? include "footer.php" ?></td> </tr> </table> </body> </html> Quote Link to comment Share on other sites More sharing options...
Nikos7 Posted July 10, 2007 Author Share Posted July 10, 2007 noone?!? Quote Link to comment Share on other sites More sharing options...
Nikos7 Posted July 11, 2007 Author Share Posted July 11, 2007 i give you only the necessary code cause the code above is to big to be read <? require ("scripts/admin_auth.php"); require ("scripts/db_connection.php"); $query_bathmida='SELECT * FROM 32495_bathmida ORDER BY bathmida ASC'; $query_sxoli='SELECT * FROM 32495_sxoli'; if(isset($_GET['sxoli'])){ $query_tmima='SELECT * FROM 32495_tmima where sid="'.$_GET['sxoli'].'" ORDER BY tmima ASC'; }else{ $query_tmima='SELECT * FROM 32495_tmima ORDER BY tmima ASC'; } $result_bathmida=mysql_query($query_bathmida); $result_sxoli=mysql_query($query_sxoli); $result_tmima=mysql_query($query_tmima); $query='SELECT * FROM 32495_contacts WHERE cid="'.$_GET["cid"].'"'; $result=mysql_query($query); $row=mysql_fetch_assoc($result); ?> <html> <body> <table class="tb" cellspacing="0"> <td width="68%"> <form name="sxoli" method="get" action="<?=$_SERVER['PHP_SELF']?>"> <table border="0" cellpadding="1" cellspacing="1" class="center_tb1"> <tr> <td width="107">Σχολή</td> <td width="192"> <select name="sxoli" onchange="document.sxoli.submit();"> <!-- <option value="">Επιλέξτε ένα</option>--> <? while($row_sxoli=mysql_fetch_assoc($result_sxoli)) {?> <option <? if ($row_sxoli['sid']==$_GET['sxoli']) echo 'selected="selected"';?> value="<?=$row_sxoli['sid']?>"><?=$row_sxoli["sxoli"]?></option> <? } ?> </select> </td> </tr> </table> </form> <form id="editcontact" name="editcontact" method="post" action="upcon.php" onsubmit="return(ValidateForm() && TilCk());"> <table border="0" cellpadding="1" cellspacing="1" class="center_tb1" > <tr> <td width="112">Όνομα</td> <td width="192"><input type="text" name="onoma" value="<?=$row['onoma'] ?>" /></td> </tr> <tr> <td>Επώνυμο</td> <td><input type="text" name="eponumo" value="<?=$row['eponumo'] ?>" /></td> </tr> <tr> <td>Βαθμίδα</td> <td><select name="bathmida"> <? while($row_bathmida=mysql_fetch_assoc($result_bathmida)) {?> <option <? if ($row_bathmida['bid']==$row['bathmida']) echo 'selected="selected"';?> value="<?=$row_bathmida['bid']?>"><?=$row_bathmida["bathmida"]?></option> <? } ?> </select></td> </tr> <tr> <td>Τμήμα</td> <td><select name="tmima"> <? while($row_tmima=mysql_fetch_assoc($result_tmima)) {?> <option <? if ($row_tmima['tid']==$row['tmima']) echo 'selected="selected"';?> value="<?=$row_tmima['tid']?>"><?=$row_tmima["tmima"]?></option> <? } ?> </select></td> </tr> <tr> <td colspan="2" align="center"><input type="submit" name="Submit" value="Ενημέρωση" /></td> </tr> <input type="hidden" name="cid" value="<?=$_GET['cid']?>" /> <input type="hidden" name="sxoli" value="<?=$_GET['sxoli'] ?>" /> </table> </form> </td> </tr> <tr> </table> </body> </html> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.