View Single Post
ישן 18-02-09, 13:55   # 10
AlmogBaku
חבר וותיק
 
AlmogBaku's Avatar
 
מיני פרופיל
תאריך הצטרפות: Nov 2007
מיקום: מודיעין
הודעות: 1,022

AlmogBaku לא מחובר  

ברור- נתתי לך הסבר לגבי הטבלאות איך צריך לבנות אותם. מכאן השאילתות מאוד פשוטות..
PHP קוד:
/**
 * Build custom where statment by the post request
 *
 * @param array $post
 * @return string $where
 */
function _custom_build_where($post=null) {
    if(
$post==null$post=$_POST;
    
    
$where "";
    
$and   false;
    if(!empty(
$post['name'])) {
        if(
$and$where.=" AND";
        
$where .= " `name`='" mysql_real_escape_string($post['name'])."'";
    }
    if(!empty(
$post['city'])) {
        if(
$and$where.=" AND";
        
$where .= " `city_id`='" intval($post['city']);
    }
    if(!empty(
$post['zone'])) {
        if(
$and$where.=" AND";
        
$where .= " `zone_id`='" intval($post['zone']);
    }
    return 
$where;    
}
$where _custom_build_where($_POST);
$query  "SELECT * FROM `prefix_card` WHERE " $where ";";
echo 
$where
  Reply With Quote