Styling php generated menu items

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vkfmj
    New Member
    • Jun 2007
    • 3

    Styling php generated menu items

    I am bidding on a project that was coded completely in php with basic tables containing the data. My job is to make the site look pretty. I am a designer and I can *read* the php, but am not the person to generate or tweak code.

    I can generate the CSS styling to do the bulk of the design, but am running in circles trying to figure out how to style this output successfully:
    [code=php]
    <?
    $sql = "select * from masterCategory" ;
    $masterResult = mysql_query($sq l);
    while ($mr = mysql_fetch_arr ay($masterResul t)){
    echo "&nbsp;&nbsp;&n bsp;&nbsp;&nbsp ;";
    echo "<font color=\"#FFFFFF \" size=\"+1\">".$ mr["name"]."</font><br>";
    $sql = "SELECT * FROM category where masterid = ".$mr["id"]." ORDER BY id";
    $result = mysql_query($sq l);
    While($r = mysql_fetch_arr ay($result)){
    echo "&nbsp;&nbsp;&n bsp;&nbsp;&nbsp ;";
    echo "<A href=\"preview. php?cat=".$r["id"]."\">".$r["name"]."</A><br>";
    }
    echo "<br>";
    }


    ?>[/code]

    [Please use CODE tags when posting source code. Thanks! --pbmods]

    The client determines the mastercategorie s (3 at the moment) and there are varying numbers of names under each mastercategory.

    Here is the way I would like it to look:

    Master 1
    some1
    some2
    some 3
    Master 2
    some 1
    some 2
    some 3

    I can style the list once I learn how I can it recognize each piece of the list as generated by the php. I prefer not to do &nbsp inserts all over the place :>)

    My undying gratitude to you who can provide the solution!
  • adamalton
    New Member
    • Feb 2007
    • 93

    #2
    I don't fully understand what you're trying to do... do you want to put it all into a table? Or just have each name/link on a new line? What are all the &nbsp;s for? I know what they do, but surely they are just indenting everything?

    As far as I can see the data should get printed out like you said. Well actually like (indented by all the &nbsp;s):

    Master 1
    www.name1.com
    www.name2.com
    Master 2
    www.name1.com
    www.name2.com

    A quick explanation of your php code (not sure what *read* means!):
    Lines 1 and 2 get all of the master categories from your database.
    And then lines 4-12 say:
    for each one of the master categories -
    print lots of &nbsp; and print the category name.
    And then get from the database all of the records that match that category,
    and for each of the matching records
    print lots of &nbsp;
    and print the link for it.

    I hope something in that helps!...?
    (Ok, so that ddn't actually come out indented anyway!)

    Comment

    • vkfmj
      New Member
      • Jun 2007
      • 3

      #3
      The info that is produced now is the menu system for the site. When it displays now, (see www.refrazegame .com) the main headings are in white and the subcategories are a yellow. Body of text is black. I was able to do that much applying some CSS to the pages. The person who coded the pages, used the html code to insert spaces. I want this to be a list format styled with CSS but am unsure of how to "define" the subcategories as the php generates them. I left the "spaces" that the original coder put in to make the categories line up. I want to remove those and use pure CSS to say this is a list.

      Here is the current code:



      <ul><!--Attempt to use list function -->
      [PHP]<?
      echo "<li>";
      $sql = "select * from masterCategory" ;
      echo "</li>", "</ul>";
      $masterResult = mysql_query($sq l);
      while ($mr = mysql_fetch_arr ay($masterResul t)){

      echo "<font color=\"#FFFFFF \" size=\"+1\">".$ mr["name"]."</font><br>";
      echo "<ul>","<li >";
      $sql = "SELECT * FROM category where masterid = ".$mr["id"]." ORDER BY id";
      $result = mysql_query($sq l);
      While($r = mysql_fetch_arr ay($result)){

      echo "<A href=\"preview. php?cat=".$r["id"]."\">".$r["name"]."</A><br>";
      }

      echo"</li>";

      echo "<br>";
      }


      ?>
      [/PHP]</ul> <!-- moved the end of the listing AFTER the preview code -->

      But, using this method, I just get too many indents. Please see:
      listing go awry

      Do I just insert echo <li> </li> for each line of generated subcategories? I know I can keep playing with it until I find what works, but I was hoping to spend some time on the proposal :>)
      Am I making this too complicated?


      Originally posted by adamalton
      I don't fully understand what you're trying to do... do you want to put it all into a table? Or just have each name/link on a new line? What are all the &nbsp;s for? I know what they do, but surely they are just indenting everything?

      As far as I can see the data should get printed out like you said. Well actually like (indented by all the &nbsp;s):

      Master 1
      www.name1.com
      www.name2.com
      Master 2
      www.name1.com
      www.name2.com

      A quick explanation of your php code (not sure what *read* means!):
      Lines 1 and 2 get all of the master categories from your database.
      And then lines 4-12 say:
      for each one of the master categories -
      print lots of &nbsp; and print the category name.
      And then get from the database all of the records that match that category,
      and for each of the matching records
      print lots of &nbsp;
      and print the link for it.

      I hope something in that helps!...?
      (Ok, so that ddn't actually come out indented anyway!)

      Comment

      Working...