Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $dbservertype='mysql';
- $servername='localhost';
- $dbusername='admin81';
- $dbpassword='admin81';
- $dbname='riz_new';
- connecttodb($servername,$dbname,$dbusername,$dbpassword);
- function connecttodb($servername,$dbname,$dbuser,$dbpassword) {
- global $link;
- $link = mysql_connect ("$servername","$dbuser","$dbpassword");
- if (!$link) { die("Could not connect to MySQL"); }
- mysql_select_db("$dbname",$link) or die("could not open db".mysql_error());
- }
- ?>
- <!doctype html public "-//w3c//dtd html 3.2//en">
- <html>
- <head>
- <title>riz</title>
- <SCRIPT language=JavaScript>
- function reload(form) {
- enable();
- var val = form.cat.options[form.cat.options.selectedIndex].value;
- self.location = 'index.php?cat=' + val;
- }
- function reloadModel(form) {
- alert("b");
- var val = form.cat.options[form.cat.options.selectedIndex].value;
- var phoneModel = form.subcat.options[form.subcat.options.selectedIndex].value;
- self.location = 'index.php?cat=' + val + '&subcatModel=' + phoneModel ;
- }
- function enable() {
- // alert(document.f1.cat.options[document.f1.cat.options.selectedIndex].text);
- if (document.f1.cat.options[document.f1.cat.options.selectedIndex].text == 'Select one') {
- document.getElementById("subcat").disabled = true;
- alert ("selected one");
- }
- }
- window.onload=enable;
- alert("a");
- </script>
- <style type="text/css">
- select {height: 20px; width: 150px; max-height: 20px}
- input {height: 20px; width: 150px; max-height: 20px}
- </style>
- </head>
- <body>
- <div style="position: absolute; left: 0; top: 0; right: 0; bottom: 0; ">
- <div id="div1" style="width:50%; height:20%; background-color:White; border-style: solid; border-width: 1px; width: 50%; margin: auto;}" >a
- <?
- @$cat=$_GET['cat']; // Use this line or below line if register_global is off
- if (strlen($cat) > 0 and !is_numeric($cat)) { // to check if $cat is numeric data or not.
- echo "Data Error";
- exit;
- }
- //@$cat=$HTTP_GET_VARS['cat']; // Use this line or above line if register_global is off
- $quer2=mysql_query("SELECT DISTINCT category,cat_id FROM category order by category");
- if (isset($cat) and strlen($cat) > 0){
- $quer = mysql_query("SELECT DISTINCT subcategory FROM subcategory where cat_id=$cat order by subcategory");
- } else {
- $quer = mysql_query("SELECT DISTINCT subcategory FROM subcategory order by subcategory"); }
- // Form begins
- echo "<form method=post name=f1 action='riz_next.php'>";
- /// Add your form processing page address to action in above line. Example action=dd-check.php////
- ////////// Starting of first drop downlist /////////
- // table begins
- echo "<table border='0'>";
- echo "<tr>";
- echo "<td>Please select phone manufacturer</td>";
- echo "<td>";
- echo "<select name='cat' onchange=\"reload(this.form)\"><option value=''>Select one</option>";
- while($noticia2 = mysql_fetch_array($quer2)) {
- if ($noticia2['cat_id'] == @$cat){
- echo "<option selected value='$noticia2[cat_id]'>$noticia2[category]</option>"."<br>";}
- else {
- echo "<option value='$noticia2[cat_id]'>$noticia2[category]</option>";
- }
- }
- echo "</select>";
- echo "</td>";
- echo "</tr>";
- echo "<tr>";
- echo "<td>Service Provider of Phone</td>";
- echo "<td>";
- echo "<select id = 'subcat' name='subcat' onchange=\"reloadModel(this.form)\" ><option value=''>";
- echo $_GET["subcatModel"];
- echo "test";
- echo "</option>";
- while($noticia = mysql_fetch_array($quer)) {
- echo "<option value='$noticia[subcategory]'>$noticia[subcategory]</option>";
- }
- echo "</select>";
- echo "</td>";
- echo "</tr>";
- echo "<tr>";
- echo "<td>Phone Model</td>";
- echo "<td>";
- echo "<input id = 'model' type='text' name='model'>";
- echo "</td>";
- echo "</tr>";
- echo "<tr>";
- echo "<td>IMEI Number</td>";
- echo "<td>";
- echo "<input id = 'imei' type='text' name='imei'>";
- echo "</td>";
- echo "</tr>";
- echo "</table>";
- // Submit
- echo "<input type=submit value=Submit>";
- echo "</form>";
- ?>
- </div>
- <div id="div2" style="width:50%; height:80%; background-color:wheat; border-style: solid; border-width: 1px; width: 50%;
- margin: auto; text-align: center;">
- <?php
- $result = "Select Phone model";
- if($_GET["subcatModel"] == "iPhone 3G"){
- $result = "Youve selected 1";
- }
- ?>
- Price: <?php echo $result; ?><br>
- Process Time: <br>
- </div>
- </div>
- </body>
- </html>
Add Comment
Please, Sign In to add comment