Help with this.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
240sxforums.com
Forum Newbie
Posts: 4
Joined: Sun Feb 16, 2003 6:44 pm
Location: Kennesaw

Help with this.

Post by 240sxforums.com »

Sorry everyone i am learning. Long way to go too. Take a look at this code for me, i want to turn off or remove the new.gif. In other words i dont want that image to show up at all.

Code: Select all

<?
	require( "common.php" );
	dbConnect();

	if( isset( $cat ) )
	&#123;
		$result = mysql_query( "SELECT cat_name, root_id FROM category WHERE papa_id=$cat ORDER BY add_date" ) or error( mysql_error() );
		if( mysql_num_rows( $result ) != 0 )
		&#123;
			displayHeader( "$ADVT_NAME > " . displayLocationNoLink( $cat ) );
			include( "menu.php" );
			echo "\n<div align="center">\n";
			echo "  <center>\n";
			echo "  <table border="0" cellpaddig="0" cellspacing="0" width="700">\n";
			echo "    <tr>\n";
			echo "      <td height="20">\n";
			displayLocation( $cat ) . "\n";
			echo "      </td>\n";
			echo "    </tr>\n";
			echo "  </table>\n";
			echo "  </center>\n";
			echo "</div>\n";
			echo "<div align="center">\n";
			echo "  <center>\n";
			echo "  <table border="0" cellpaddig="0" cellspacing="0" width="700">\n";
			echo "    <tr>\n";
			echo "      <td>\n";
			while( $row = mysql_fetch_array( $result ) )
				echo "      <li><a href="$PHP_SELF?cat=&#123;$row&#1111;'root_id']&#125;">&#123;$row&#1111;'cat_name']&#125;</a>(" . findTotalAds( $row&#1111;'root_id'] ) . ")</li>\n";
			echo "      </td>\n";
			echo "    </tr>\n";
			echo "  </table>\n";
			echo "  </center>\n";
			echo "</div>\n";
			displayMoreCat();
		&#125;
		else
		&#123;
			$time = time();
			$maxAds = 10;
			$result = mysql_query( "SELECT cat_id FROM ads WHERE cat_id=$cat AND exp_date>$time " ) or error( mysql_error() );
			$totalAds = mysql_num_rows( $result );
			if( $totalAds <= $maxAds ) $totalPages = 1;
			elseif( $totalAds % $maxAds == 0 ) $totalPages = $totalAds / $maxAds;
			else $totalPages = ceil( $totalAds / $maxAds );
			if( !isset( $page ) ) $page = 1;
			elseif( $page > $totalPages || $page < 1 ) $page = 1;
			if( $totalAds == 0 ) $adsStart = 0;
			else $adsStart = $maxAds * $page - $maxAds + 1;
			if( $page == $totalPages ) $adsEnd = $totalAds;
			else $adsEnd = $maxAds * $page;
			$prePage = $page - 1;
			$nextPage = $page + 1;
			$initAds = $maxAds * $page - $maxAds;

			$result = mysql_query( "SELECT * FROM ads WHERE cat_id=$cat AND exp_date>$time ORDER BY add_date DESC LIMIT $initAds, $maxAds" ) or error( mysql_error() );

			displayHeader( "$ADVT_NAME > " . displayLocationNoLink( $cat ) );
			include( "menu.php" );
			echo "\n<div align="center">\n";
			echo "  <center>\n";
			echo "  <table border="0" cellpaddig="0" cellspacing="0" width="700" height="20">\n";
			echo "    <tr>\n";
			echo "      <td>\n";
			displayLocation( $cat ) . "\n";
			echo "      </td>\n";
			echo "    </tr>\n";
			echo "  </table>\n";
			echo "  </center>\n";
			echo "</div>\n";
			echo "<div align="center">\n";
			echo "  <center>\n";
			echo "  <table border="0" cellpaddig="0" cellspacing="0" width="700">\n";
			echo "    <tr class="frame">\n";
			echo "      <td width="20" height="25" align="right"><font color="#FFFFFF"><b>#</b></font></td>\n";
			echo "      <td width="450" height="25" align="left"><font color="#FFFFFF"><b>Subject</b></font></td>\n";
			echo "      <td width="80" height="25" align="center"><font color="#FFFFFF"><b>Added on</b></font></td>\n";
			echo "      <td width="75" height="25" align="center"><font color="#FFFFFF"><b>Photo</b></font></td>\n";
			echo "      <td width="75" height="25" align="center"><font color="#FFFFFF"><b>Detail</b></font></td>\n";
			echo "    </tr>\n";
			echo "    <tr>\n";
			echo "      <td width="100%" height="1" colspan="5" bgcolor="#FFFFFF"></td>\n";
			echo "    </tr>\n";
			if( $totalAds == 0 )
			&#123;
				echo "    <tr>\n";
				echo "      <td width="100%" height="25" colspan="5" align="center"><font size="4">No ads currently listed in this category</font>\n";
				echo "    </tr>\n";
			&#125;
			$i = $adsStart;
			while( $row = mysql_fetch_array( $result ) )
			&#123;
				echo "    <tr class="detail">\n";
				echo "      <td height="25" align="right">&#123;$i&#125;.</td>\n";
				echo "      <td height="25">" . substr( $row&#1111;'subject'], 0, 50 );
				if( strlen( $row&#1111;'subject'] ) > 50 ) echo "... ...";
				echo "</td>\n";
				echo "      <td height="25" align="center"><small>" . date( "m/d/y h:i", $row&#1111;'add_date'] ) . "</small></td>\n";
				echo "      <td height="25" align="center">";
				$photo = mysql_query( "SELECT photo_id FROM photo WHERE ad_id=&#123;$row&#1111;'ad_id']&#125;" ) or error( mysql_error() );
				if( mysql_num_rows( $photo ) >= 1 ) echo "Yes";
				else echo "No";
				echo "</td>\n";
				echo "      <td height="25" align="center"><a href="detail.php?cat=$cat&de=&#123;$row&#1111;'ad_id']&#125;">Detail</a></td>\n";
				echo "    </tr>\n";
				echo "    <tr>\n";
				echo "      <td></td>\n";
				echo "      <td colspan="4">" . substr( $row&#1111;'descript'], 0, 300 );
				if( strlen( $row&#1111;'descript'] ) > 300 ) echo "... ...";
				echo "</td>\n";
				echo "    </tr>\n";
				echo "    <tr>\n";
				echo "      <td colspan="5" align="right"><a href="detail.php?cat=$cat&de=&#123;$row&#1111;'ad_id']&#125;"><small>More...</small></a></td>\n";
				echo "    </tr>\n";
				$i++;
			&#125;
			echo "    <tr>\n";
			echo "      <td width="100%" height="1" colspan="5" bgcolor="#808080"></td>\n";
			echo "    </tr>\n";
			echo "    <tr>\n";
			echo "      <td width="100%" height="20" colspan="5"><small>Found <b>$totalAds</b> listings, now displaying <b>$adsStart</b> - <b>$adsEnd</b></small></td>\n";
			echo "    </tr>\n";
			echo "  </table>\n";
			echo "  </center>\n";
			echo "</div>\n";
			echo "<p align="center">";
			if( $page != 1 ) echo "<a href="$PHP_SELF?cat=$cat&page=$prePage"><<</a> ";
			for( $i = 1; $i <= $totalPages; $i++ )
			&#123;
				if( $page == $i ) echo "<b>$i</b> ";
				else echo "<a href="$PHP_SELF?cat=$cat&page=$i">$i</a> ";
			&#125;
			if( $page != $totalPages ) echo " <a href="$PHP_SELF?cat=$cat&page=$nextPage">>></a>";
			echo "</p>\n";
			echo "<div align="center">\n";
			echo "  <center>\n";
			echo "  <table border="0" cellpaddig="0" cellspacing="0" width="700">\n";
			echo "    <tr>\n";
			echo "      <td align="center">\n";
			echo "      <form method="post" action="search.php?action=search">\n";
			echo "      <b>Search <input type="text" name="keywords" size="20" maxlength="100">\n";
			echo "      <input type="submit" value="  Go  "></b>\n";
			echo "      </form></td>\n";
			echo "    </tr>\n";
			echo "  </table>\n";
			echo "  </center>\n";
			echo "</div>\n";
		&#125;
	&#125;
	else
	&#123;
		$cats = mysql_query( "SELECT cat_name, root_id FROM category WHERE papa_id='' ORDER BY add_date DESC" ) or error( mysql_error() );
		displayHeader( $ADVT_NAME );
		if( mysql_num_rows( $cats ) == 0 )
			echo "<p align="center"><font size="4">No Category Found</font></p>\n";
		else
		&#123;
			include( "menu.php" );
			echo "\n<div align="center">\n";
			echo "  <center>\n";
			echo "  <table border="0" cellpaddig="0" cellspacing="0" width="700">\n";
			$i = 1;
			while( $catsrow = mysql_fetch_array( $cats ) )
			&#123;
				$subcats = mysql_query( "SELECT cat_name, root_id, add_date FROM category WHERE papa_id=&#123;$catsrow&#1111;'root_id']&#125; ORDER BY add_date DESC" ) or error( mysql_error() );
				echo $i % 2 == 1 ? "    <tr>\n" : "";
				echo "      <td width="50%">";
				echo "<a href="$PHP_SELF?cat=&#123;$catsrow&#1111;'root_id']&#125;"><b>&#123;$catsrow&#1111;'cat_name']&#125;</b></a>(" . findTotalAds( $catsrow&#1111;'root_id'] ) . ")<br>\n";
				$num = mysql_num_rows( $subcats );
				$j = 1;
				$time = time();
				while( $subcatsrow = mysql_fetch_array( $subcats ) )
				&#123;
					$subcatsrow&#1111;'add_date'] > $time - 3600 * 24 * 3 ? $isnew = "<img src="new.gif" align="top">" : $isnew = "";
					if( $num != $j )
						echo "      <a href="$PHP_SELF?cat=&#123;$subcatsrow&#1111;'root_id']&#125;">&#123;$subcatsrow&#1111;'cat_name']&#125;</a>&#123;$isnew&#125;, \n";
					else echo "      <a href="$PHP_SELF?cat=&#123;$subcatsrow&#1111;'root_id']&#125;">&#123;$subcatsrow&#1111;'cat_name']&#125;</a>$isnew\n";
					$j++;
				&#125;
				echo "      <br> \n";
				echo "      </td>\n";
				echo $i % 2 == 0 ? "    </tr>\n" : "";
				$i++;
			&#125;
			echo "  </table>\n";
			echo "  </center>\n";
			echo "</div>\n";
		&#125;
	&#125;
	displayFooter();
?>
How do i make that go away with out causing an error? Thanks everyone.[/quote]
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

That is a lot of code - which bit do you want us to look at specifically?

Mac
240sxforums.com
Forum Newbie
Posts: 4
Joined: Sun Feb 16, 2003 6:44 pm
Location: Kennesaw

Post by 240sxforums.com »

the very last part. there is a line containing new.gif and i want to eliminate the image or make it not show up on the main page.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

I guess you can just change:

Code: Select all

$subcatsrow['add_date'] > $time - 3600 * 24 * 3 ? $isnew = "<img src="new.gif" align="top">" : $isnew = ""; 
               if( $num != $j ) 
                  echo "      <a href="$PHP_SELF?cat={$subcatsrow['root_id']}">{$subcatsrow['cat_name']}</a>{$isnew}, \n"; 
               else echo "      <a href="$PHP_SELF?cat={$subcatsrow['root_id']}">{$subcatsrow['cat_name']}</a>$isnew\n"; 
               $j++;
to

Code: Select all

if( $num != $j ) 
                  echo "      <a href="$PHP_SELF?cat={$subcatsrow['root_id']}">{$subcatsrow['cat_name']}</a>, \n"; 
               else echo "      <a href="$PHP_SELF?cat={$subcatsrow['root_id']}">{$subcatsrow['cat_name']}</a>\n"; 
               $j++;
Mac
Post Reply