Solved

PHP Table Code

Posted on 2013-01-18
3
438 Views
Last Modified: 2013-01-18
The following code works fine I'm just trying to make it more presenatble in a browser. At this time this code pulls data from my MySQL database & displays it in a browser. As you can see in the attached pic, the background behind the data is all white. How can I edit this code so every other field will be a little bit darker to help the user distinguish each field?

<b> <p> <i> To go to the main page <a href="http://16.12.5.24/gflow/index.html">click here</a>.</p> </i>

<table>
<title> Your Assignments</title>
      <thead>
      <tr>
	   <table border='7'>

<th>First Name</th>
<th>Last Name</th>
<th>Status</th>
<th>Next Date</th>
<th>Date Assigned</th>
<th>Clerk</th>
<th>Due to Rev</th>
<th>Due to SUSO</th>
<th>Due to Sec</th>
<th>Due to Ref</th>
<th>Due to Owner</th>
<th>Sent Date</th>
<th>Enter 1 Info</th>
<th>Enter 2 Info</th>
<th>Edit Date</th>
<th>Review </th>
<th>Archive</th>
      </tr>      
      </thead>
      <tbody>
<?php
require('connection.php');


if (isset($_GET['op']) && $_GET['op'] == "d") 
if($_GET['op'] == "d" && !empty($_GET['id']) )
{
   $query="UPDATE psrinfo SET active = '0' WHERE fid={$_GET['id']}";
   $result = mysql_query($query) or die(mysql_error()); 
 
}

$query="SELECT fid, pact, fname, lname, oth_date, assgn_date, status, sent, clerk, due_suso, due_clerk, due_owner, due_attny, due_rev FROM psrinfo WHERE employee = 'me' AND active='1' order by sent";
$result = mysql_query($query) or die(mysql_error());  
 
while($row = mysql_fetch_array( $result )) {
?>
       <tr>
           
			
            <td><center><?php echo "".$row['fname']; ?></center></td>
            <td><center><?php echo "".$row['lname']; ?></center></td>
			<td><center><?php echo "".$row['status']; ?></center></td>
			<td><center><?php echo "".$row['oth_date']; ?></center></td>
			<td><center><?php echo "".$row['assgn_date']; ?></center></td>
			<td><center><?php echo "".$row['clerk']; ?></center></td>
			<td><center><?php echo "".$row['due_rev']; ?></center></td>
			<td><center><?php echo "".$row['due_suso']; ?></center></td>
			<td><center><?php echo "".$row['due_clerk']; ?></center></td>
			<td><center><?php echo "".$row['due_attny']; ?></center></td>
			<td><center><?php echo "".$row['due_owner']; ?></center></td>
			<td><center><?php echo "".$row['sent']; ?></center></td>
			<td><center><a href="psd_dqa.php?id=<?php echo $row['fid'];?>"><center>Enter/Edit P1</center></a></center></td>
			<td><center><a href="p2.php?id=<?php echo $row['fid'];?>"><center>Enter/Edit P2</center></a></center></td>
			<td><center><a href="edit_dqa_cont.php?id=<?php echo $row['fid'];?>"><center>Edit Date</center></a></center></td>
			<td><center><a href="ps_checklist.php?id=<?php echo $row['fid'];?>"><center>Generate Checklist</center></a></center></td>
			<td><center><a href="<?php echo $_SERVER['PHP_SELF'];?>?op=d&id=<?php echo $row['fid'];?>" onClick="javascript:if(confirm ('Are you sure?')) return true; else return false;">ARCHIVE</a></center></td>
      </tr>
<?php } ?>            
      </tbody>
 
</table>

Open in new window

aa.JPG
0
Comment
Question by:wantabe2
  • 2
3 Comments
 
LVL 108

Accepted Solution

by:
Ray Paseur earned 500 total points
Comment Utility
The "ternary operator" is just made for this requirement!  Look near line 46.

<b> <p> <i> To go to the main page <a href="http://16.12.5.24/gflow/index.html">click here</a>.</p> </i>

<table>
<title> Your Assignments</title>
      <thead>
      <tr>
	   <table border='7'>

<th>First Name</th>
<th>Last Name</th>
<th>Status</th>
<th>Next Date</th>
<th>Date Assigned</th>
<th>Clerk</th>
<th>Due to Rev</th>
<th>Due to SUSO</th>
<th>Due to Sec</th>
<th>Due to Ref</th>
<th>Due to Owner</th>
<th>Sent Date</th>
<th>Enter 1 Info</th>
<th>Enter 2 Info</th>
<th>Edit Date</th>
<th>Review </th>
<th>Archive</th>
      </tr>      
      </thead>
      <tbody>
<?php
require('connection.php');


if (isset($_GET['op']) && $_GET['op'] == "d") 
if($_GET['op'] == "d" && !empty($_GET['id']) )
{
   $query="UPDATE psrinfo SET active = '0' WHERE fid={$_GET['id']}";
   $result = mysql_query($query) or die(mysql_error()); 
 
}

$query="SELECT fid, pact, fname, lname, oth_date, assgn_date, status, sent, clerk, due_suso, due_clerk, due_owner, due_attny, due_rev FROM psrinfo WHERE employee = 'me' AND active='1' order by sent";
$result = mysql_query($query) or die(mysql_error());  
$bgcolor = 'orange';
while($row = mysql_fetch_array( $result )) {
    echo "<tr style=\"background-color:$bgcolor;\">" . PHP_EOL;
    ($bgcolor == "orange") ? $bgcolor = "purple" : $bgcolor = "orange";
?>
           
			
            <td><center><?php echo "".$row['fname']; ?></center></td>
            <td><center><?php echo "".$row['lname']; ?></center></td>
			<td><center><?php echo "".$row['status']; ?></center></td>
			<td><center><?php echo "".$row['oth_date']; ?></center></td>
			<td><center><?php echo "".$row['assgn_date']; ?></center></td>
			<td><center><?php echo "".$row['clerk']; ?></center></td>
			<td><center><?php echo "".$row['due_rev']; ?></center></td>
			<td><center><?php echo "".$row['due_suso']; ?></center></td>
			<td><center><?php echo "".$row['due_clerk']; ?></center></td>
			<td><center><?php echo "".$row['due_attny']; ?></center></td>
			<td><center><?php echo "".$row['due_owner']; ?></center></td>
			<td><center><?php echo "".$row['sent']; ?></center></td>
			<td><center><a href="psd_dqa.php?id=<?php echo $row['fid'];?>"><center>Enter/Edit P1</center></a></center></td>
			<td><center><a href="p2.php?id=<?php echo $row['fid'];?>"><center>Enter/Edit P2</center></a></center></td>
			<td><center><a href="edit_dqa_cont.php?id=<?php echo $row['fid'];?>"><center>Edit Date</center></a></center></td>
			<td><center><a href="ps_checklist.php?id=<?php echo $row['fid'];?>"><center>Generate Checklist</center></a></center></td>
			<td><center><a href="<?php echo $_SERVER['PHP_SELF'];?>?op=d&id=<?php echo $row['fid'];?>" onClick="javascript:if(confirm ('Are you sure?')) return true; else return false;">ARCHIVE</a></center></td>
      </tr>
<?php } ?>            
      </tbody>
 
</table>

Open in new window

0
 
LVL 15

Author Closing Comment

by:wantabe2
Comment Utility
Thank You! I tried everything I knew but your code works great!
0
 
LVL 108

Expert Comment

by:Ray Paseur
Comment Utility
Thanks for the points!  Best regards, ~Ray
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now