我希望查询最初返回 c_id>0 的所有记录,然后根据通过文本框提供的后续条件进行过滤。但是,第一次访问该页面时,我没有打印任何记录。这是代码:
$ctitle = mysql_real_escape_string($_POST['ctitle']);
$csubject = mysql_real_escape_string($_POST['csubject']);
$creference = mysql_real_escape_string($_POST['creference']);
$cobjecttype = mysql_real_escape_string($_POST['cobjecttype']);
$cmaterial = mysql_real_escape_string($_POST['cmaterial']);
$ctechnic = mysql_real_escape_string($_POST['ctechnic']);
$cartist = mysql_real_escape_string($_POST['cartist']);
$csource = mysql_real_escape_string($_POST['csource']);
$sql = "SELECT * FROM collections WHERE (
c_id>0 AND
`ctitle` LIKE '{$ctitle}' AND
`csubject` LIKE '{$csubject}' AND
`creference` LIKE '{$creference}' AND
`cobjecttype` LIKE '{$cobjecttype}' AND
`cmaterial` LIKE '{$cmaterial}' AND
`ctechnic` LIKE '{$ctechnic}' AND
`csource` LIKE '{$csource}' AND
`cartist` LIKE '{$cartist}'
)ORDER BY c_id DESC";
当我回显查询时,我会打印以下内容:
request "Could not execute SQL query" SELECT * FROM collections WHERE ( c_id>0 AND `ctitle` LIKE '' AND `csubject` LIKE '' AND `creference` LIKE '' AND `cobjecttype` LIKE '' AND `cmaterial` LIKE '' AND `ctechnic` LIKE '' AND `csource` LIKE '' AND `cartist` LIKE '' )ORDER BY c_id DESC
我应该从这里去哪里?