Hi there, This is what I want to do. I want to have one template php with the mysql query below: The idea is that i can call one template file without physically having the files on the server: I have this defined at the top of the page: $cat = array('clothes','electronics'); And this is the query i want to run: ps. This part from the query doesn't work Niche='$cat' If i change the Niche='$cat' to Niche='clothes' then it works. $sql = "SELECT Sitename_open, Sitename_closed, Message, Niche, IF (CHAR_LENGTH(Message)>100,RPAD(LEFT(Message,50),53,'.'),Message) AS Message FROM xxxxxxx where Niche='$cat' ORDER BY `Sitename_open` ASC"; I hope someone can help me
You would need the where clause to be: where Niche = 'clothes' or Niche = 'electronics' Code (sql): or where Niche in ('clothes', 'electronics') Code (sql): you could probably do $sql = "SELECT Sitename_open, Sitename_closed, Message, Niche, IF (CHAR_LENGTH(Message)>100,RPAD(LEFT(Message,50),53,'.'),Message) AS Message FROM xxxxxxx where Niche in ('" . implode("','", $cat) . "') ORDER BY `Sitename_open` ASC"; Code (php):
That seems to work, but now i get all the categories in one single page. I wanted this page to show only the items where Niche = Clothes when i open the virtual page :clothes.php Any ideas how to do this? Cheers