Page 1 of 1

Just a small, but pretty important need of help! :o

Posted: Mon Jul 19, 2010 5:56 pm
by deluxxmanx
Ok, so my main menu looks like this:

Image

How can I make the every first letter start at the same place? :?

here is my mainmenu.php

Code: Select all

<?php
global $db,$c,$ir, $set;
$hc=$set['hospital_count'];
$jc=$set['jail_count'];
$ec=$ir['new_events'];
$mc=$ir['new_mail'];
if($ir['hospital'])
{
  print "<a href='hospital.php'>Hospital ($hc)</a><br />
  <a href='inventory.php'>Inventory</a><br />";
}
elseif($ir['jail'])
{
  print "<a href='jail.php'>Dungeon ($jc)</a><br />";
}
else
{
  print "<img src='home.png' width='16' height='16' /></a><a href='index.php'>Home</a><br />
  <img src='link.png' width='16' height='16' /><a href='inventory.php'>Inventory</a><br />";
}
if($ec > 0) { print "<img src='cv.png' width='16' height='16' /><a href='events.php' style='font-weight: 800;'>Events ($ec)</a><br />"; }
else { print "<img src='cv.png' width='16' height='16' /><a href='events.php'>Events (0)</a><br />"; }
if($mc > 0) { print "<img src='email.png' width='16' height='16' /><a href='mailbox.php' style='font-weight: 800;'>Mailbox ($mc)</a><br />"; }
else { print "<img src='email.png' width='16' height='16' /><a href='mailbox.php'>Mailbox (0)</a><br />"; }
if($ir['jail'] and !$ir['hospital'])
{
  print "<a href='gym.php'>Dungeon Gym</a><br />
  <a href='hospital.php'>Hospital ($hc)</a><br />";
}
else if (!$ir['hospital'])
{
  print "<img src='world.png' width='16' height='16' /><a href='explore.php'>Village</a><br />
  <img src='bestseller.png' width='16' height='16' /><a href='gym.php'>Training</a><br />
  <img src='business-contact.png' width='16' height='16' /><a href='criminal.php'>Illegal Work</a><br />
  <img src='cost.png' width='16' height='16' /><a href='job.php'>Your Job</a><br />
  <img src='drawings.png' width='16' height='16' /><a href='education.php'>Skill Study</a><br />
  <img src='busy.png' width='16' height='16' /><a href='hospital.php'>Hospital</a><br />
  <img src='illustration.png' width='16' height='16' /><a href='jail.php'>Dungeon</a><br />";
}
else
{
  print "<a href='jail.php'>Dungoen ($jc)</a><br />";
}
print "<img src='networking.png' width='16' height='16' /><a href='chat.php'>Chat</a><br>";
print "<img src='milestone.png' width='16' height='16' /><a href='forums.php'>Forums</a><br />";
print "<img src='customers.png' width='16' height='16' /><a href='halloffame.php'>Hall Of Fame</a><br />";
if($ir['new_announcements'])
{
print "<img src='finished-work.png' width='16' height='16' /><a href='ann.php' style='font-weight: 800;'>Announcements ({$ir['new_announcements']})</a><br />";
}
else
{
print "<img src='finished-work.png' width='16' height='16' /><a href='ann.php'>Announcements (0)</a><br />";
}
print "
<img src='product-design.png' width='16' height='16' /><a href='newspaper.php'>Newspaper</a><br />
<img src='search.png' width='16' height='16' /><a href='search.php'>Search</a><br />";
if(!$ir['jail'] && $ir['gang'])
{
  print "<a href='yourgang.php'>Your Clan</a><br />";
}
if($ir['user_level'] > 1)
{
print "<hr />
<a href='staff.php'>Staff Panel</a><br />\n";



print "<hr /><b>Staff Online:</b><br />";
$q=$db->query("SELECT * FROM users WHERE laston>(unix_timestamp()-15*60) AND user_level>1 ORDER BY userid ASC");
while($r=$db->fetch_row($q))
{
$la=time()-$r['laston'];
$unit="secs";
if($la >= 60)
{
$la=(int) ($la/60);
$unit="mins";
}
if($la >= 60)
{
$la=(int) ($la/60);
$unit="hours";
if($la >= 24)
{
$la=(int) ($la/24);
$unit="days";
}
}
print "<a href='viewuser.php?u={$r['userid']}'>{$r['username']}</a> ($la $unit)<br />";
}
}
if($ir['donatordays'])
{
print "<hr />
<b>Donators Only</b><br />
<a href='friendslist.php'>Friends List</a><br />
<a href='blacklist.php'>Enemy List</a>";
}
print "<hr />
<img src='user.png' width='16' height='16' /><a href='viewuser.php?u={$ir['userid']}'>My Profile</a><br />
<img src='settings.png' width='16' height='16' /><a href='preferences.php'>Preferences</a><br />
<img src='pencil.png' width='16' height='16' /><a href='preport.php'>Player Report</a><br />
<img src='library.png' width='16' height='16' /><a href='helptutorial.php'>Help Tutorial</a><br />
<img src='limited-edition.png' width='16' height='16' /><a href='gamerules.php'>Game Rules</a><br />
<img src='logout.png' width='16' height='16' /><a href='logout.php'>Logout</a><br /><br />
<img src='full-time.png' width='16' height='16' /><br>Time is now<br />
";
echo date ('F j, Y')."<br />".date('g:i:s a');

?>

Re: Just a small, but pretty important need of help! :o

Posted: Mon Jul 19, 2010 8:58 pm
by Chris
You should try learn some HTML before making a big system like this in PHP.

The proper way to do this would be with an unorderd list (ul), and then make each bullet be the url of the img, this would be what the code would look like:

Code: Select all

<ul>
	<li style="list-style: url(home.png);"><a href="index.php">Home</a></li>
	<li style="list-style: url(link.png);"><a href="inventory.php">Inventory</a></li>
	<li style="list-style: url(cv.png);"><a href="events.php">Events (0)</a></li>
	<li style="list-style: url(email.png);"><a href="mailbox.php">Mailbox (0)</a></li>
</ul>
etc.

Re: Just a small, but pretty important need of help! :o

Posted: Mon Jul 19, 2010 9:42 pm
by deluxxmanx
Thank you, shall try. :)

Re: Just a small, but pretty important need of help! :o

Posted: Mon Jul 19, 2010 10:31 pm
by Callan S.
I don't know much HTML myself, but after experimenting with the urban realms front page I wonder if you could make a new pair of cells to the left and right of each other within a larger cell. With the left cell, put the icons on the right hand side of that cell, and with the right hand cell, put the text on the left.

Re: Just a small, but pretty important need of help! :o

Posted: Mon Jul 19, 2010 11:58 pm
by Jackolantern
Callan S. wrote:I don't know much HTML myself, but after experimenting with the urban realms front page I wonder if you could make a new pair of cells to the left and right of each other within a larger cell. With the left cell, put the icons on the right hand side of that cell, and with the right hand cell, put the text on the left.
While that would work, that would be resorting to using tables for layout, which should be avoided if there is a better alternative. Tables have to be transmitted with every single page load, and even though they may only be a handful of bytes, the CSS to format the links is only sent once for each user if held in an external style sheet (where main page styles should be anyway). If you have thousands of users visiting hundreds of pages every visit (which is very possible in a web game), that could add up to be gigabytes saved each month off just a simple optimization that will also make the page cleaner.

Re: Just a small, but pretty important need of help! :o

Posted: Tue Jul 20, 2010 5:08 pm
by Noctrine
I like Chris' suggestion.

Re: Just a small, but pretty important need of help! :o

Posted: Tue Jul 20, 2010 11:09 pm
by Jackolantern
Noctrine wrote:I like Chris' suggestion.
Yep, that is the standard way of doing it, and then use CSS to do any additional styling needed.