Jump to content
MakeWebGames

Need help making stripey tables


Recommended Posts

Hi I recently got the ajax crimes script and tried to take out the code making the stripey tables and putting it into job.php to make the job rank tables stripey but it didnt work would someone be able to help me please? Here is an example of what i mean by stripey tables Check the link below thanks.

http://i658.photobucket.com/albums/uu303/firecamp555/points.jpg

this is the part that needs editing thanks.

 

function job_index()
{
global $db, $ir,$c,$userid,$h;
Doing('Viewing their Job');
print "<h3>[i]Your Job</h3>
</marquee>
<hr width=80%>


You currently work in the {$ir['jNAME']}! You receive \${$ir['jrPAY']} and {$ir['jrPOINTS']} Job Points each day at 9pm UK time!

You also receive {$ir['jrIQG']} IQ, {$ir['jrENDURANCEG']} Endurance, and {$ir['jrLABOURG']} labour!

</marquee>
<hr width=80%>
<table width=50% cellspacing=1 class='table'><tr><td>Endurance: {$ir['endurance']}</td><td>IQ: {$ir['IQ']}</td></tr><tr><td>Labour: {$ir['labour']}</td><td>Job Points: {$ir['jobpoints']}</td><td> Job Rank: {$ir['jrNAME']}</td></tr></table>
<hr width=80%>
[b]Job Ranks[/b]


<table width='75%' border='0' cellspacing='0'><tr bgcolor=#cccccc><th><div align=left>Rank</th><th><div align=left></th><th><div align=left>Endurance Needed</th><th><div align=left>IQ Needed</th><th><div align=left>Labour Needed</th></tr>";
$q=$db->query("SELECT * FROM jobranks WHERE jrJOB={$ir['job']} ORDER BY jrPAY ASC;");
while($r=$db->fetch_row($q))
{
print "<tr><td>{$r['jrNAME']}</td><td>Income: $".number_format($r['jrPAY'])." Per Day</td><td>{$r['jrENDURANCEN']}</td><td>{$r['jrIQN']}</td><td>{$r['jrLABOURN']}</td></tr>";
}
print "</table>

[url='job.php?action=promote'][/url]

[url='job.php?action=quit']<hr width=80%>[/url]";
}
$js=$db->query("SELECT * FROM jobspecials WHERE jsJOB={$ir['job']} ORDER BY jsID ASC;",$c);
print "[b]<table width=80% cellspacing=0 class='table'><tr><td><center>Specials unlocked:[/b]
<form action='specials.php' method='post'>
<table width=100% cellspacing=0 class='table'> <tr> <th><font color=></font></th> <th><font color=></font></th> <th><font color=></font></th></tr>";
if($db->num_rows($js) == 0)
{
print "<tr class='row$current_row'><td colspan=3>This Job has no Specials</td></tr>";
$current_row = 1 - $current_row;
}
while($sp=$db->fetch_row($js))
{
print "<tr class='row$current_row'><tr style=\"background-color: $color;\"><td><font color=>{$sp['jsNAME']} <font color=red>-{$sp['jsCOST']} Job Points</td><td><font color=#><center></font></td><td><center><input type='radio' name='ID' value='{$sp['jsID']}' /><onclick=\"javascript:this.form.submit();\"/></td></tr>";
$current_row = 1 - $current_row;
}
print "<tr>
<td colspan=3><div align=center><input type='submit' value='Purchase'></div></td>
</tr></table></form>";
print "</table>

<hr width=80%>
[url='job.php?action=promote']> Try To Get Promoted[/url]

[url='job.php?action=quit']> Quit[/url]
<hr width=80%>";
Link to comment
Share on other sites

Example...

		$_GET['var'] = ( isset($_GET['var']) && ctype_digit($_GET['var']) ) ? $_GET['var'] : 0;
 if ( empty($_GET['var']) ) {
 die('ERROR.');
 }
  echo '
<table width="100%" cellpadding="1" cellspacing="1">
	<tr>
<th>#</th>
<th>Title</th>
	</tr>
  ';
	$colour_cnt = 0;
	$fetched = $mysql_query('SELECT `field` FROM `users` WHERE `id` = '.$_GET['var']);
    while ( $ql = $mysql_fetch_object($fetched) ) {
	$td_colour =  ($colour_cnt % 2) ? "#000" : "#fff";
  echo '
	<tr style="color: '.$td_colour.';">
<td>'.$colour_cnt.'</td>
<td>'.$ql->field.'</td>
	</tr>
  ';
	$colour_cnt++;
    }
  echo '
</table>
  ';
Link to comment
Share on other sites

Example...
		$_GET['var'] = ( isset($_GET['var']) && ctype_digit($_GET['var']) ) ? $_GET['var'] : 0;
 if ( empty($_GET['var']) ) {
 die('ERROR.');
 }
  echo '


#
Title

  ';
	$colour_cnt = 0;
	$fetched = $mysql_query('SELECT `field` FROM `users` WHERE `id` = '.$_GET['var']);
    while ( $ql = $mysql_fetch_object($fetched) ) {
	$td_colour =  ($colour_cnt % 2) ? "#000" : "#fff";
  echo '

'.$colour_cnt.'
'.$ql->field.'

  ';
	$colour_cnt++;
    }
  echo '

  ';

Sorry but how do i fit that in to my code?

Link to comment
Share on other sites

ok this is what i have so far but the colours do not alternate

 

function job_index()
{
global $db, $ir,$c,$userid,$h;
Doing('Viewing their Job');
//if you have an anti-macro uncomment this line. it should just work, as long as the field in the users table is called validated, otherwise you will just have to change that.
//if ( $ir['validated'] == 0 ) { header("Location: macro.php?ref=".urlencode($_SERVER['PHP_SELF'])); exit; }


//do you want the table rows to alternate back and forth between colors to make things easier on players? 1=yes, 0=no
$alternate_colors=1;

//odd row color
$odd="#cccccc";
//even row color
$even="#DFDFDF";
print "<h3>[i]Your Job</h3>
</marquee>
<hr width=80%>


You currently work in the {$ir['jNAME']}! You receive \${$ir['jrPAY']} and {$ir['jrPOINTS']} Job Points each day at 9pm UK time!

You also receive {$ir['jrIQG']} IQ, {$ir['jrENDURANCEG']} Endurance, and {$ir['jrLABOURG']} labour!

</marquee>
<hr width=80%>
<table width=50% cellspacing=1 class='table'><tr><td>Endurance: {$ir['endurance']}</td><td>IQ: {$ir['IQ']}</td></tr><tr><td>Labour: {$ir['labour']}</td><td>Job Points: {$ir['jobpoints']}</td><td> Job Rank: {$ir['jrNAME']}</td></tr></table>
<hr width=80%>";
$num+=1;
if($alternate_colors==1)
{
if ($num % 2) {
$color="$even";
} else {
$color="$odd";
}
}
print "[b]Job Ranks[/b]


<table width='75%' tr style=\"background-color: $color;\" border='0' cellspacing='0'><tr bgcolor=#999999><th><div align=left>Rank</th><th><div align=left></th><th><div align=left>Endurance Needed</th><th><div align=left>IQ Needed</th><th><div align=left>Labour Needed</th></tr>";
$q=$db->query("SELECT * FROM jobranks WHERE jrJOB={$ir['job']} ORDER BY jrPAY ASC;");
Link to comment
Share on other sites

function job_index()
{
global $db, $ir,$c,$userid,$h;
Doing('Viewing their Job');
print "<h3>[i]Your Job</h3>
</marquee>
<hr width=80%>


You currently work in the {$ir['jNAME']}! You receive \${$ir['jrPAY']} and {$ir['jrPOINTS']} Job Points each day at 9pm UK time!

You also receive {$ir['jrIQG']} IQ, {$ir['jrENDURANCEG']} Endurance, and {$ir['jrLABOURG']} labour!

</marquee>
<hr width=80%>
<table width=50% cellspacing=1 class='table'><tr><td>Endurance: {$ir['endurance']}</td><td>IQ: {$ir['IQ']}</td></tr><tr><td>Labour: {$ir['labour']}</td><td>Job Points: {$ir['jobpoints']}</td><td> Job Rank: {$ir['jrNAME']}</td></tr></table>
<hr width=80%>
[b]Job Ranks[/b]


<table width='75%' border='0' cellspacing='0'><tr bgcolor=#cccccc><th><div align=left>Rank</th><th><div align=left></th><th><div align=left>Endurance Needed</th><th><div align=left>IQ Needed</th><th><div align=left>Labour Needed</th></tr>";
$q=$db->query("SELECT * FROM jobranks WHERE jrJOB={$ir['job']} ORDER BY jrPAY ASC;");
$i = 1;
while($r=$db->fetch_row($q))
{
// Set row color
	$bgcolor = " bgcolor=\"#ececec\"";
               // Display alternate color for rows
	//if ($i % 2 <> 0) {
	if ($i % 2 == 0) {
        $bgcolor = " bgcolor=\"#dedede\"";
	}
print "<tr $bgcolor><td>{$r['jrNAME']}</td><td>Income: $".number_format($r['jrPAY'])." Per Day</td><td>{$r['jrENDURANCEN']}</td><td>{$r['jrIQN']}</td><td>{$r['jrLABOURN']}</td></tr>";
$bgcolor = " bgcolor=\"#ececec\"";
$i ++;
}
print "</table>

[url='job.php?action=promote'][/url]

[url='job.php?action=quit']<hr width=80%>[/url]";
}
$js=$db->query("SELECT * FROM jobspecials WHERE jsJOB={$ir['job']} ORDER BY jsID ASC;",$c);
print "[b]<table width=80% cellspacing=0 class='table'><tr><td><center>Specials unlocked:[/b]
<form action='specials.php' method='post'>
<table width=100% cellspacing=0 class='table'> <tr> <th><font color=></font></th> <th><font color=></font></th> <th><font color=></font></th></tr>";
if($db->num_rows($js) == 0)
{
print "<tr class='row$current_row'><td colspan=3>This Job has no Specials</td></tr>";
$current_row = 1 - $current_row;
}
while($sp=$db->fetch_row($js))
{
print "<tr class='row$current_row'><tr style=\"background-color: $color;\"><td><font color=>{$sp['jsNAME']} <font color=red>-{$sp['jsCOST']} Job Points</td><td><font color=#><center></font></td><td><center><input type='radio' name='ID' value='{$sp['jsID']}' /><onclick=\"javascript:this.form.submit();\"/></td></tr>";
$current_row = 1 - $current_row;
}
print "<tr>
<td colspan=3><div align=center><input type='submit' value='Purchase'></div></td>
</tr></table></form>";
print "</table>

<hr width=80%>
[url='job.php?action=promote']> Try To Get Promoted[/url]

[url='job.php?action=quit']> Quit[/url]
<hr width=80%>";

 

I helped if you can see where lol. You may get the hint after you replace the one you posted with the one i have posted for you...( I only did it to the job indez you need to add the same to the next table below that function.

Link to comment
Share on other sites

function job_index()
{
global $db, $ir,$c,$userid,$h;
Doing('Viewing their Job');
print "Your Job




You currently work in the {$ir['jNAME']}! You receive \${$ir['jrPAY']} and {$ir['jrPOINTS']} Job Points each day at 9pm UK time!

You also receive {$ir['jrIQG']} IQ, {$ir['jrENDURANCEG']} Endurance, and {$ir['jrLABOURG']} labour!



Endurance: {$ir['endurance']}IQ: {$ir['IQ']}Labour: {$ir['labour']}Job Points: {$ir['jobpoints']} Job Rank: {$ir['jrNAME']}

Job Ranks


Rank
Endurance NeededIQ NeededLabour Needed";
$q=$db->query("SELECT * FROM jobranks WHERE jrJOB={$ir['job']} ORDER BY jrPAY ASC;");
$i = 1;
while($r=$db->fetch_row($q))
{
// Set row color
	$bgcolor = " bgcolor=\"#ececec\"";
               // Display alternate color for rows
	//if ($i % 2 <> 0) {
	if ($i % 2 == 0) {
        $bgcolor = " bgcolor=\"#dedede\"";
	}
print "{$r['jrNAME']}Income: $".number_format($r['jrPAY'])." Per Day{$r['jrENDURANCEN']}{$r['jrIQN']}{$r['jrLABOURN']}";
$bgcolor = " bgcolor=\"#ececec\"";
$i ++;
}
print "



";
}
$js=$db->query("SELECT * FROM jobspecials WHERE jsJOB={$ir['job']} ORDER BY jsID ASC;",$c);
print "Specials unlocked:




";
if($db->num_rows($js) == 0)
{
print "This Job has no Specials";
$current_row = 1 - $current_row;
}
while($sp=$db->fetch_row($js))
{
print "{$sp['jsNAME']} -{$sp['jsCOST']} Job Points
";
$current_row = 1 - $current_row;
}
print "

";
print "


> Try To Get Promoted

> Quit
";

 

I helped if you can see where lol. You may get the hint after you replace the one you posted with the one i have posted for you...

thanks a bunch mate. Stripey tables are the most annoying codes for me X(

Link to comment
Share on other sites

You add

$i = 1; before the

while($r=$db->fetch_row($q))

{

area

and this below....

// Set row color

$bgcolor = " bgcolor=\"#ececec\"";

// Display alternate color for rows

//if ($i % 2 <> 0) {

if ($i % 2 == 0) {

$bgcolor = " bgcolor=\"#dedede\"";

}

and then add $bgcolor in the <tr> bracket

then this after your table ending in </tr>";

$bgcolor = " bgcolor=\"#ececec\"";

$i ++;

 

PM me your script and i will get it working for you if you want.

Link to comment
Share on other sites

A much easier way :P

$row_color = 0;

while($r=$db->fetch_row($q))

{

$row_color++;

if ($row_color % 2 == 0) {

$paddy = ' style="background-color:#484848;text-align:center;"';

} else {

$paddy = ' style="background-color:#686868;text-align:center;"';

}

print " <tr$paddy>

and all the other <td>text here</td>

Link to comment
Share on other sites

A much easier way :P

$row_color = 0;

while($r=$db->fetch_row($q))

{

$row_color++;

if ($row_color % 2 == 0) {

$paddy = ' style="background-color:#484848;text-align:center;"';

} else {

$paddy = ' style="background-color:#686868;text-align:center;"';

}

print "

and all the other text here

This one seems to leave large gaps between each table column =/
Link to comment
Share on other sites

Edited: this below is what i use and doesn't leave any gaps, obviosly you can play around with some css in the style section to fit your game

 

$row_color = 0;
while($r=$db->fetch_row($q))
{
$row_color++;
if ($row_color % 2 == 0) {
$paddy = ' style="background-color:#484848;text-align:center;"';

} else {

$paddy = ' style="background-color:#686868;text-align:center;"';
}
print " <tr$paddy>

and all the other <td>text here</td>
Link to comment
Share on other sites

the issue is in the class=table

<table cellspacing="0" cellpadding="0" border="0" width="75%" class="table"> if you remove table they get back together with no gap or you can add to the style (.table) this line

border-collapse:collapse;

try and let me know

Edited:

you can also try

.table td {

border-style:hidden;

Link to comment
Share on other sites

Yet even a better way: http://deadlykillah.net/testscripts/test1.php. And is browser compliant!

What my script does (Read the Source page), it set's all table's to "zebra styled" table's. How ever, i have also created a class for the css that if you don't want the table to be zebra style'd. all you add is class="except". With this (And DJK's script) it will make your entire site zebra styled. How ever, i do suggest you add my script to the very bottom of globals.php, thus so it does not affect anything else, but just the main play.

Enjoy.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...