Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.
Moderator: General Moderators
-
Hunnam
- Forum Newbie
- Posts: 4
- Joined: Thu Jul 05, 2007 3:50 am
Post
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.
-
superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
Post
by superdezign »
Have you tried "WHERE `images` != NULL?" Seems like the common sense answer.
-
feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
Post
by feyd »
"!=" doesn't work with NULL as nothing can equal NULL. It either IS or IS NOT NULL.
-
superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
Post
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.
-
Hunnam
- Forum Newbie
- Posts: 4
- Joined: Thu Jul 05, 2007 3:50 am
Post
by Hunnam »
Thanks for the replies, I used
Code: Select all
$query_Recordset1 = "SELECT * FROM PHPAUCTIONXL_auctions WHERE pict_url >0"