Solved

PHP Table Code

Posted on 2013-01-18
3
446 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
ID: 38794144
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
ID: 38794197
Thank You! I tried everything I knew but your code works great!
0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 38794251
Thanks for the points!  Best regards, ~Ray
0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …

910 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

27 Experts available now in Live!

Get 1:1 Help Now