Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I run the code you did and it works for me. The only change I made was creating the form element. I have to create a table to make it functional. I did not go throughout village. I stopped when I got districts working.</p> <p>Here is the code I changed:</p> <pre><code>&lt;?php $db = mysql_connect('127.0.0.1','root') or die('could not connect'); mysql_select_db('financial_system_local',$db); ?&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt; &lt;title&gt;Register Page&lt;/title&gt; &lt;link href="style/stylesheet.css" rel="stylesheet" type="text/css" /&gt; &lt;link href="style/imagesGallery.css"rel="stylesheet" type="text/css"/&gt; &lt;SCRIPT language=JavaScript&gt; function reload(form) { var val=form.governorate.options[form.governorate.options.selectedIndex].value; self.location='register.php?governorate=' + val ; } function reload3(form) { var val=form.governorate.options[form.governorate.options.selectedIndex].value; var val2=form.district.options[form.district.options.selectedIndex].value; self.location='register.php?governorate=' + val + '&amp;district=' + val2 ; } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;form&gt; &lt;?php $governorate = ""; $district = ""; //$quer2=mysql_query("SELECT DISTINCT category,cat_id FROM category order by category"); $quer2=mysql_query("SELECT DISTINCT governorate_name,governorate_id FROM governorate order by governorate_name",$db); echo mysql_error($db); //$cat=$_GET['cat']; $governorate=$_GET['governorate']; var_dump($governorate); if(isset($governorate) and strlen($governorate) &gt; 0) { $quer=mysql_query("SELECT DISTINCT district_name,district_id FROM districts where governorate_id=$governorate order by district_name",$db); } else { $quer=mysql_query("SELECT DISTINCT district_name,district_id FROM districts order by district_name",$db); } $district=$_GET['district']; if(isset($district) and strlen($district) &gt; 0){ $quer3=mysql_query("SELECT DISTINCT village_name FROM village where district_id=$district order by village_name"); } else { $quer3=mysql_query("SELECT DISTINCT village_name FROM village order by village_name"); } echo "&lt;select name='governorate' onchange=\"reload(this.form)\"&gt;&lt;option value=''&gt;Select one&lt;/option&gt;"; while($noticia2 = mysql_fetch_array($quer2)) { if($noticia2['governorate_id']==@$governorate) { echo "&lt;option selected value='$noticia2[governorate_id]'&gt;$noticia2[governorate_name]&lt;/option&gt;"."&lt;BR&gt;"; } else { echo "&lt;option value='$noticia2[governorate_id]'&gt;$noticia2[governorate_name]&lt;/option&gt;"; } } echo "&lt;/select&gt;"; echo "&lt;select name='district' onchange=\"reload3(this.form)\"&gt;&lt;option value=''&gt;Select one&lt;/option&gt;"; while($noticia = mysql_fetch_array($quer)) { if($noticia['district_id']==@$district) { echo "&lt;option selected value='$noticia[district_id]'&gt;$noticia[district_name]&lt;/option&gt;"."&lt;BR&gt;"; } else { echo "&lt;option value='$noticia[district_id]'&gt;$noticia[district_name]&lt;/option&gt;"; } } echo "&lt;/select&gt;"; echo "&lt;select name='village' &gt;&lt;option value=''&gt;Select one&lt;/option&gt;"; while($noticia = mysql_fetch_array($quer3)) { echo "&lt;option value='$noticia[village_name]'&gt;$noticia[village_name]&lt;/option&gt;"; } echo "&lt;/select&gt;"; ?&gt; &lt;/form&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload