我试图按照ASc顺序的经验订购。我需要选择特定课程的学生,并根据他们的升序顺序进行排序。请帮助我。这是代码
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>";
}
}
}
?>
答案 0 :(得分:0)
尝试以下方法,
$query = "SELECT * FROM `resume` WHERE skill ='$skill' ORDER by exp1 asc";
答案 1 :(得分:0)
使用SQL关键字的大写字母编写如下的最佳做法,它可以安全地工作而不会出现任何版本问题。
$query = "SELECT * FROM `resume` WHERE `skill` = '$skill' ORDER BY exp1 ASC";