Jump to content

"if (!$row_count)" Not working...


DBookatay

Recommended Posts

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.