Alright. So I'm trying to make a data table very similar to the members.php list. It features 4 columns of data, then the 5th is the delete column, where the admin clicks the delete link and it deletes the row of data from the database. For some reason, it eludes me.
Here's the datatable:
[syntaxhighlighter brush=php,first-line=1,highlight=0,collapse=false,html-script=false]
opentable('Discharges'
;
$result = dbquery("SELECT * FROM
fusion_discharges
"
;
$rows = dbrows($result);
if (!isset($_GET['rowstart']) || !isnum($_GET['rowstart'])) {
$_GET['rowstart'] = 0;
}
if ($rows) {
$i = 0;
echo "<table class='tbl-border' cellpadding='5' cellspacing='2' align='center' width='100%'>";
echo "<tr>";
echo "<td class='tbl2'><strong>Rank</strong></td>";
echo "<td class='tbl2'><strong>Name</strong></td>";
echo "<td class='tbl2'><strong>Type</strong></td>";
echo "<td class='tbl2'><strong>Date</strong></td>";
echo "<td class='tbl2'><strong>Options</strong></td>";
echo "</tr>";
$result = dbquery("SELECT * FROM
fusion_discharges
LIMIT ".$_GET['rowstart'].",20"
;
while ($data = dbarray($result)) {
$cell_color = ($i % 2 == 0 ? "tbl1" : "tbl2"
; $i++;
echo "<tr>";
echo "<td class='$cell_color'>".$data['discharge_rank']."</td>";
echo "<td class='$cell_color'>".$data['discharge_name']."</td>";
echo "<td class='$cell_color'>".$data['discharge_type']."</td>";
echo "<td class='$cell_color'>".$data['discharge_date']."</td>";
echo "<td class='$cell_color'><a href='".FUSION_SELF.$aidlink."&delete=".$data['discharge_name']."'>Delete</a></td>";
echo "</tr>";
}
echo "</table>";
} else {
echo "<center><br />There seems to be an error.<br /><br /></center>";
}
if ($rows > 20) {
echo "<div align='center' style='margin-top:5px;'>".makepagenav($_GET['rowstart'], 20, $rows, 3, FUSION_SELF.$aidlink."&"
."</div>";
}
closetable();[/syntaxhighlighter]
Now to my understanding, the following needs to be included which I threw in at the top of the file.
[syntaxhighlighter brush=php,first-line=1,highlight=0,collapse=false,html-script=false]if (isset($_GET['delete']) && isnum($_GET['delete'])) {
$result = dbquery("DELETE FROM
fusion_discharges
WHERE discharge_name='".$_GET['delete']."'"
;
redirect(FUSION_SELF.$aidlink);
}[/syntaxhighlighter]
I see no error in this code. I'm not new to coding either, I've been around these forums for a while, but I never tried something like this, and I really can't get it right and it's annoying me.
I'm open to suggestions from my fellow developers.