mysql - listing database values for select and processing form php -



mysql - listing database values for select and processing form php -

i have used next post create filtered dropdown list database table, working fine.

listing database values according selected filter in dropdown before edit ajax, process.php working perfect without problems , after have made changes filtering select alternative working fine.

codes above post reply accepted. html

<select name="filter" onchange="filter(this.value)"> <option>filter:</option> <option value="alphabetical">asc</option> <option value="date">date</option> </select> <div id="results"></div>// store results here

jquery:

function filter(item){ $.ajax({ type: "post", url: "filter.php", data: {value: item}, success: function(data){ $("#results").html(data); } }); }

filter.php:

include "connection.php"; //database connection $fieldname = $_post['value']; if($fieldname == "alphabetical"){ // if take first alternative $query1 = mysqli_query("select * table order name asc"); // echo results }else{ // if take sec alternative $query1 = mysqli_query("select * table order date asc"); // echo results }

my form looks this

<form action="process.php" method="post"> <label>code</label><input type="text" name="code" /> <label>course</label> <div id="results"></div> <input type="submit" value="submit" /> </form>

now problem when submit form sending values filter.php not process.php

please, how rectify problem? thanks

as per user1406062's request network console web console

my process.php

include("../include/session.php"); class userprocess { /* class constructor */ function userprocess(){ global $session; if(!$session->isuser()){ header("location: ../index.php"); return; } /* pupil submit forms register course of study */ if(isset($_post['subreg'])){ $this->procreg(); } else if(isset($_post['subrem'])){ $this->procrem(); } else{ header("location: ../index.php"); } } function procreg(){ global $session, $form; $_post = $session->cleaninput($_post); $retval = $session->regu($_post['courseid'], $_post['user']); /* add together successful */ if($retval == 0){ $_session['addsuccess'] = true; header("location: ".$session->referrer); } /* error found form */ else if($retval == 1){ $_session['value_array'] = $_post; $_session['error_array'] = $form->geterrorarray(); header("location: ".$session->referrer); } /* add together failed */ else if($retval == 2){ $_session['addsuccess'] = false; header("location: ".$session->referrer); } } $userprocess = new userprocess;

well, in javascript function have hard-coded url:

function filter(item){ $.ajax({ type: "post", **url: "filter.php",** data: {value: item}, success: function(data){ $("#results").html(data); } });

}

and not using form action url... alter filtert.php process.php

php mysql ajax

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -