I using 3 tables to store booking information: eventinfo, customer and testbook.
My Coding:
<?php
include('config.php');
$per_page = 9;
if($_GET)
{
$page=$_GET['page'];
}
//get table contents
$start = ($page-1)*$per_page;
$sql = "SELECT bookingID,eventinfo.eventTitle,boothAlias,testbook.bstatus,date'"
."testbook.username, customer.companyName, customer.contactName"
."from eventinfo, testbook, customer where testbook.username=customer.username"
." and testbook.eventID=eventinfo.eventID order by date limit $start,$per_page";
$rsd = mysql_query($sql);
?>
<table width="800px">
<?php
//Print the contents
while($row = mysql_fetch_array($rsd))
{
$id=$row['companyName'];
$contactName=$row['contactName'];
$eventTitle=$row['eventTitle'];
//$phone=$row['phone'];
$date=$row['date'];
$status=$row['bstatus'];
开发者_StackOverflow $booth=$row['boothAlias']
?>
<tr><td style="color:#B2b2b2; padding-left:4px"><?php echo $id; ?></td><td><?php echo $contactName; ?></td>
<td><?php echo $eventTitle; ?></td><td><?php echo $booth; ?></td><td><?php echo $date; ?></td><td><select name='status' id='status'>
<option value='-1'>--Select--</option>
<option value='0'>Approve</option>
<option value='1'>Reject</option>
<option value='2'>Pending</option>
</select></td>
</tr>
<?php
} //while
?>
</table>
And it return this:
I try to print out the record in the following pattern:
Anyone can help me?
Assuming you have all of your records ordered by id
first, followed by contactName
and then eventTitle
, a simple conditional can check to see if the current records values match that of the previously displayed record, and if they do, omit them. I've use ternary operators in this code just for the sake of compactness.
<?php
while($row = mysql_fetch_array($rsd)) {
$date=$row['date'];
$status=$row['bstatus'];
?>
<tr><td style="color:#B2b2b2; padding-left:4px"><?php echo ($id == $row['id']) ? "" : $row['id']; ?></td><td><?php echo ($contactName == $row['contactName']) ? "" : $row['contactName']; ?></td>
<td><?php echo ($eventTitle== $row['eventTitle']) ? "" : $row['eventTitle']; ?></td><td><?php echo ($booth== $row['boothAlias']) ? "" : $row['boothAlias']; ?></td><td><?php echo $date; ?></td><td><select name='status' id='status'>
<option value='-1'>--Select--</option>
<option value='0'>Approve</option>
<option value='1'>Reject</option>
<option value='2'>Pending</option>
</select></td>
</tr>
<?php
$id=$row['companyName'];
$contactName=$row['contactName'];
$eventTitle=$row['eventTitle'];
//$phone=$row['phone'];
$booth=$row['boothAlias'];
} //while
?>
This can easily be achieved in PHP.
Just store contactName and eventTitle and do an if-statement to determine if you should declare $contactName=$row['contactName'];
or $contactName='';
I find your first picture way more informative and readable. Why do you want to make it worse and harder to read?
精彩评论