Full Post Page
 

UPDATE INSERT DELETE RADIO TYPE INPUT IN PHP MYSQL

Category: Latest Source Code & Written by Admin On March-14-2024 17:22:50

<?php //1 CONNECTUON $servername="localhost"; $username="root"; $password=""; $dbname="test"; $con= mysqli_connect($servername,$username,$password,$dbname) or die('database connection failed'); //3 delete if(@$_GET['del_id']!=''){ $delquery="DELETE FROM radiotype WHERE each_id='".@$_GET['del_id']."'"; $rundel=mysqli_query($con,$delquery); if($rundel){ echo '<div class="alert alert-success text-center"> delete success</div>'; } } //2 insert if(isset($_POST['each_id'])){ // if(isset($_POST['submit'])){ if($_POST['each_id']==""){ // print_r($_POST); $EACH = @$_POST['EACH']; $insQuery="INSERT INTO radiotype (take_one) VALUES('$EACH')"; // echo $insQuery; die(); $Runins= mysqli_query($con,$insQuery); if($Runins){ echo '<div class="alert alert-success text-center"> insert success</div>'; }else{ echo '<div class=alert alert-danger> not uploaded</div>';}}} // 5 update if(@$_POST['each_id']!=''){ // $EACH = @$_POST['EACH']; // $upQuery="UPDATE INTO radiotype SET take_one='$EACH' WHERE each_id ='".@$_GET['each_id']."'"; $upQuery="UPDATE radiotype SET take_one ='".@$_POST['EACH']."' WHERE each_id = '".@$_POST['each_id']."' "; // echo $upQuery; die(); $runupdateQ = mysqli_query($con,$upQuery); if($runupdateQ){ echo '<div class="alert alert-success text-center"> update success</div>'; }else{ echo '<div class="alert alert-success text-center"> update success</div>';}} //fetcch data for updation if(@$_GET['uid']!=''){ $editQuery= "SELECT *FROM radiotype WHERE each_id ='".@$_GET['uid']."'"; $runEditQ= mysqli_query($con,$editQuery); $editData= mysqli_fetch_assoc($runEditQ); // print_r($editData) ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>RADIO TYPE INSERT IN PHP</title> <link rel="stylesheet" href="css/bootstrap.css" type="text/css"> <link rel="stylesheet" href="style.css" type="text/css"> </head> <body> <form action="" method="POST"> <fieldset> <legend class=" text-center">SELECT ONE INSERT IN PHP:</legend><center><div><div> <input type="hidden" name="each_id" value="<?php echo @$_GET['uid'] ?>" /> <input type="radio" name="EACH" value="HTML" <?php if('HTML'==@$editData['take_one']) echo 'checked="checked"'; ?> /> <label for="huey">HTML</label></div><div> <input type="radio" name="EACH" value="CSS" <?php if('CSS'==@$editData['take_one']) echo 'checked="checked"'; ?> /><label>CSS</label> </div><div> <input type="radio" name="EACH" value="LARAVEL" <?php if('LARAVEL'==@$editData['take_one']) echo 'checked="checked"'; ?> /> <label>LARAVEL</label></div> <input type="submit" name="SUBMIT" value="Submit" /></center></div></fieldset> </form> <table style="width: 100%;" border="1"> <thead> <tr><th>SR</th> <th>RADIO</th><th>OPERATION</th></tr> </thead><tbody> <?php //select query for fetching data frim databas $Disdata= "SELECT* FROM radiotype"; $RunDisdata=mysqli_query($con,$Disdata); if(mysqli_fetch_row($RunDisdata)>0){ // echo 'Row found'; $abc=1; foreach($RunDisdata as $key=> $value) {?><tr><td><?php echo $abc++ ?></td> <td><?php echo $value['take_one']?></td> <td><a href="index.php?uid=<?php echo $value['each_id'] ?>" class="btn btn-primary">Edit</a> <a href="index.php?del_id=<?php echo $value['each_id'] ?>" class="btn btn-danger">Delete</a> </td></tr> <?php } }else{ ?><?php echo ' <tr><td colsapn="10">ROW NOT FOUND</td></tr> '; }?> </tbody> </table></body></html>

Comments

Share your thoughts about this post

Why Choose Us:

Experienced Instructors: Our team of experienced instructors are passionate about coding and dedicated to helping you succeed. With years of industry experience and a knack for teaching, they'll guide you every step of the way. Beginner-Friendly Content: Don't worry if you're new to coding. Our tutorials are designed with beginners in mind, starting from the fundamentals and gradually building up to more advanced topics. Updated Content: Coding is a rapidly evolving field, and we're committed to keeping our content up-to-date with the latest trends, technologies, and best practices. Community Support: Learning to code is more fun and effective when you're part of a supportive community. Join our online community forums to connect with fellow learners, share insights, and collaborate on projects. Get Started Today:



Recent Posts

Advance Js Fetch API Part-5

June-06-2025 21:23:08


Advance Js Promise Part-4

June-06-2025 11:35:05


Advance js oop part-3

June-06-2025 08:25:42


ExpressJs API With Image Crud-3

June-02-2025 21:09:41


NodeJs API-MVC-2

June-02-2025 10:56:22


ExpressJs API Crud-1

June-02-2025 10:27:58


ExpressJs Files upload

June-02-2025 10:15:40


NodeJS Cookie and CsrfToken

May-30-2025 19:20:40


ExpressJS Session

May-30-2025 19:14:29


ExpressJS NodeJs Crud Part-2

May-27-2025 21:52:18


ExpressJS NodeJS Crud Part-1

May-27-2025 21:33:30


ExpressJS Authentication

May-26-2025 17:11:41


NodeJS ExpressJS Files Upload

May-26-2025 16:53:29



Angular Introduction

May-13-2025 21:02:32



Advance Js part-1

May-12-2025 15:41:29