Your IP : 216.73.216.40


Current Path : /var/www/html/mmishra/iws8/html/iport/
Upload File :
Current File : /var/www/html/mmishra/iws8/html/iport/vehicles.inc.bak

<h3 align='left'>Vehicle Detail</h3>
<center>
<?php

$tbl = 'vehicles';
$mm = 'readonly';
$del = '';
$edit = 0;
$delete = 0;

$rowID = $_REQUEST["rowID"];
$submit = $_POST["submit"];

if (!$rowID) $mm = '';

if ($submit == 'ADD') {
	$rowID = 0;
	$mm = '';

} else if ($submit == 'EDIT') {
	$mm = '';
	$edit = 1;

} else if ($submit == 'SAVE') {
	$vehicleID = $_POST["vehicleID"];
	$registrationNo = $_POST["registrationNo"];
	$brand = $_POST["brand"];
	$model = $_POST["model"];
	$make = $_POST["make"];
	$seatingCapacity = $_POST["seatingCapacity"];
	$photograph = $_POST["photograph"];
	$vehicleOwner = $_POST["vehicleOwner"];
	$ownerContact = $_POST["ownerContact"];
	
	//maitain vehicle record	
	if (mysql_num_rows(mysql_query("select * from $tbl where rowID=$rowID"))) {
		mysql_query("update $tbl set vehicleID='$vehicleID',registrationNo='$registrationNo',
		brand='$brand',model='$model',make=$make,seatingCapacity=$seatingCapacity,
		photograph='$photograph',vehicleOwner='$vehicleOwner',ownerContact='$ownerContact',
		loginID='$user' where rowID=$rowID");
	} else {
		mysql_query("insert into $tbl(vehicleID,registrationNo,brand,model,make,seatingCapacity,
		photograph,vehicleOwner,ownerContact,dateCreation,loginID)
		values('$vehicleID','$registrationNo','$brand','$model',$make,$seatingCapacity,
		'$photograph','$vehicleOwner','$ownerContact',now(),'$user')");
	}
} else if ($submit == 'DELETE') {
	$del = "Are you sure? [ <a href='?pg=$pg&delete=1&rowID=$rowID'>Yes</a> | <a href='?pg=$pg&rowID=$rowID'>No</a> ]";
	$mm = '';
	$edit = 1;
	
} 

if ($_GET['delete'] == 1) mysql_query("delete from $tbl where rowID=$rowID");

$rs = mysql_query("select * from $tbl where rowID=$rowID");
while ($o = mysql_fetch_object($rs)) {
	$vehicleID = $o->vehicleID;
	$registrationNo = $o->registrationNo;
	$brand = $o->brand;
	$model = $o->model;
	$make = $o->make;
	$seatingCapacity = $o->seatingCapacity;
	$photograph = $o->photograph;
	$vehicleOwner = $o->vehicleOwner;
	$ownerContact = $o->ownerContact;
}
?>
<table border='1' width='100%'>
<tr><th width='70%'>Add/Edit/Delete Record</th><th width='30%'>List Records</th></tr>
<tr valign='top'><td>
<input type='hidden' name='rowID' value='<?php echo $rowID; ?>'>
<table border='0' width='100%'>
<tr><td>Vehicle ID</td><td><input type='text' name='vehicleID' value='<?php echo $vehicleID; ?>' size='30' <?php echo $mm; ?>></td></tr>
<tr><td>Registration No.</td><td><input type='text' name='registrationNo' value='<?php echo $registrationNo; ?>' size='30' <?php echo $mm; ?>></td></tr>
<tr><td>Brand</td><td><input type='text' name='brand' value='<?php echo $brand; ?>' size='30' <?php echo $mm; ?>></td></tr>
<tr><td>Model</td><td><input type='text' name='model' value='<?php echo $model; ?>' size='30' <?php echo $mm; ?>></td></tr>
<tr><td>Make</td><td><input type='text' name='make' value='<?php echo $make; ?>' size='30' <?php echo $mm; ?></td></tr>
<tr><td>Seating Capacity</td><td><input type='text' name='seatingCapacity' value='<?php echo $seatingCapacity; ?>' size='30' <?php echo $mm; ?>></td></tr>
<tr><td>Photograph</td><td><input type='text' name='photograph' value='<?php echo $photograph; ?>' size='30' <?php echo $mm; ?>></td></tr>
<tr><td>Owner Name</td><td><input type='text' name='vehicleOwner' value='<?php echo $vehicleOwner; ?>' size='30' <?php echo $mm; ?>></td></tr>
<tr><td>Owner Contact</td><td><input type='text' name='ownerContact' value='<?php echo $ownerContact; ?>' size='30' <?php echo $mm; ?>></td></tr>
<tr><th>

<?php
if ($rowID) {
	echo "<input type='submit' name='submit' value='ADD'>";
} else {
	echo "<input type='reset' name='reset' value='CLEAR'>";
}
?>
</th><th>
<?php
if ($rowID) {
	if ($edit) {
		echo "<input type='submit' name='submit' value='SAVE'> <input type='submit' name='submit' value='DELETE'>";
		echo $del;
	} else {
		echo "<input type='submit' name='submit' value='EDIT'>";
	}
} else {
	echo "<input type='submit' name='submit' value='SAVE'>";
}

?>
</th></tr>
</table>
</td><td>
<ol>
<?php
$rs = mysql_query("select * from $tbl order by vehicleID");
while ($o = mysql_fetch_object($rs)) {
	echo "<li><a href='?pg=$pg&rowID=$o->rowID'>$o->vehicleID</a> $o->model</li>";
}
?>
</ol>
</td></tr>
</table>
</center>