Try something like this:

$sql = "SELECT robeson_inv.manufacturer, robeson_inv.model,";
$sql .= " robeson_inv.specs, robeson_inv.qty, robeson_inv.ID";
$sql .= " FROM robeson_inv";
$sql .= " WHERE robeson_inv.manufacturer = 'vManufacturer'";
if ($vKeywords)
  $sql .= " AND MATCH (robeson_inv.specs) AGAINST ('$vKeywords')";
$sql .= " ORDER BY robeson_inv.model";

Martin

-----Original Message-----
From: Robb Kerr [mailto:[EMAIL PROTECTED]
Sent: Thursday, 30 October 2003 11:59 AM
To: [EMAIL PROTECTED]
Subject: [PHP] conditional within SELECT


Here's another newbie question. The SELECT statement below gets its values
from the URL of the page. When something is entered for "vKeywords" the
SELECT works fine and returns the correct records. However, if nothing is
entered for "vKeywords" (which should return all records matching the other
criteria), the results are NO records. How do I make the "MATCH
(robeson_inv.specs) AGAINST ('vKeywords')" part of the SELECT statement
conditional?

SELECT robeson_inv.manufacturer, robeson_inv.model, robeson_inv.specs,
robeson_inv.qty, robeson_inv.ID
FROM robeson_inv
WHERE MATCH (robeson_inv.specs) AGAINST ('vKeywords') AND
robeson_inv.manufacturer = 'vManufacturer'
ORDER BY robeson_inv.model

Thanx,
-- 
Robb Kerr
Digital IGUANA
Helping Digital Artists Achieve their Dreams
http://www.digitaliguana.com
http://www.cancerreallysucks.org

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to