Professional Documents
Culture Documents
php
//display all video in a list langga. May inline edit kag delete button.
<!DOCTYPE html>
<html>
<head>
<title>Online-Video-Rental</title>
</head>
<style type="text/css">
th,tr{
width: 800px;
</style>
<body>
<?php
if (!$con) {
die('Unable to connect');
?>
<th>
No.
</th>
<th>
Video ID
</th>
<th>
Video Title
</th>
<th>
Category
</th>
<th>Company</th>
<th>
Year Released
</th>
<th>
Action
</th>
<?php
$count=1;
$result = mysqli_query($con,$sel_query);
<td align="center">
<td align="center">
</td>
</td>
<td align="center">
</td>
<td align="center">
</td>
<td align="center">
</td>
<td align="center">
</td>
<td align="center">
</td>
</tr>
<?php $count++; }
mysqli_close($con);?>
</table>
</body>
</html>
edit.php
$vidId = $_REQUEST['txtid'];
if(mysqli_num_rows($result)>0)
$row = mysqli_fetch_object($result);
?>
<table border ='1' width ='30%'>
<tr>
</tr>
<tr>
<td><input size ="20" type ="text" name ="txttitle" value ="<?php echo $row-
>title;?>"></td>
</tr>
<tr>
<td><input size ="20" type ="text" name ="txtcategory" value ="<?php echo
$row->category;?>"></td>
</tr>
<tr>
<td><input size ="20" type ="text" name ="txtcompany" value ="<?php echo
$row->category;?>"></td>
</tr>
<tr>
<td><input size ="20" type ="text" name ="txtyear" value ="<?php echo $row-
>yearReleased;?>"></td>
</tr>
<tr>
</td>
</tr>
</form>
</table>
<?php
?>
<?php
mysqli_close($con);
?>
update.php
//syempre we have to update what we have edited langga..mayo tna sa database kay pwede
mo ma set sa tama ang pagkakamali mo ligad..ahahahh
<?php
if(!isset($_POST['txtvidId']) ||trim($_POST['txtvidId']==""))
$videoid=$_POST['txtvidId'];
$title=$_POST['txttitle'];
$category=$_POST['txtcategory'];
$company=$_POST['txtcompany'];
$year=$_POST['txtyear'];
$con=mysqli_connect("localhost","root","")or die(mysqli_error());
mysqli_select_db($con,"video-rental") or die(mysqli_error());
Header("Location:view_video.php");
?>
delete.php
//automatic delete langga..wala na kuskos balungos..delete agad..recommended sa mabilis
na pag move on..
<?php
if(isset($_GET['txtid']) !=="")
mysqli_select_db($con,"video-rental") or die(mysql_error());
$delete = $_GET['txtid'];
if($delete){
header("Location:view_video.php");
else{
echo 'Error';
?>