Jump to content

Filter mysql query with file_exists() ?


hyeteck

Recommended Posts

hi,

 

i am trying to filter the results of a mysql query with file_exists()

 

i have a database of products with one of the columns of data being the product image url.

 

i want to retreive the results for only the proucts where the pImage exists.

 

i have the following code.

 
$query_Recordset1 = "SELECT 
  `products`.`pID`,
  `products`.`pName`,
  `products`.`pDescription`,
  `products`.`pSection`,
  `products`.`pImage`,
  `products`.`pPrice`,
  `products`.`pListPrice`,
  `products`.`pDisplay`,
  `sections`.`sectionDisabled`,
  `sections`.`sectionID`,
  `products`.`pSell`,
  `prodoptions`.`poProdID`
FROM
  `products`
  INNER JOIN `sections` ON (`products`.`pSection` = `sections`.`sectionID`)
  LEFT JOIN `prodoptions` ON (`products`.`pID` = `prodoptions`.`poProdID`)
WHERE
  (`sections`.`sectionDisabled` = 0) AND 
  (`products`.`pDisplay` = 1) AND
  (`products`.`pInStock` > 0) AND
  (`products`.`pSection` != 256) AND
  (`products`.`pPrice` > 9) ORDER BY $orderby" ;

$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
$Recordset1 = mysql_query($query_limit_Recordset1, $dbh) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);

 

i am using this to show random products on my homepage so i want to show the products where the image exists only.  "pImage" is the column name for the image.

 

any ideas on how i can go about doing this?

 

thanks

Link to comment
https://forums.phpfreaks.com/topic/42911-filter-mysql-query-with-file_exists/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.