Page 1 of 1

Null records

Posted: Sat Jul 14, 2007 6:27 pm
by Hunnam
I have setup a file to get info from an Auction site I have, I want to show the latest items added (that have a pic).

The problem is I cannot for the life of me work out how to ignore a record that has a null record in the images coloum.

Code: Select all

<?php require_once('public_html/Connections/auction.php'); ?>
<?php
$maxRows_Recordset1 = 3;
$pageNum_Recordset1 = 0;
if (isset($HTTP_GET_VARS['pageNum_Recordset1'])) {
  $pageNum_Recordset1 = $HTTP_GET_VARS['pageNum_Recordset1'];
}
$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;

mysql_select_db($database_auction, $auction);
$query_Recordset1 = "SELECT * FROM PHPAUCTIONXL_auctions";
$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
$Recordset1 = mysql_query($query_limit_Recordset1, $auction) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);

if (isset($HTTP_GET_VARS['totalRows_Recordset1'])) {
  $totalRows_Recordset1 = $HTTP_GET_VARS['totalRows_Recordset1'];
} else {
  $all_Recordset1 = mysql_query($query_Recordset1);
  $totalRows_Recordset1 = mysql_num_rows($all_Recordset1);
}
$totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;
?>
Any help would be greatly appreciated.

Posted: Sun Jul 15, 2007 6:48 am
by superdezign
Have you tried "WHERE `images` != NULL?" Seems like the common sense answer.

Posted: Sun Jul 15, 2007 6:49 am
by feyd
"!=" doesn't work with NULL as nothing can equal NULL. It either IS or IS NOT NULL.

Posted: Sun Jul 15, 2007 7:10 am
by superdezign
feyd wrote:"!=" doesn't work with NULL as nothing can equal NULL. It either IS or IS NOT NULL.
I figured as much. I remember califdon mentioning it, but I couldn't find it in the manual.

Posted: Sun Jul 15, 2007 1:46 pm
by Hunnam
Thanks for the replies, I used

Code: Select all

$query_Recordset1 = "SELECT * FROM PHPAUCTIONXL_auctions WHERE pict_url >0"