topical media & game development
basic-mysql-17-PHPApp-index.php / php
<?
*****************************************************************************
Author: Geoff Moes and Robert Sheldon
Project: Begining MySQL - Chapter 17
Module: index.php
Date: 12/10/04
Description:
This is the main listing page for the DVDRentals transaction application.
This page allows the user to list the current transactions and select
individual transactions for editing and deletion.
*****************************************************************************
?>
<html>
<head>
<title>DVD - Listing</title>
<link rel="stylesheet" href="dvdstyle.css" type="text/css">
<script language="JavaScript" src="dvdrentals.js"></script>
</head>
<body>
<form name="mainForm" method="post" action=<index.php>>
<input type="hidden" name="command" value="view">
<input type="hidden" name="transaction_id" value="">
<p></p>
<table cellSpacing="0" cellPadding="0" width="619" border="0">
<tr>
<td>
<table height="20" cellSpacing="0" cellPadding="0" width="619" bgcolor="#bed8e1" border="0">
<tr align=left>
<td valign="bottom" width="400" class="title">
DVD Transaction Listing
</td>
<td align="right" width="219" class="title">
<input type="button" value="New Transaction" class="add" onclick="doAdd(this)">
</td>
</tr>
</table>
<br>
<table cellSpacing="2" cellPadding="2" width="619" border="0">
<tr>
<td width="250" class="heading">Order Number</td>
<td width="250" class="heading">Customer</td>
<td width="250" class="heading">DVDName</td>
<td width="185" class="heading">DateOut</td>
<td width="185" class="heading">DateDue</td>
<td width="185" class="heading">DateIn</td>
<td width="99" class="heading"> </td>
<td width="99" class="heading"> </td>
</tr>
<?
// Connect to server or return an error
link)
or die("Unable to select database: . mysql_error()");
// Initialize variables with parameters retrieved from the form
transactionId = null;
if(isset(command = _POST["transaction_id"]))
_POST["transaction_id"];
// Processes the delete command
if(command) == 0)
{
include <delete.php>;
}
}
// Construct the SQL statement
result = mysql_query(link);
if(!selectSql);
// Loop through the result set
while(result))
{
// Retrieve the columns from the result set into local variables
row["TransID"];
row["OrderID"];
row["DVDID"];
row["DateOut"];
row["DateDue"];
row["DateIn"];
row["CustFN"];
row["CustLN"];
row["DVDName"];
// Convert nulls to empty strings and format the data
dateOutPrint = "";
dateInPrint = "";
if(customerName .= custLastName != null)
custLastName;
if(dvdName = "";
dateOut != null)
dateFormat, strtotime(dateDue != null)
dateFormat, strtotime(dateIn, "0000-00-00") != 0)
dateFormat, strtotime(orderId);?>
</nobr>
</td>
<td class="item">
<nobr>
<?printf(dvdName");?>
</nobr>
</td>
<td class="item">
<nobr>
<?printf(dateDuePrint);?>
</nobr>
</td>
<td class="item">
<nobr>
<?printf(transId)?>)">
</td>
<td class="item" valign="center" align="center">
<input type="button" value="Delete" class="delete" onclick="doDelete(this, <?printf(link);
?>
</table>
</td>
</tr>
</table>
</body>
</html>
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.