A Simple PHP Script (MySQL, Too) To Track Radio Station Song Requests, Part 4
In the last post, I discussed the beginnings of the administrative backend for a Web-based radio station request system written in PHP with MySQL.
To wrap the project up, we just need two more pages: One that will list off all the DJs that are in the system now, and one that will delete a DJ record. [Actually, we need to replicate this for the admins of the system, too. However, we're going to be lazy and just discuss the DJ section, since the admin records are fundamentally the same thing.]
Task 1: Display The Current DJ List (dj_list.php)
Other than checking for the presence of the login session variable, there’s nothing to this script: Just get your records and put them out in a table.
<?php
session_start();
if(!isset($_SESSION['login']) || $_SESSION['login'] == "") {
header('Location: index.php');
}
require_once("../conn.inc.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>DJ List</title>
</head>
<body>
<h1>DJ List</h1>
<?php
$sql = "SELECT * FROM djlist ORDER BY dj_id DESC";
$rs = mysql_query($sql) or die('Cannot get DJ records');
if(mysql_num_rows($rs) == 0) {
echo "<p>There are no DJs.</p>n";
}
else {
echo "<table>n";
echo "t<tr>n";
echo "tt<th>Edit</th><th>Public Name</th><th>Delete</th>n";
echo "t</tr>n";
while($row = mysql_fetch_array($rs)) {
echo "t<tr>n";
echo "tt<td><a href="dj_edit.php?id=$row[dj_id]">Edit</a></td><td>$row[dj_public_name]</td><td><a href="dj_delete.php?id=$row[dj_id]">Delete</a></td>n";
echo "t</tr>n";
}
echo "</table>n";
}
?>
<p><a href="dj_add.php">Add DJ</a> | <a href="menu.php">Menu</a> </p>
<p>&nbsp;</p>
</body>
</html>
Task 2: Delete A DJ Record (dj_delete.php)
This is really easy. All we do is get the DJ ID, delete the record, and kick the user back to the listing.
session_start();
if(!isset($_SESSION['login']) || $_SESSION['login'] == "") {
header('Location: index.php');
}
require_once("../conn.inc.php");
$id = $_GET['id'];
$rs = mysql_query("DELETE FROM djlist WHERE dj_id = $id") or die('Cannot delete record');
header('Location: dj_list.php');
And that’s pretty much it (again, after we convert the DJ management files to work with the admins). All that’s left is to install it; and that’s as simple as uploading the files to your Web server and running the SQL scripts through your MySQL database.
Which leads to how one goes about getting this code. That’s easy: A Simple PHP Script (MySQL, Too) To Track Radio Station Song Requests Demo Code
Related Posts
- A Simple PHP Script (MySQL, Too) To Track Radio Station Song Requests, Part 3 (100.5)
- A Simple PHP Script (MySQL, Too) To Track Radio Station Song Requests, Part 2 (99)
- A Simple PHP Script (MySQL, Too) To Track Radio Station Song Requests, Part 1 (96.2)
- National Weather Service Current Observations PHP Script Project Has First Release (15.9)
The numbers inside parentheses are relevance scores. Scoring is based, in order of priority, on title, category, content and tags. The higher the score, the more likely that post relates to this post.


[...] « A Simple PHP Script (MySQL, Too) To Track Radio Station Song Requests, Part 2 A Simple PHP Script (MySQL, Too) To Track Radio Station Song Requests, Part 4 » [...]
for some reason @ the top of every page it shows some php here a pic of the request
and i can just change page by going to admin/index.php idk if i should be able to or should it say you must be login to veiw this?
@Michael: You’ve either added a closing PHP tag prematurely, failed to properly escape a double-quoted sequence, or otherwise miscopied the code. I can help you with your specific implementation in exchange for a Wish List purchase, as described under the link above, “Need More Help Or Want To Say Thanks?”