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

how can i do it?

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


Your 1 and 4 is in different coloumn or same column?
If 1 and 4 is in same column then,it is wrong query... Becoz it is never possible.

other wise , you can use like that....
Select * from Venue where idVenue != 1 or idVenue != 4

If you want to use PHP to create a string containing a SELECT query containing both values in a $day_result array, you could do it like this:

<?php
$day_result = array(1, 4); // Initial array of numbers
$sql3 = "Select * from Venue where ";

foreach($day_result as $day_num){
    $dr[] = "idVenue != $day_num "; // Build array of strings
}

$sql3 .= implode(' AND ', $dr); // convert to string joined by ' AND ' and add to end of $sql3

echo $sql3;
?>

your code is not working

An easier query would be:

select * from table where column not in (1, 4)
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.