hbalagh Posted January 2, 2010 Share Posted January 2, 2010 we have this page where we want the background of each job row to be altering (like on most message boards) here is the code, all help is greatly appreciated.. <?php $ratings=array(); $jobId = $_GET['jobId']; $pg = (int)$_GET['pg']; if(!isset($pg)) $pg=1; if(empty($pg)) $pg=1; ////get a list of phrase ids to search in $query = " SELECT id, category_id, job_title, post_date, location, contact_info, description, banned FROM job_content ORDER BY id DESC "; $jobs = mysqli_query($g_link, $query); $k=1; while ($job = mysqli_fetch_assoc($jobs)) { $query = " SELECT id, name, description FROM job_category WHERE id=".$job['category_id']." LIMIT 1 "; $joballs = mysqli_query($g_link, $query); while ($joball = mysqli_fetch_assoc($joballs)) { $jobName = $joball['name']; } unset($joball); $postdate = convert($job['post_date'], 'Y-m-d', 'M,d'); $jobArrs[$k] = $job['id']."__".$job['category_id']."__".$job['job_title']."__".$jobName."__".$postdate."__".$job['location']."__".$job['contact_info']."__".$job['description']; $k++; } unset($job); $numpgs = ceil(count($jobArrs)/25); if( $g_link != false ) mysqli_close($g_link); ?> <div class="pageright"> <?php if(count($jobArrs)==0){ ?> <h3>Currently there is no jobs, do you want to <a href="job_add.php?jobId=<?php echo $jobId?>&jobName=<?php echo $jobName?>">post</a> one?</h3> <?php } ?> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr><td colspan="4"> <div style="float:left; width:50%;"><a href="job_add.php">POST A NEW JOB</a></div><div style="float: left; text-align:right; width:50%;"> <a href="job_viewall.php?pg=<?php echo $pg>1?$pg-1:$pg;?>">PREVIOUS</a> | <?php for($j=1;$j<=$numpgs;$j++) if($pg==$j) echo "$j | "; else echo "<a href=\"job_viewall.php?pg=$j\">$j</a> | "; ?> <a href="job_viewall.php?pg=<?php echo $pg<$numpgs?$pg+1:$pg;?>">NEXT</a></div></td></tr> <tr style="background-color:#666666; height:20px; color:#ffffff;"><th width=15% align="center">Post Date</th><th width=30% align="center">Job Title</th><th width=25% align="center">Category</th><th width=30% align="center">Location</th></tr> <?php for ($i=25*($pg-1)+1;$i<=25*$pg;$i++){ if($i<=count($jobArrs)){ $job=$jobArrs[$i]; list($id, $categoryid, $jobTitle, $jobName,$post_date,$location,$contact_info,$description)=explode('__',$job); ?> <tr bgcolor="#ffffff" border=1px height="30px"> <td align="center"><?php echo $post_date;?></td> <td align="center" class="capitalize"><a href="job_viewdetail3.php?jobId=<?php echo $id?>"><?php echo $jobTitle;?></td> <td align="center" class="capitalize"><a href="job_view3.php?jobId=<?php echo $categoryid?>"><?php echo $jobName;?></a></td> <td align="center" class="capitalize"><?php echo $location;?></td> </tr> <?php } } ?> <tr><td colspan="4"> <div style="float:left; width:50%;"><a href="job_add.php">POST A NEW JOB</a></div><div style="float: left; text-align:right; width:50%;"> <a href="job_viewall.php?pg=<?php echo $pg>1?$pg-1:$pg;?>">PREVIOUS</a> | <?php for($j=1;$j<=$numpgs;$j++) if($pg==$j) echo "$j | "; else echo "<a href=\"job_viewall.php?pg=$j\">$j</a> | "; ?> <a href="job_viewall.php?pg=<?php echo $pg<$numpgs?$pg+1:$pg;?>">NEXT</a></div> </td></tr> </table> <br /><br /> <br /> </div> Quote Link to comment https://forums.phpfreaks.com/topic/186960-altering-background-colors-on-table-row/ Share on other sites More sharing options...
wildteen88 Posted January 2, 2010 Share Posted January 2, 2010 Change this: list($id, $categoryid, $jobTitle, $jobName,$post_date,$location,$contact_info,$description)=explode('__',$job); ?> <tr bgcolor="#ffffff" border=1px height="30px"> to list($id, $categoryid, $jobTitle, $jobName,$post_date,$location,$contact_info,$description)=explode('__',$job); // ALTERNATE BACKGROUND COLOR $bgcolor = ($i % 2) ? '#COLOR1' : '#COLOR2'; ?> <tr bgcolor="<?php echo $bgcolor; ?>" border=1px height="30px"> Replace #COLOR1 and #COLOR2 to the colors you wish to alternate between. Quote Link to comment https://forums.phpfreaks.com/topic/186960-altering-background-colors-on-table-row/#findComment-987302 Share on other sites More sharing options...
hbalagh Posted January 2, 2010 Author Share Posted January 2, 2010 thank u Quote Link to comment https://forums.phpfreaks.com/topic/186960-altering-background-colors-on-table-row/#findComment-987306 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.