Jump to content

Desprate - Need help!


Snowhawk

Recommended Posts

I am so greeen at this I'm sprouting weeds!

Would like to get someone to at least look at this for me.

I am having a hard time getting the third category to show up. 

Don't know what I am missing here.

 

I have this:

Real Estate

      Rentals

          Comercial

          Residential

      Sales

 

Rentals shows up but Comercial & Residential doesn't.

Here is the script:

 

<?

     

  include('header.php');

 

  //Print bread crumb

  echo "You are here: <a href='index.php'>Home</a> » <a href='view_all.php'>All Categories</a>";

 

  echo "<h4>All Categories</h4>";

  echo "<h5><center>If you need a category made contact Webmaster.</h5></center>";

 

  //Fetch all Father categories order by title asc

  $node = new sqlNode();

  $node->table = "categories";

  $node->select = "*";

  $node->where = "where FatherID = 0";

  $node->orderby="order by Title asc";

 

  if( ($result = $mysql->select($node)) === false )

      die($mysql->debugPrint());

     

  $num_of_rows = mysql_num_rows($result);

 

  echo "<table border=0 align=center cellpadding=2 width=98%>";

  echo "<tr>";

  echo "<td valign=top>";

 

  $count = 0;

  $break = ceil($num_of_rows/2);

  while( $category = mysql_fetch_assoc($result) ){

      echo "<p>";

      echo "<a href='browse.php?fatherID=".$category['ID']."'>".$category['Title'];

      if($settings['ShowNumAds'] == 'yes'){

            $number_of_ads = fetchNumAds(intval($category['ID']),$mysql) + fetchSubCats(intval($category['ID']),$mysql);

            if( ($number_of_ads > 0) || ($settings['ShowGTZero'] == 'yes') )

              echo " (" . $number_of_ads . ")";       

      }             

      echo "</a><br/>";

     

      $node = new sqlNode();

      $node->table = "categories";

      $node->select = "*";

      $node->where = "where FatherID = ".intval($category['ID']);

      $node->orderby="order by Title asc";

     

      if( ($subRS = $mysql->select($node)) === false )

        die($mysql->debugPrint());

       

      $num_subcats = mysql_num_rows($subRS);

      $break2 = ceil($num_subcats/2);

      $count2 = 1;

     

      echo "<table border=0>";

      echo "<tr>";

      echo "<td valign=top>";

      while( $subcat = mysql_fetch_assoc($subRS) ){

 

        echo "<table border=0 cellspacing=0 sellpadding=0>";

        echo "<tr>";

        echo "<td>";

        echo "<a href='browse.php?fatherID=".$subcat['ID']."' title='".$subcat['Title']."'>";

        echo "<img src='icons_folder/folder.jpg' border=0 alt='".$subcat['Title']."' >";

        echo "</a>";

        echo "</td>";

        echo "<td>";

        echo "<span class='subCat'><a href='browse.php?fatherID=".$subcat['ID']."'>".$subcat['Title']."</a>";

        if($settings['ShowNumAds'] == 'yes'){

            $number_of_ads = fetchNumAds(intval($subcat['ID']),$mysql) + fetchSubCats(intval($subcat['ID']),$mysql);

            if( ($number_of_ads > 0) || ($settings['ShowGTZero'] == 'yes') )

              echo " (" . $number_of_ads . ")";       

        }

        echo "</span>";

        echo "</td>";

        echo "</tr>";

        echo "</table>";

       

        if($count2 == $break2){

            echo "</td><td valign=top>";

        }

        $count2++;

      }

      echo "</td>";

      echo "</tr>";

      echo "</table>"; 

     

  }

 

  echo "</td>";

  echo "</tr>";

  echo "</table>";

 

  include('footer.php');

 

?>     

     

Thank you in advance for your expertise in this field.

 

Submit a correction or amendment below (click here to make a fresh posting)

After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

 

Syntax highlighting:NoneBashCC++HTMLJavaJavascriptLuaPerlPHPPythonRuby----------------------------NoneABAPActionScriptAdaApache Log FileAppleScriptASM (NASM based)ASPAutoItBashBlitz BasicBNFCC for MacsCAD DCLCAD LispC++C#ColdFusionCSSDDelphiDiffDOSEiffelErlangFortranFreeBasicGeneroGame MakerGroovyHaskellHTMLIDLINIInno ScriptJavaJavascriptLatexLispLuaLinden Scripting LanguageMatLabM68000 AssemblerMPASMmIRCMySQLNullSoft InstallerObjective COCamlOpenoffice.org BASICOracle 8PascalPerlPHPPL/SQLPythonQBasic/QuickBASICRailsRobotsRubySchemeSmalltalkSmartySQLTCLunrealScriptVisualBasicVB.NETVisualFoxProXMLZ80 Assembler

 

To highlight particular lines, prefix each line with @@

<?

     

  include('header.php');

 

  //Print bread crumb

  echo "You are here: <a href='index.php'>Home</a> » <a href='view_all.php'>All Categories</a>";

 

  echo "<h4>All Categories</h4>";

  echo "<h5><center>If you need a category made contact Webmaster.</h5></center>";

 

  //Fetch all Father categories order by title asc

  $node = new sqlNode();

  $node->table = "categories";

  $node->select = "*";

  $node->where = "where FatherID = 0";

  $node->orderby="order by Title asc";

 

  if( ($result = $mysql->select($node)) === false )

      die($mysql->debugPrint());

     

  $num_of_rows = mysql_num_rows($result);

 

  echo "<table border=0 align=center cellpadding=2 width=98%>";

  echo "<tr>";

  echo "<td valign=top>";

 

  $count = 0;

  $break = ceil($num_of_rows/2);

  while( $category = mysql_fetch_assoc($result) ){

      echo "<p>";

      echo "<a href='browse.php?fatherID=".$category['ID']."'>".$category['Title'];

      if($settings['ShowNumAds'] == 'yes'){

            $number_of_ads = fetchNumAds(intval($category['ID']),$mysql) + fetchSubCats(intval($category['ID']),$mysql);

            if( ($number_of_ads > 0) || ($settings['ShowGTZero'] == 'yes') )

              echo " (" . $number_of_ads . ")";       

      }             

      echo "</a><br/>";

     

      $node = new sqlNode();

      $node->table = "categories";

      $node->select = "*";

      $node->where = "where FatherID = ".intval($category['ID']);

      $node->orderby="order by Title asc";

     

      if( ($subRS = $mysql->select($node)) === false )

        die($mysql->debugPrint());

       

      $num_subcats = mysql_num_rows($subRS);

      $break2 = ceil($num_subcats/2);

      $count2 = 1;

     

      echo "<table border=0>";

      echo "<tr>";

      echo "<td valign=top>";

      while( $subcat = mysql_fetch_assoc($subRS) ){

 

        echo "<table border=0 cellspacing=0 sellpadding=0>";

        echo "<tr>";

        echo "<td>";

        echo "<a href='browse.php?fatherID=".$subcat['ID']."' title='".$subcat['Title']."'>";

        echo "<img src='icons_folder/folder.jpg' border=0 alt='".$subcat['Title']."' >";

        echo "</a>";

        echo "</td>";

        echo "<td>";

        echo "<span class='subCat'><a href='browse.php?fatherID=".$subcat['ID']."'>".$subcat['Title']."</a>";

        if($settings['ShowNumAds'] == 'yes'){

            $number_of_ads = fetchNumAds(intval($subcat['ID']),$mysql) + fetchSubCats(intval($subcat['ID']),$mysql);

            if( ($number_of_ads > 0) || ($settings['ShowGTZero'] == 'yes') )

              echo " (" . $number_of_ads . ")";       

        }

        echo "</span>";

        echo "</td>";

        echo "</tr>";

        echo "</table>";

       

        if($count2 == $break2){

            echo "</td><td valign=top>";

        }

        $count2++;

      }

      echo "</td>";

      echo "</tr>";

      echo "</table>"; 

     

  }

 

  echo "</td>";

  echo "</tr>";

  echo "</table>";

 

  include('footer.php');

 

?>     

     

Thank you in advance for your expertise in this field. snowhawk(at)mia.net

Link to comment
https://forums.phpfreaks.com/topic/152596-desprate-need-help/
Share on other sites

OK can't be arsed at looking at what you have done - its a mess...

 

2 things

 

1. break out of php for outputting mark up . Its a nightmare to manage if you need to change mark up..

 

<?php
..... lots of code...
         echo "<table border=0 cellspacing=0 sellpadding=0>";
         echo "<tr>";
         echo "<td>";
         echo "<a href='browse.php?fatherID=".$subcat['ID']."' title='".$subcat['Title']."'>";
         echo "<img src='icons_folder/folder.jpg' border=0 alt='".$subcat['Title']."' >";

.....
?>

 

should be

<?php
..... lots of code...
?>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
  <a href="browse.php?fatherID=<?php echo $subcat['ID']; ?>"' title="<?php echo $subcat['Title']; ?>">
<img src="icons_folder/folder.jpg" border="0" alt="<?php echo $subcat['Title']; ?>" >
<?php
....
?>

 

this helps you separate you code and presentation a bit better (no MVC but hey its your code we are dealing with here ;))

 

2 recursive actions require recursive functions... http://devzone.zend.com/node/view/id/1235

 

Link to comment
https://forums.phpfreaks.com/topic/152596-desprate-need-help/#findComment-801462
Share on other sites

@ ToonMariner....  ehhh...

 

<?php
..... lots of code...
?>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
  <a href="browse.php?fatherID=<?php echo $subcat['ID']; ?>"' title="<?php echo $subcat['Title']; ?>">
<img src="icons_folder/folder.jpg" border="0" alt="<?php echo $subcat['Title']; ?>" >
<?php
....
?>

 

^ not optimal...

 

The following is preferable...

 

<?php
..... lots of code...

echo '
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
  <a href="browse.php?fatherID=', $subcat['ID'], '" title="', $subcat['Title'], '">
<img src="icons_folder/folder.jpg" border="0" alt="', $subcat['Title'], '" />';

....
?>

Link to comment
https://forums.phpfreaks.com/topic/152596-desprate-need-help/#findComment-801469
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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