I wouldnt call it exactly..speeding up your script, but cleaning it up may be a better word for it.
Take for instance this part:
php Code:
Original
- php Code |
|
|
|
<div align='center'>
<table width=85%>
<tr class='row1'>';
echo "<td background=$bgimg width=75%>";echo
'<u>'.
$GLOBALS['consolecolor'].
' ';
echo " $row2->name ";
echo ' </font></u></td> </tr>
<tr class='row2'>
<td align='center'>
';
What I normally try to do, is keep all HTML stuff in one organized area. This can be accomplished as:
php Code:
Original
- php Code |
|
|
|
$_mydivide= <<<EOD
<div align='center'>
<table width=85%>
<tr class='row1'>
<td background=$bgimg width=75%><font>$_mystatement </font></u></td>
</tr>
<tr class='row2'>
<td align='center'>
EOD;
Than, to call it all out, you could go about doing this:
php Code:
Original
- php Code |
|
|
|
$_mystatement="<u>'.$GLOBALS['consolecolor'].' $row2->name";
Just with that tidbit, you can dramatically cut down your lines of code.
So, lets just apply that bit of it to your script.
php Code:
Original
- php Code |
|
|
|
function dispConsole()
{
global $row1,
$row2,
$bgimg,
$consolesep;
{
dispProfile();
echo ' Welcome to Your Console '.
$_SESSION['rank'].
' '.
$_SESSION['username'].
' ';
$result1=
mysql_query("SELECT * FROM consoles WHERE minrank<= '".
$_SESSION['rank'].
"' AND disabled=0 ORDER BY position ASC");
//your statement can now be modified on the fly if need be
$_mystatement="<font><u>'.$GLOBALS['consolecolor'].' $row2->name</font></u>";
//here we have your table output
$_mydivide = <<<EOD
<div align='center'>
<table width=85%>
<tr class='row1'>
<td background=$bgimg width=75%>$_mystatement</td>
</tr>
<tr class='row2'>
<td align='center'>
EOD;
// this prints out your information and table from one simple call line.
$result =
mysql_query("SELECT * FROM consolestuff WHERE minrank<= '".
$_SESSION['rank'].
"' AND console ="$row2->
name"");
echo " $consolesep <a href=$row3->link> $row3->name</a> ";
} echo ' $consolesep </td>
</tr>
</table>
</div>
';
//viewNews(1);
} } }
?>
Without knowing how this actually executes, or what info you pull up when running that script, it is possible that this will not work within the function guideline, however, it is the little tweaks like that above (and one could be made for your other echo statement as a link function) which keep (in my opinion anyway) things nice and easy to configure and edit down the road. Of course, a person could make one whole class out of that statement as well, but for now, as a function, it might do the trick.