Solved

PHP Table Code

Posted on 2013-01-18
3
468 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 110

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 110

Expert Comment

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

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

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

Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
This post contains step-by-step instructions for setting up alerting in Percona Monitoring and Management (PMM) using Grafana.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

635 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