<?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>
May-21-2024 22:46:29
thanks for code
March-21-2025 10:42:01
thank you for this
June-06-2025 21:23:08
June-06-2025 11:35:05
June-06-2025 08:25:42
June-02-2025 21:09:41
June-02-2025 10:56:22
June-02-2025 10:27:58
June-02-2025 10:15:40
May-30-2025 19:20:40
May-30-2025 19:14:29
May-27-2025 21:52:18
May-27-2025 21:33:30
May-26-2025 17:11:41
May-26-2025 16:53:29
May-26-2025 16:50:59
May-13-2025 21:02:32
May-13-2025 17:46:23
May-12-2025 15:41:29