473,597 Members | 2,726 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Styling php generated menu items

3 New Member
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 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!
Jun 2 '07 #1
2 1711
adamalton
93 New Member
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 New Member
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?


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
6823
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 this be done using style sheets? -- - Yours truly, Pete Collinson
5
2579
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 the outer list items? I can't get it to work using descendant selectors. Thanks in advance, John
2
3874
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 http://home.pacific.net.sg/~jacksony ? (the drop down bar could not work at www.apchosting.net but can drop at home.pacific.net.sg. I suspect it is a server problem but was told it is not possible, therefore assuming it is a client script problem? the script works last time...
8
10083
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 a text box has 6 items, undo, cut, copy, paste, delete and select all. I would like to add one additional paste menu that opens a new sub menu with several optional text items that could be pasted. The items would be populated by my program but...
6
3219
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 when viewing it in the source code, however, because it doesn't show the complete path to the file. (I'm talking about Internet Explorer click View, click source code.)
3
1718
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 is just sitting there, taking up space ;)) thanks, -Steve
1
5247
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 New Files/Working Files, there are more sub menu items, respectively. All those menu items are enabled at beginning.
3
1445
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 the <lielements. Anyone know why and/or how to fix it?
5
1299
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 possible to apply an adapter to this control that could make the generated html a great deal easier to style (although I haven't seen such an adapter myself yet). Could anyone help me / point me in the right direction? Thanks
0
8281
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8381
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
6706
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5847
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5437
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3893
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3937
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2409
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1245
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.