Full Post Page

Latest Full Posts

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: Ready to kickstart your coding journey? Subscribe to [Rupesh-Tech] on YouTube and start learning today! Don't forget to hit the bell icon to receive notifications whenever we upload new tutorials or go live with Q&A sessions. Remember, coding opens up a world of endless possibilities. Whether you're dreaming of becoming a software developer, launching your own startup, or simply exploring a new hobby, [Rupesh-Tech] is here to help you turn your coding aspirations into reality. Let's code together and unleash your full potential! Feel free to customize the content to better suit Rupesh-tech channel's branding and audience.



Recent Posts

IMAGE CRUD PHP MYSQL

September-04-2024 09:18:37


complete php project mysql

August-11-2024 11:31:12


LARAVEL 11 crud step by step

August-02-2024 23:22:25