Solved

PHP Table Code

Posted on 2013-01-18
3
458 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

This article discusses four methods for overlaying images in a container on a web page
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

739 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