IMP
How to do insert edit and delete on same page
6 When we do insert, fetch, edit on same page
do insert and fatch as previous
in data fetch table provide collom for edit botton
<form action="future_movies.php" method="post" enctype="multipart/form-data">
<input type="submit" id="editm" name="editm" value="Edit" placeholder="Movie Name" required="">
<input type="hidden" id="idedit" name="idedit" value="<?php echo $data['id'];?>" placeholder="Movie Name" required="">
</form>
Then After Fatch data from DB when we click on edit botton in data fatch table.
<?php
if(isset($_POST['newedit']) && !empty($_POST['newedit']))
{
$sql1="select * from screen where id = '".$_POST['newedit']."'";
$row = mysql_query($sql1);
while($data1 = mysql_fetch_array($row))
{
$name = $data1['name'];
$seats = $data1['seats'];
$mshow1 = $data1['mshow'];
$updatedata = $data1['id'];
}
}
?>
<h3 id="forms-example" class="">Add Screen</h3> <br
<form action="function.php" method="post" class="form-horizontal" enctype="multipart/form-data">
<div class="form-group">
<label for="inputEmail3" class="col-sm-2 control-label hor-form">Screen Name</label>
<div class="col-sm-10"> <div class="input-group"><span class="input-group-addon"> <i class="fa fa-television"></i>
</span>
<input type="text" value="<?php echo $name; ?>" class="form-control" id="name" name="name" placeholder="Screen Name" required="" ></div>
</div>
</div>
<div class="form-group">
<label for="checkbox" class="col-sm-2 control-label">screen show</label>
<div class="col-sm-8">
<div class="checkbox-inline"><label><input type="checkbox" name="mshow" id="mshow" value="2D"> 2D</label></div>
<div class="checkbox-inline"><label><input type="checkbox" checked="" name="mshow" id="mshow" value="3D"> 3D</label></div>
<div class="checkbox-inline"><label><input type="checkbox" disabled="" name="mshow" id="mshow"value="both"> Both</label></div>
</div>
</div>
<div class="form-group">
<label for="inputEmail3" class="col-sm-2 control-label hor-form">Total Seats</label>
<div class="col-sm-10"> <div class="input-group"><span class="input-group-addon"> <i class="fa fa-dashboard"></i>
</span>
<input type="text" value="<?php echo $seats; ?>" class="form-control" id="seats" name="seats" placeholder="Total Seats" required=""></div>
</div>
</div>
Then after go to insert from section where we insert data in DB change botton value if insert data then botton show add new movie and when user click on edit botton from fetch table botoon change to update.
<?php
if(isset($_POST['editm']) && ($_POST['editm']=='Edit'))
{ $value = 'Update'; } else { $value = 'add new movie'; } ?>
<input type="submit" class="btn btn-default" id="addnewmovie" name="addnewmovie" value="<?php echo $value; ?>"
<input type="hidden" class="btn btn-default" id="submitid" name="submitid" value="<?php echo $submitid; ?>">
Then go to function.php file and add update query for update data
if(isset($_POST['addnewmovie']) && !empty($_POST['addnewmovie'])=='Update')
{
$sqlup = "UPDATE `movie` SET `name` = '".$_POST['name']."', `date` = '".$_POST['date']."' where `movie`.`id` = '".$_POST['submitid']."'"; //////we create varible $submitid and save velue of id ($_post['id']) and when we send id use only submitid in form id and name in hidden input of update botton.
$run=mysql_query($sqlup);
}
header ("location:future_movies.php");
Comments
Post a Comment