SHOW:
|
|
- or go back to the newest paste.
| 1 | - | <?php |
| 1 | + | |
| 2 | - | |
| 2 | + | <?php |
| 3 | - | # Include db.inc |
| 3 | + | |
| 4 | - | include 'db.inc'; |
| 4 | + | # Include db.inc |
| 5 | - | |
| 5 | + | include 'db.inc'; |
| 6 | - | # Connect to the database |
| 6 | + | |
| 7 | - | mysql_connect("$hostName", "$username", "$password");
|
| 7 | + | # Connect to the database |
| 8 | - | |
| 8 | + | mysql_connect("$hostName", "$username", "$password");
|
| 9 | - | ?> |
| 9 | + | |
| 10 | - | |
| 10 | + | ?> |
| 11 | - | <html> |
| 11 | + | |
| 12 | - | <head> |
| 12 | + | <html> |
| 13 | - | |
| 13 | + | <head> |
| 14 | - | <SCRIPT language=JavaScript> |
| 14 | + | |
| 15 | - | |
| 15 | + | <SCRIPT language=JavaScript> |
| 16 | - | function reloadpage(form) |
| 16 | + | |
| 17 | - | {
|
| 17 | + | function reloadpage(form) |
| 18 | - | var val=form.icd_main.options[form.icd_main.options.selectedIndex].value; |
| 18 | + | {
|
| 19 | - | self.location='index.php?icd_main=' + val ; |
| 19 | + | var val=form.icd_main.options[form.icd_main.options.selectedIndex].value; |
| 20 | - | } |
| 20 | + | self.location='index.php?icd_main=' + val ; |
| 21 | - | |
| 21 | + | } |
| 22 | - | function reloadpageagain(form) |
| 22 | + | |
| 23 | - | {
|
| 23 | + | function reloadpageagain(form) |
| 24 | - | var val=form.icd_main.options[form.icd_main.options.selectedIndex].value; |
| 24 | + | {
|
| 25 | - | var val2=form.icd_sub.options[form.icd_sub.options.selectedIndex].value; |
| 25 | + | var val=form.icd_main.options[form.icd_main.options.selectedIndex].value; |
| 26 | - | |
| 26 | + | var val2=form.icd_sub.options[form.icd_sub.options.selectedIndex].value; |
| 27 | - | self.location='index.php?icd_main=' + val + '&cat3=' + val2 ; |
| 27 | + | |
| 28 | - | } |
| 28 | + | self.location='index.php?icd_main=' + val + '&cat3=' + val2 ; |
| 29 | - | |
| 29 | + | } |
| 30 | - | </script> |
| 30 | + | |
| 31 | - | |
| 31 | + | </script> |
| 32 | - | </head> |
| 32 | + | |
| 33 | - | |
| 33 | + | </head> |
| 34 | - | <body> |
| 34 | + | |
| 35 | - | |
| 35 | + | <body> |
| 36 | - | <form name="form1" method="post" action="index.php"> |
| 36 | + | |
| 37 | - | |
| 37 | + | <form name="form1" method="post" action="index.php"> |
| 38 | - | <?php |
| 38 | + | |
| 39 | - | |
| 39 | + | <?php |
| 40 | - | # The following code produces the three column drop down list box |
| 40 | + | |
| 41 | - | |
| 41 | + | # The following code produces the three column drop down list box |
| 42 | - | # Get data from category_1 table for first list box |
| 42 | + | |
| 43 | - | |
| 43 | + | # Get data from category_1 table for first list box |
| 44 | - | $quer2=mysql_query("SELECT DISTINCT category,cat_id FROM $databaseName.category_1 order by cat_id");
|
| 44 | + | |
| 45 | - | |
| 45 | + | $quer2=mysql_query("SELECT DISTINCT category,cat_id FROM $databaseName.category_1 order by cat_id");
|
| 46 | - | # End of query for first list box |
| 46 | + | |
| 47 | - | |
| 47 | + | # End of query for first list box |
| 48 | - | |
| 48 | + | |
| 49 | - | # For second drop down list we will check if a category is selected |
| 49 | + | |
| 50 | - | |
| 50 | + | # For second drop down list we will check if a category is selected |
| 51 | - | $cat=$HTTP_GET_VARS['icd_main']; // This line is added to take care if global variable is off |
| 51 | + | |
| 52 | - | |
| 52 | + | $cat=$HTTP_GET_VARS['icd_main']; // This line is added to take care if global variable is off |
| 53 | - | if(isset($cat) and strlen($cat) > 0){
|
| 53 | + | |
| 54 | - | $quer=mysql_query("SELECT DISTINCT subcategory,subcat_id FROM $databaseName.subcategory where cat_id=$cat order by subcat_id");
|
| 54 | + | if(isset($cat) and strlen($cat) > 0){
|
| 55 | - | } |
| 55 | + | $quer=mysql_query("SELECT DISTINCT subcategory,subcat_id FROM $databaseName.subcategory where cat_id=$cat order by subcat_id");
|
| 56 | - | |
| 56 | + | } |
| 57 | - | # For third drop down list we will check if subcategory is selected |
| 57 | + | |
| 58 | - | |
| 58 | + | # For third drop down list we will check if subcategory is selected |
| 59 | - | $cat3=$HTTP_GET_VARS['cat3']; // This line is added to take care if global variable is off |
| 59 | + | |
| 60 | - | |
| 60 | + | $cat3=$HTTP_GET_VARS['cat3']; // This line is added to take care if global variable is off |
| 61 | - | if(isset($cat3) and strlen($cat3) > 0){
|
| 61 | + | |
| 62 | - | $quer3=mysql_query("SELECT DISTINCT subcat2 FROM $databaseName.subcategory2 where subcat_id=$cat3 order by subcat2");
|
| 62 | + | if(isset($cat3) and strlen($cat3) > 0){
|
| 63 | - | } |
| 63 | + | $quer3=mysql_query("SELECT DISTINCT subcat2 FROM $databaseName.subcategory2 where subcat_id=$cat3 order by subcat2");
|
| 64 | - | |
| 64 | + | } |
| 65 | - | # end of query for third subcategory drop down list box |
| 65 | + | |
| 66 | - | |
| 66 | + | # end of query for third subcategory drop down list box |
| 67 | - | # Start first drop downlist |
| 67 | + | |
| 68 | - | |
| 68 | + | # Start first drop downlist |
| 69 | - | echo "<select name='icd_main' onchange=\"reloadpage(this.form)\"><option value=''>Masina</option>"; |
| 69 | + | |
| 70 | - | |
| 70 | + | echo "<select name='icd_main' onchange=\"reloadpage(this.form)\"><option value=''>Masina</option>"; |
| 71 | - | while($noticia2 = mysql_fetch_array($quer2)) {
|
| 71 | + | |
| 72 | - | |
| 72 | + | while($noticia2 = mysql_fetch_array($quer2)) {
|
| 73 | - | # If a category has been selected, show it here |
| 73 | + | |
| 74 | - | if($noticia2['cat_id']==@$cat){
|
| 74 | + | # If a category has been selected, show it here |
| 75 | - | echo "<option selected value='$noticia2[cat_id]'>$noticia2[category]</option>"."<BR>"; |
| 75 | + | if($noticia2['cat_id']==@$cat){
|
| 76 | - | } |
| 76 | + | echo "<option selected value='$noticia2[cat_id]'>$noticia2[category]</option>"."<BR>"; |
| 77 | - | |
| 77 | + | } |
| 78 | - | # Display all categories |
| 78 | + | |
| 79 | - | if($noticia2['cat_id']!=@$cat){
|
| 79 | + | # Display all categories |
| 80 | - | echo "<option value='$noticia2[cat_id]'>$noticia2[category]</option>"; |
| 80 | + | if($noticia2['cat_id']!=@$cat){
|
| 81 | - | } |
| 81 | + | echo "<option value='$noticia2[cat_id]'>$noticia2[category]</option>"; |
| 82 | - | } |
| 82 | + | } |
| 83 | - | echo "</select>"; |
| 83 | + | } |
| 84 | - | |
| 84 | + | echo "</select>"; |
| 85 | - | # End first drop down list |
| 85 | + | |
| 86 | - | |
| 86 | + | # End first drop down list |
| 87 | - | print " "; |
| 87 | + | |
| 88 | - | |
| 88 | + | print " "; |
| 89 | - | # Start second drop downlist |
| 89 | + | |
| 90 | - | |
| 90 | + | # Start second drop downlist |
| 91 | - | echo "<select name='icd_sub' onchange=\"reloadpageagain(this.form)\"><option value=''>Model</option>"; |
| 91 | + | |
| 92 | - | while($noticia = mysql_fetch_array($quer)) {
|
| 92 | + | echo "<select name='icd_sub' onchange=\"reloadpageagain(this.form)\"><option value=''>Model</option>"; |
| 93 | - | |
| 93 | + | while($noticia = mysql_fetch_array($quer)) {
|
| 94 | - | # Display all subcategories for the selected category |
| 94 | + | |
| 95 | - | if($noticia['subcat_id']==@$cat3){
|
| 95 | + | # Display all subcategories for the selected category |
| 96 | - | echo "<option selected value='$noticia[subcat_id]'>$noticia[subcategory]</option>"."<BR>"; |
| 96 | + | if($noticia['subcat_id']==@$cat3){
|
| 97 | - | |
| 97 | + | echo "<option selected value='$noticia[subcat_id]'>$noticia[subcategory]</option>"."<BR>"; |
| 98 | - | } |
| 98 | + | |
| 99 | - | |
| 99 | + | } |
| 100 | - | # Display all subcategory items |
| 100 | + | |
| 101 | - | if($noticia['subcat_id']!=@$cat3){
|
| 101 | + | # Display all subcategory items |
| 102 | - | echo "<option value='$noticia[subcat_id]'>$noticia[subcategory]</option>"; |
| 102 | + | if($noticia['subcat_id']!=@$cat3){
|
| 103 | - | } |
| 103 | + | echo "<option value='$noticia[subcat_id]'>$noticia[subcategory]</option>"; |
| 104 | - | } |
| 104 | + | } |
| 105 | - | echo "</select>"; |
| 105 | + | } |
| 106 | - | |
| 106 | + | echo "</select>"; |
| 107 | - | # End the second drop down list |
| 107 | + | |
| 108 | - | |
| 108 | + | # End the second drop down list |
| 109 | - | print " "; |
| 109 | + | |
| 110 | - | |
| 110 | + | print " "; |
| 111 | - | # Start third drop downlist |
| 111 | + | |
| 112 | - | echo "<select name='icd_diag'><option value=''>AN</option>"; |
| 112 | + | # Start third drop downlist |
| 113 | - | while($noticia = mysql_fetch_array($quer3)) {
|
| 113 | + | echo "<select name='icd_diag'><option value=''>AN</option>"; |
| 114 | - | |
| 114 | + | while($noticia = mysql_fetch_array($quer3)) {
|
| 115 | - | echo "<option value='$noticia[subcat2]'>$noticia[subcat2]</option>"; |
| 115 | + | |
| 116 | - | |
| 116 | + | echo "<option value='$noticia[subcat2]'>$noticia[subcat2]</option>"; |
| 117 | - | } |
| 117 | + | |
| 118 | - | echo "</select>"; |
| 118 | + | } |
| 119 | - | # End the third drop down list |
| 119 | + | echo "</select>"; |
| 120 | - | |
| 120 | + | # End the third drop down list |
| 121 | - | ?> |
| 121 | + | |
| 122 | - | |
| 122 | + | ?> |
| 123 | - | <input type="submit" value="Arata Produse"> |
| 123 | + | |
| 124 | - | |
| 124 | + | <input type="submit" value="Arata Produse"> |
| 125 | - | </form> |
| 125 | + | |
| 126 | - | |
| 126 | + | </form> |
| 127 | - | <?php |
| 127 | + | |
| 128 | - | |
| 128 | + | <?php |
| 129 | - | # This form handler shows how you could typically handle data from the drop down list boxes. |
| 129 | + | |
| 130 | - | |
| 130 | + | # This form handler shows how you could typically handle data from the drop down list boxes. |
| 131 | - | # Get values from form |
| 131 | + | |
| 132 | - | $icd_main=$_POST['icd_main']; |
| 132 | + | |
| 133 | - | $icd_sub=$_POST['icd_sub']; |
| 133 | + | |
| 134 | - | $icd_diag=$_POST['icd_diag']; |
| 134 | + | # Get values from form |
| 135 | - | |
| 135 | + | $icd_main=$_POST['icd_main']; |
| 136 | - | # Check to see from which drop down list boxes selections have been made |
| 136 | + | $icd_sub=$_POST['icd_sub']; |
| 137 | - | # Was an item selected from the third drop down list box? |
| 137 | + | $icd_diag=$_POST['icd_diag']; |
| 138 | - | if (!$icd_diag){
|
| 138 | + | |
| 139 | - | |
| 139 | + | # Check to see from which drop down list boxes selections have been made |
| 140 | - | # If an item was not selected from the third drop down list box, |
| 140 | + | # Was an item selected from the third drop down list box? |
| 141 | - | # was one selected from the second? |
| 141 | + | if (!$icd_diag){
|
| 142 | - | if (!$icd_sub){
|
| 142 | + | |
| 143 | - | |
| 143 | + | # If an item was not selected from the third drop down list box, |
| 144 | - | # If an item was not selected from the second drop down list box, |
| 144 | + | # was one selected from the second? |
| 145 | - | # was one selected from the first? |
| 145 | + | if (!$icd_sub){
|
| 146 | - | |
| 146 | + | |
| 147 | - | # If not, display message |
| 147 | + | # If an item was not selected from the second drop down list box, |
| 148 | - | if (!$icd_main){
|
| 148 | + | # was one selected from the first? |
| 149 | - | print ""; |
| 149 | + | |
| 150 | - | } |
| 150 | + | # If not, display message |
| 151 | - | |
| 151 | + | if (!$icd_main){
|
| 152 | - | else {
|
| 152 | + | print ""; |
| 153 | - | # Select category from category_1 where cat_id = icd_main |
| 153 | + | } |
| 154 | - | |
| 154 | + | |
| 155 | - | $result = mysql_query( |
| 155 | + | else {
|
| 156 | - | "SELECT category FROM $databaseName.category_1 WHERE cat_id = '$icd_main'"); |
| 156 | + | # Select category from category_1 where cat_id = icd_main |
| 157 | - | |
| 157 | + | |
| 158 | - | while ($row = mysql_fetch_assoc($result)){
|
| 158 | + | $result = mysql_query( |
| 159 | - | $category = $row['category']; |
| 159 | + | "SELECT category FROM $databaseName.category_1 WHERE cat_id = '$icd_main'"); |
| 160 | - | print "You selected $category from the first drop down list box.\n"; |
| 160 | + | |
| 161 | - | } |
| 161 | + | while ($row = mysql_fetch_assoc($result)){
|
| 162 | - | |
| 162 | + | $category = $row['category']; |
| 163 | - | } |
| 163 | + | print "You selected $category from the first drop down list box.\n"; |
| 164 | - | } |
| 164 | + | } |
| 165 | - | |
| 165 | + | |
| 166 | - | # If an item was selected from the second drop down list box, make a selection from the |
| 166 | + | } |
| 167 | - | # subcategory table |
| 167 | + | } |
| 168 | - | else {
|
| 168 | + | |
| 169 | - | |
| 169 | + | # If an item was selected from the second drop down list box, make a selection from the |
| 170 | - | $result = mysql_query( |
| 170 | + | # subcategory table |
| 171 | - | "SELECT subcategory FROM $databaseName.subcategory WHERE subcat_id = '$icd_sub'"); |
| 171 | + | else {
|
| 172 | - | |
| 172 | + | |
| 173 | - | while ($row = mysql_fetch_assoc($result)){
|
| 173 | + | $result = mysql_query( |
| 174 | - | $subcategory = $row['subcategory']; |
| 174 | + | "SELECT subcategory FROM $databaseName.subcategory WHERE subcat_id = '$icd_sub'"); |
| 175 | - | print "You have selected $subcategory from the second drop down list box.\n"; |
| 175 | + | |
| 176 | - | } |
| 176 | + | while ($row = mysql_fetch_assoc($result)){
|
| 177 | - | } |
| 177 | + | $subcategory = $row['subcategory']; |
| 178 | - | } |
| 178 | + | print "You have selected $subcategory from the second drop down list box.\n"; |
| 179 | - | |
| 179 | + | } |
| 180 | - | # If an item was selected from the third drop down list box |
| 180 | + | } |
| 181 | - | else {
|
| 181 | + | } |
| 182 | - | |
| 182 | + | |
| 183 | - | print "Ai ales $icd_diag din a treia categorie.\n"; |
| 183 | + | # If an item was selected from the third drop down list box |
| 184 | - | } |
| 184 | + | else {
|
| 185 | - | |
| 185 | + | |
| 186 | - | ?> |
| 186 | + | print "Ai ales $icd_diag din a treia categorie.\n"; |
| 187 | - | </body> |
| 187 | + | } |
| 188 | - | </head> |
| 188 | + | |
| 189 | ||
| 190 | ||
| 191 | ?> | |
| 192 | ||
| 193 | </body> | |
| 194 | </head> |