473,386 Members | 1,621 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Styling php generated menu items

3
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:
Expand|Select|Wrap|Line Numbers
  1. <?
  2. $sql = "select * from masterCategory";
  3. $masterResult = mysql_query($sql);
  4. while ($mr = mysql_fetch_array($masterResult)){
  5.     echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
  6.     echo "<font color=\"#FFFFFF\" size=\"+1\">".$mr["name"]."</font><br>";
  7.     $sql = "SELECT * FROM category where masterid = ".$mr["id"]." ORDER BY id";
  8.     $result = mysql_query($sql);
  9.     While($r = mysql_fetch_array($result)){
  10.         echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
  11.         echo "<A href=\"preview.php?cat=".$r["id"]."\">".$r["name"]."</A><br>";
  12.     }
  13.     echo "<br>";
  14. }
  15.  
  16.  
  17. ?>
[Please use CODE tags when posting source code. Thanks! --pbmods]

The client determines the mastercategories (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!
Jun 2 '07 #1
2 1698
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!)
Jun 2 '07 #2
vkfmj
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($sql);
while ($mr = mysql_fetch_array($masterResult)){

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($sql);
While($r = mysql_fetch_array($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?


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!)
Jun 4 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Peter Collinson | last post by:
Hi... Is there any way to style a List Item a different color and size than the <LI> in an Ordered List? I'd like a red super-script number and a dark blue text in a page's footnotes. And...
5
by: John Topley | last post by:
Hi, I'm doing some work in an intranet environment where I'm forced to use IE 6.0. Is it possible to style (unordered) nested lists so that the inner list items have a different appearance to...
2
by: Jackson Yap | last post by:
can someone kind enough to help me look at the attached html and js file? Why is it that the javascript menu could not work at www.apchosting.net but could work at...
8
by: Dennis C. Drumm | last post by:
Is there a way to modify the standard context menu shown when someone right clicks in a windows text box and that would work for all open windows applications? The standard context menu for...
6
by: Sandy | last post by:
Hello - I have a book that illustrates pulling menu items from a Sql Server table into an ascx via a stored procedure. Is this something that is done in the real world? I do like the effect...
3
by: Steve Richter | last post by:
how can I get asp.net to not show the right arrow symbol that appears alongside top level menu items which contain lower level menu items? ( maybe not an arrow, more like a solid triangle, that...
1
by: =?Utf-8?B?QW5kcmV3?= | last post by:
Hi, friends, I am using C#.net 2005 to create a windows application. It has menu items, such as File, etc. Under File, there are more menu items, such as New Files, Working Files, etc. Under...
3
by: Ian Hobson | last post by:
Hi guys, I am trying to build a simple menu. See http://jupiter.ianhobson.co.uk/msc/index.htm It looks how I want in FF and Safari, but IE6 is not playing nice. It is adding space between...
5
by: GeoffreyD | last post by:
Hi I am working together with an artist who is familiar with CSS and HTML, but we seem to be struggling with some of the more intricate details of the Menu control. From what I understand, it is...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.