Skip to content

Commit

Permalink
Delete record working
Browse files Browse the repository at this point in the history
  • Loading branch information
asakpke committed Nov 23, 2023
1 parent c3861f3 commit ef6fa84
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 5 deletions.
9 changes: 9 additions & 0 deletions Example1/Delete.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php
ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');
error_reporting(E_ALL);

require 'Example1.php';

$example1 = new Example1();
$example1->delete($_GET['id']);
9 changes: 9 additions & 0 deletions Example2/Delete.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php
ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');
error_reporting(E_ALL);

require 'Example2.php';

$example2 = new Example2();
$example2->delete($_GET['id']);
35 changes: 30 additions & 5 deletions PRC.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ function __construct($opt = null)
<meta name="author" content="<?= $this->app['developer'] ?>">
<meta name="generator" content="<?= $this->app['nameShort'].' '.$this->app['version'] ?>">
<title><?= $this->app['nameShort'].' - '.$this->app['name'] ?></title>
<link rel="apple-touch-icon" sizes="180x180" href="<?= $this->app['pathUrl'] ?>/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="<?= $this->app['pathUrl'] ?>/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="<?= $this->app['pathUrl'] ?>/favicon-16x16.png">
<link rel="manifest" href="<?= $this->app['pathUrl'] ?>/site.webmanifest">
<link href="<?= $this->app['pathUrl'] ?>/style.css?v=<?= $this->app['version'] ?>" rel="stylesheet">
</head>
<body>
Expand Down Expand Up @@ -98,7 +102,7 @@ function list()
} // if num_rows
?>
<main>
<h2><?= $this->tbl['nameUcF'] ?> Records <a href="<?= $this->app['pathUrl'].'/'.$this->tbl['nameUcF'] ?>/Add.php" style="text-decoration: none;">+ <small>(add new)</small></a></h2>
<h2><?= $this->tbl['nameUcF'] ?> Records <a href="<?= $this->app['pathUrl'].'/'.$this->tbl['nameUcF'] ?>/Add.php" title="Add new record">+</a></h2>
<?php
showMsg();
?>
Expand Down Expand Up @@ -135,7 +139,7 @@ function list()
echo "<td>
<a href=\"{$this->app['pathUrl']}/{$this->tbl['nameUcF']}/View.php?id={$row['id']}\">View</a> |
<a href=\"{$this->app['pathUrl']}/{$this->tbl['nameUcF']}/Edit.php?id={$row['id']}\">Edit</a> |
<a href=\"#\">Delete</a> (not working)
<a href=\"{$this->app['pathUrl']}/{$this->tbl['nameUcF']}/Delete.php?id={$row['id']}\">Delete</a>
</td>";
?>
</tr>
Expand Down Expand Up @@ -183,7 +187,7 @@ function view($id)
?>
</main>
<?php
} // view
} // view()

function add()
{
Expand Down Expand Up @@ -245,7 +249,7 @@ function add()
</form>
</main>
<?php
} // add
} // add()

function edit($id)
{
Expand Down Expand Up @@ -326,7 +330,28 @@ function edit($id)
</form>
</main>
<?php
} // edit
} // edit()

function delete($id)
{
$result = mysqli_query(
$this->dbConn,
"DELETE FROM {$this->tbl['name']} WHERE id = $id;"
);

if ($result) {
$msg = "{$this->tbl['nameUcF']} record deleted successfully.";
$color = 'green';
} // if result
else {
$msg = "Error in deleting {$this->tbl['nameUcF']} record.";
$color = 'red';
}

$loc = "{$this->app['pathUrl']}/{$this->tbl['nameUcF']}/index.php?msg={$msg}&color={$color}";
header("Location: $loc");
exit;
} // delete()

function blob($id, $name)
{
Expand Down
9 changes: 9 additions & 0 deletions Users/Delete.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php
ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');
error_reporting(E_ALL);

require 'Users.php';

$user = new Users();
$user->delete($_GET['id']);
Binary file added android-chrome-192x192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added android-chrome-512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apple-touch-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added favicon-16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added favicon-32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added favicon.ico
Binary file not shown.
1 change: 1 addition & 0 deletions site.webmanifest
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"name":"","short_name":"","icons":[{"src":"/android-chrome-192x192.png","sizes":"192x192","type":"image/png"},{"src":"/android-chrome-512x512.png","sizes":"512x512","type":"image/png"}],"theme_color":"#ffffff","background_color":"#ffffff","display":"standalone"}

0 comments on commit ef6fa84

Please sign in to comment.