DBookatay Posted February 9, 2008 Share Posted February 9, 2008 Can anyone spot an error: My "if (!$row_count)" (near the end of the code) does not work on this page, but does on a different. Everything else seems to work fine though. (I removed all non important php, just to make the script shorter) <? if(!empty($where)) {$where = 'where ' . implode(' and ', $where).'and status = "Active"';} $offset = ($_GET['page']-1) * $num; $query = "SELECT count(*) as thecount from Inventory $where"; $result = mysql_query($query); $row = mysql_fetch_array($result); $total = $row[thecount]; $pages = ceil($total/$num); $query = "SELECT * FROM Inventory $where ORDER BY $filter limit $offset,$num"; $result = mysql_query($query); $numrows = mysql_num_rows($result); for($x = 0; $row = mysql_fetch_array($result); $x++) { $stock = $row['stock']; $class = ($row_count % 2) ? $class1 : $class2; if ($_GET['view'] == "Caption") { $mileage = floor($row[mileage]/1000).'k miles'; $vehicle = "'".substr($row['year'], -2)." ".$row['make']." ".$row['model']." ".$row['trim']; $thumb = '<a href="apply.php" onclick="return hs.htmlExpand(this, { objectType: \'ajax\', contentId: \'highslide-html-8\' } )" class="highslide"><div class="Flag" style="background: url(inventory/'.$row[category].'/'.$row['stock'].'s.jpg);"><span class="'.$flagClass.'">'.$flagText.'</span></div></a>'; $display = '<td class="capOff" onmouseout="this.className=\'capOff\'" onmouseover="this.className=\'capOver\'"><div align="center"><table width="100%"><tr><td class="capThmb">'.$thumb.'</td></tr><tr><td class="capTitle">'.$vehicle.'</td></tr><tr><td align="center">'.$trans.' / '.$mileage.'</td></tr><tr><td class="capPrc">'.$asking.'</td></tr><tr><td class="capComp"><input type="checkbox" class="capComp" onClick="javascript:checkChecked('.$stock.');" id="c'.$stock.'" name="c'.$stock.'"> Compare</td></tr></table></div></td>'; if($x == '5') {echo ' </tr>'; $x = 0;} $row_count++; if($_GET['pgPer']); switch($_GET['pgPer']) { default: $perPg = '15 | <a href="search.php?'.$catLnk.'&view=Caption'.$vehMkeLnk.$vehMdlLnk.$bodyLnk.$trnsLnk.$typeLnk.$fltrLnk.$priceLnk.'&pgPer=30">30</a> | <a href="search.php?'.$catLnk.'&view=Caption'.$vehMkeLnk.$vehMdlLnk.$bodyLnk.$trnsLnk.$typeLnk.$fltrLnk.$priceLnk.'&pgPer=45">45</a>'; break; case '30': $perPg = '<a href="search.php?'.$catLnk.'&view=Caption'.$vehMkeLnk.$vehMdlLnk.$bodyLnk.$trnsLnk.$typeLnk.$fltrLnk.$priceLnk.'&pgPer=15">15</a> | 30 | <a href="search.php?'.$catLnk.'&view=Caption'.$vehMkeLnk.$vehMdlLnk.$bodyLnk.$trnsLnk.$typeLnk.$fltrLnk.$priceLnk.'&pgPer=45">45</a>'; break; case '45': $perPg = '<a href="search.php?'.$catLnk.'&view=Caption'.$vehMkeLnk.$vehMdlLnk.$bodyLnk.$trnsLnk.$typeLnk.$fltrLnk.$priceLnk.'&pgPer=15">15</a> | <a href="search.php?'.$catLnk.'&view=Caption'.$vehMkeLnk.$vehMdlLnk.$bodyLnk.$trnsLnk.$typeLnk.$fltrLnk.$priceLnk.'&pgPer=30">30</a> | 45'; break; } } elseif ($_GET['view'] == "Picture") { $thumb = '<a href="#" onclick="return hs.htmlExpand(this, { contentId: \'http://www.carcityofdanbury.com/include/popups/balloon.php?view=Picture&stock='.$stock.'\'} )" class="highslide"><div class="Flag" style="background: url(inventory/'.$row[category].'/'.$row['stock'].'s.jpg);"><span class="'.$flagClass.'">'.$flagText.'</span></div></a>'; $display = "<td class=\"thmbOff\" onmouseout=\"this.className='thmbOff'\" onmouseover=\"this.className='thmbOver'\"><div align=\"center\"><table><tr><td class=\"thmbThmb\">$thumb</td></tr></table></div></td>"; if($x == '7') {echo " </tr>"; $x = 0;} $row_count++; if($_GET['pgPer']); switch($_GET['pgPer']) { default: $perPg = '35 | <a href="search.php?'.$catLnk.'&view=Picture'.$vehMkeLnk.$vehMdlLnk.$bodyLnk.$trnsLnk.$typeLnk.$fltrLnk.$priceLnk.'&pgPer=70">70</a>'; break; case '70': $perPg = '<a href="search.php?'.$catLnk.'&view=Picture'.$vehMkeLnk.$vehMdlLnk.$bodyLnk.$trnsLnk.$typeLnk.$fltrLnk.$priceLnk.'&pgPer=35">35</a> | 70'; break; } } else { $thumb = '<div class="Flag" style="background: url(inventory/'.$row[category].'/'.$row['stock'].'s.jpg);" onmouseover="showtrail(\''.$large.'\',\'\',\'\',\'\',\'\',\'1\',380,1);" onmouseout="hidetrail();"><span class="'.$flagClass.'">'.$flagText.'</span></div>'; $mileage = floor($row[mileage]/1000); $vehicle = $row['year']." ".$row['make']." ".$row['model']." ".$row['trim']; $link = 'onClick="document.location.href=\'inventory_view.php?stock='.$stock.'\'"'; $display = '<table class="'.$class.'" onmouseout="this.className=\''.$class.'\'" onmouseover="this.className=\'listOn\'"><tr><td class="listComp" rowspan="2"><input class="listComp" onClick="javascript:checkChecked('.$stock.');" type="checkbox" id="c'.$stock.'" name="c'.$stock.'"><br /><img src="images/Common/Icons/Compare.gif" /></td><td class="listThmb" rowspan="2" '.$link.'><div id="capt"></div>'.$thumb.'</td><td class="listText" width="260" '.$link.'>'.$vehicle.'</td><td class="listText" width="80" '.$link.'>'.$mileage.'</td><td class="listText" width="95" '.$link.'>'.$engine.'</td><td class="listText" width="85" '.$link.'>'.$trans.'</td><td class="listText" width="75" '.$link.'><span class="red">'.$asking.'</a></td><td class="listCrfx" '.$link.'>'.$carfax.'</td></tr><tr><td class="listFtrs" colspan="8" '.$link.'>'.$fuel.' '.$drive.' '.$features_string.'</td></tr></table>'; $row_count++; if($_GET['pgPer']); switch($_GET['pgPer']) { default: $perPg = '8 | <a href="search.php?'.$catLnk.'&view=List'.$vehMkeLnk.$vehMdlLnk.$bodyLnk.$trnsLnk.$typeLnk.$fltrLnk.$priceLnk.'&pgPer=16">16</a> | <a href="search.php?'.$catLnk.'&view=List'.$vehMkeLnk.$vehMdlLnk.$bodyLnk.$trnsLnk.$typeLnk.$fltrLnk.$priceLnk.'&pgPer=24">24</a>'; break; case '16': $perPg = '<a href="search.php?'.$catLnk.'&view=List'.$vehMkeLnk.$vehMdlLnk.$bodyLnk.$trnsLnk.$typeLnk.$fltrLnk.$priceLnk.'&pgPer=8">8</a> | 16 | <a href="search.php?'.$catLnk.'&view=List'.$vehMkeLnk.$vehMdlLnk.$bodyLnk.$trnsLnk.$typeLnk.$fltrLnk.$priceLnk.'&pgPer=24">24</a>'; break; case '24': $perPg = '<a href="search.php?'.$catLnk.'&view=List'.$vehMkeLnk.$vehMdlLnk.$bodyLnk.$trnsLnk.$typeLnk.$fltrLnk.$priceLnk.'&pgPer=8">8</a> | <a href="search.php?'.$catLnk.'&view=List'.$vehMkeLnk.$vehMdlLnk.$bodyLnk.$trnsLnk.$typeLnk.$fltrLnk.$priceLnk.'&pgPer=16">16</a> | 24'; break; } } if (!$row_count) { echo '<div style="font-size: 17px; padding-top: 30px"><b>Sorry, no vehicles matchining your criteria were found.<p>Try <a href="inventory_request.php">Request-A-Car</a> to get exactly what you\'re looking for.</b></div>'; } else { echo $display; } ?> Link to comment https://forums.phpfreaks.com/topic/90151-if-row_count-not-working/ Share on other sites More sharing options...
DBookatay Posted February 9, 2008 Author Share Posted February 9, 2008 FYI: Ive tried if ($row_count =="0") if ($row_count >"0") as well... Link to comment https://forums.phpfreaks.com/topic/90151-if-row_count-not-working/#findComment-462278 Share on other sites More sharing options...
corillo181 Posted February 9, 2008 Share Posted February 9, 2008 i spot row_count at this line $class = ($row_count % 2) ? $class1 : $class2; where is row_count getting its value from? Link to comment https://forums.phpfreaks.com/topic/90151-if-row_count-not-working/#findComment-462279 Share on other sites More sharing options...
DBookatay Posted February 9, 2008 Author Share Posted February 9, 2008 $class1 = "listW"; $class2 = "listB"; $row_count = 0; Basically what I am trying to do is this is a search results page, if no results are found, I want the message "Sorry... yada yada yada" to appear. (If that helps!) Link to comment https://forums.phpfreaks.com/topic/90151-if-row_count-not-working/#findComment-462281 Share on other sites More sharing options...
corillo181 Posted February 9, 2008 Share Posted February 9, 2008 well if row_count is going to have a number you should use if($row_count <1) yada yada if is going to use a string use if(empty($row_count)) yada yada Link to comment https://forums.phpfreaks.com/topic/90151-if-row_count-not-working/#findComment-462283 Share on other sites More sharing options...
DBookatay Posted February 9, 2008 Author Share Posted February 9, 2008 http://www.carcityofdanbury.com/search.php?&view=Caption&vehMke=Ferrari Still no results... Link to comment https://forums.phpfreaks.com/topic/90151-if-row_count-not-working/#findComment-462284 Share on other sites More sharing options...
DBookatay Posted February 9, 2008 Author Share Posted February 9, 2008 Anyone else have any ideas? Link to comment https://forums.phpfreaks.com/topic/90151-if-row_count-not-working/#findComment-462613 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.