سلام اساتید
من این خط کد رو order by productid desc کجای کد پاین بذارم که جواب بده
$p="select * from tblproduct where catid=".$_GET['cat'];
نمایش نسخه قابل چاپ
سلام اساتید
من این خط کد رو order by productid desc کجای کد پاین بذارم که جواب بده
$p="select * from tblproduct where catid=".$_GET['cat'];
این کد برای چه کاری میخواید استفاده کنید؟
به صورت بالاست ولی این کد شما مشکل امنیتی داره؛ SQL Injection.کد PHP:
$p="select * from tblproduct where catid='$_GET['cat']' order by 'productid' desc";
کد زیر امن تره:
کد PHP:
function sqi( $value ){
if( get_magic_quotes_gpc() ){
$value = stripslashes( $value );
}
if( function_exists("mysql_real_escape_string") ){
$value = mysql_real_escape_string( $value );
}
else
{
$value = addslashes( $value );
}
return $value;
}
$cat= $_GET['cat'];
$cat= sqi($cat);
$p="select * from tblproduct where catid='$cat' order by 'productid' desc";