Full Post Page
 

WEBSITE URL INSERT UPDATE DELETE READ PHP MYSQL

Category: Latest Source Code & Written by Admin On May-12-2024 02:44:34

<?php error_reporting(0); $servername="localhost"; $username="root"; $password=""; $database="test"; $con= mysqli_connect($servername,$username,$password,$database) or die('connection failed'); if($con){ // echo 'Connection is set'; } //delete if($_GET['del']){ $delSql= "DELETE FROM webiste WHERE website_id= '".$_GET['del']."' "; // echo $delSql; $RunDel= mysqli_query($con,$delSql); if($RunDel){ echo '<h3 style="text-align:center;color:red;">data deteted !!!</h3>'; ?> <meta HTTP-EQUIV="Refresh" content="4; URL=index.php"><?php } } // if(isset($_POST['save'])){ if(isset($_POST['website_id'])){ // print_r($_POST);{} // if($_POST['website_id']==''){ $insql= "INSERT INTO webiste (website_url) VALUES('".$_POST['url']."')"; // echo $insql; $Runquery= mysqli_query($con,$insql); if($Runquery){ echo '<h3 style="text-align:center;color:green;">data inserted !!!</h3>'; ?> <meta HTTP-EQUIV="Refresh" content="4; URL=index.php"><?php } } // } //fetch and update if($_GET['uid']!=''){ $fet="SELECT *FROM webiste WHERE website_id= '".$_GET['uid']."'"; $runfet=mysqli_query($con,$fet); // echo print_r($runfet); $editdata=mysqli_fetch_assoc($runfet); } if($_POST['website_id']!=''){ $upSQL= "UPDATE webiste SET website_url='".$_POST['url']."' WHERE website_id='".$_POST['website_id']."' "; // echo $upSQL; $runupsql= mysqli_query($con,$upSQL); if($runupsql){ echo '<h3 style="text-align:center;color:green;">data updated !!!</h3>'; } } ?> <!DOCTYPE html> <html> <body> <h1>WEBSITE URL CRUD</h1> <form action="<?php $_SERVER["PHP_SELF"] ?>" method="POST"> <label for="homepage">Add your homepage:</label> <input type="hidden" id="homepage" name="website_id" value="<?php echo $_GET['uid']; ?>"> <input type="url" id="homepage" name="url" value="<?php echo $editdata['website_url'] ?>"><br><br> <input type="submit" name="save"> </form> <table width="100%" cellpadding="10px" cellspacing="10px" border="2px"> <thead> <tr style="text-align:center; background-color:black;color:#fff;"> <th>Sr No</th> <th>Webiste Url</th> <th>Operation</th> </tr> </thead> <tbody> <?php $disSql ="SELECT *FROM webiste"; $rundisql= mysqli_query($con,$disSql); if(mysqli_fetch_row($rundisql)>0){ // echo 'ROW Found'; $abc=1; foreach($rundisql as $key=>$value){ echo '<tr style="text-align:center;"> <td> '.$abc++.'</td> <td> <a href=" '.$value['website_url'].'"> '.$value['website_url'].'</a></td> <td> <a href="index.php?del='.$value["website_id"].'">DELETE</a> <a href="index.php?uid='.$value["website_id"].'">UPDATE</a> </td> </tr>'; } } ?> </tbody> </table> </body> </html>

Comments

saneha

May-21-2024 22:46:29

thanks for code


mdramjan

March-21-2025 10:42:01

thank you for this


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