Simplify my Variable Assignment
Posted: Sun Jul 06, 2003 8:53 pm
I have some code that I will need to put on multiple pages, but the length of code is very large (the following is a snipet of the basic pattern):
How can I simplify this code? Is there some loop function that can do this? Note: this is a minor section of the patterned code, so it will be useful for me to have this simplified.
Though the next code segment has no mySQL it also repeats. If it could be stuck in a loop statement or something, that would be awesome:
Code: Select all
$giant_katana = mysql_result ($result, 0 , giant_katana);
$claymore = mysql_result ($result, 0 , claymore);
$great_axe = mysql_result ($result, 0 , great_axe);
$scourge = mysql_result ($result, 0 , scourge);Though the next code segment has no mySQL it also repeats. If it could be stuck in a loop statement or something, that would be awesome:
Code: Select all
if ($giant_katana)
{ print "
<tr>
<td><li><font color=gray>ї$giant_katana] giant katana</font></td>
</tr>
"; }
if ($claymore)
{ print "
<tr>
<td><li><font color=gray>ї$claymore] claymore</font></td>
</tr>
"; }
if ($great_axe)
{ print "
<tr>
<td><li><font color=gray>ї$great_axe] great axe</font></td>
</tr>
"; }
if ($scourge)
{ print "
<tr>
<td><li><font color=gray>ї$scourge] scourge</font></td>
</tr>
"; }