Full Post Page

Latest Full Posts

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


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