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
Solved

PHP Table Code

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

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 109

Expert Comment

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

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

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…
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)

829 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