简体   繁体   中英

MYSQL query to order by experience

I m trying to order by experience in ASc order. I need to select the students of particular course and order them based on their expreience in ascending order.Please help me. Here is the code

Search Skills:</label>
<select name="skill" style="width: 220px; border:solid 1px #5A380D; height: 38px; margin-left:35px; border: 1px solid #0d82b9; " >
    <option   value="selectopt1" >------Select Course-----</option>
          <option value="Electricals and Electronics">Electricals and Electronics</option>
          <option value="Ites">Ites</option>
          <option value="Hotel Management">Hotel Management</option><option value="Beauty Culture">Beauty Culture</option>
          <option value="Retail Management">Retail Management</option></select>
</td></tr>


</td></tr><tr>
<td align="right"><br />
<input type="hidden" name="formType" id="formType" value="reg"/>
<input type="submit" name="submit" value="Submit" class="button">

$dbserver="localhost";
$dbusername="root";
$dbpassword="";
$dbname="ABC";
$dbhandle = mysql_connect($dbserver, $dbusername, $dbpassword) or die("Unable to connect to MySQL");
mysql_select_db($dbname,$dbhandle) or die('cannot select db');
if(isset($_POST['submit'])) 
{
$skill=$_POST["skill"];

$query = "SELECT * FROM `resume` WHERE skill ='$skill' ORDER by exp1";
$run = mysql_query($query);
if(mysql_num_rows($run)>0){
echo "<script>window.open('searchmem.php?skill=".$skill."', '_self')</script>";
}
else {
echo "<script>alert('do not Exist!')</script>";
    }
}
}
?>

尝试以下,

$query = "SELECT * FROM `resume` WHERE skill ='$skill' ORDER by exp1 asc";

最好的做法是用大写的 SQL 关键字写成如下所示,它可以安全地工作,没有任何版本问题。

 $query = "SELECT * FROM `resume` WHERE `skill` = '$skill' ORDER BY exp1 ASC";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM