Solved

HTML / PHP Code Sorting

Posted on 2011-03-16
1
312 Views
Last Modified: 2013-12-25
In the below code, it displays data from a mysql database in a browser. Is there any way for me to sort what is shown by the date?

<table>
      <thead>
      <tr>
	   <table border='7'>

<th>Customer No</th>
<th>First Name</th>
<th>Last Name</th>
<th>Order Date>/th>
<th>Edit</th>
<th>Delete</th>
      </tr>      
      </thead>
      <tbody>
<?php
require('connection.php');

if (isset($_GET['op']) && $_GET['op'] == "d") 
if($_GET['op'] == "d" && !empty($_GET['id']) )
{
   $query="DELETE FROM `psrinfo` WHERE `fid`=" . $_GET['id'];
   $result = mysql_query($query) or die(mysql_error());  
}

$query="SELECT fid, cust, fname, lname WHERE employee = 'employee1'";
$result = mysql_query($query) or die(mysql_error());  
 
while($row = mysql_fetch_array( $result )) {
?>
       <tr>
           
			<td><?php echo "".$row['cust']; ?></td>
            <td><?php echo "".$row['fname']; ?></td>
            <td><?php echo "".$row['lname']; ?></td>
			<td><?php echo "".$row['date']; ?></td>
			<td><a href="edit.php?id=<?php echo $row['fid'];?>"><center>Edit</center></a></td>
            <td><a href="<?php echo $_SERVER['PHP_SELF'];?>?op=d&id=<?php echo $row['fid'];?>">Delete</a></td>
		    
      </tr>
<?php } ?>            
      </tbody> 
</table>

Open in new window

0
Comment
Question by:wantabe2
1 Comment
 
LVL 17

Accepted Solution

by:
shinuq earned 500 total points
ID: 35146882
Hope this helps
<table>
      <thead>
      <tr>
	   <table border='7'>

<th>Customer No</th>
<th>First Name</th>
<th>Last Name</th>
<th>Order Date>/th>
<th>Edit</th>
<th>Delete</th>
      </tr>      
      </thead>
      <tbody>
<?php
require('connection.php');

if (isset($_GET['op']) && $_GET['op'] == "d") 
if($_GET['op'] == "d" && !empty($_GET['id']) )
{
   $query="DELETE FROM `psrinfo` WHERE `fid`=" . $_GET['id'];
   $result = mysql_query($query) or die(mysql_error());  
}

$query="SELECT fid, cust, fname, lname,date WHERE employee = 'employee1' order by date";
$result = mysql_query($query) or die(mysql_error());  
 
while($row = mysql_fetch_array( $result )) {
?>
       <tr>
           
			<td><?php echo "".$row['cust']; ?></td>
            <td><?php echo "".$row['fname']; ?></td>
            <td><?php echo "".$row['lname']; ?></td>
			<td><?php echo "".$row['date']; ?></td>
			<td><a href="edit.php?id=<?php echo $row['fid'];?>"><center>Edit</center></a></td>
            <td><a href="<?php echo $_SERVER['PHP_SELF'];?>?op=d&id=<?php echo $row['fid'];?>">Delete</a></td>
		    
      </tr>
<?php } ?>            
      </tbody> 
</table>

Open in new window

0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
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…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

746 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

12 Experts available now in Live!

Get 1:1 Help Now