Hi! i have problems one query.

$day_result has a value of 1 and 4

$sql3 = "Select * from Venue where idVenue != $day_result";
echo $sql3;
if i use for loop for the above it will give the result below

Select * from Venue where idVenue != 1
Select * from Venue where idVenue != 4

But this is the result i want to get:

Select * from Venue where idVenue != 1 and idVenue != 4

wad loop or is there anyway to append? how can i do it?

I'm assuming $day_result is an array... In which case:

$sql3 = "SELECT * from Venue WHERE"
$first_day = true;
foreach($day_result as $day) {
    if(!first_day) {  // Check if we need to use AND
       $sql3 .= "AND";
    }  
    else {           // Set flag for next loop execution
        $first_day = false;       
    }
    $sql3 .= " idVenue != '$day' ";
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.