
Are you a QOTWer? Do you want to start a thread that isn't a direct answer to the current QOTW? Then this place, gentle poster, is your friend.
( , Sun 1 Apr 2001, 1:00)
« Go Back | See The Full Thread

like this would do it if it were in a simple table in a MySQL database (which tbh, is probably your best bet, as that way, he could use phpmyadmin to enter the latest DJ and this script will grab the latest one, leaving the work up to him):
Have a table like this, called "dj_schedule":
"dj_schedule_id | dj | dj_image"
--code
function getLatestDJ(){
$con = mysql_connect("localhost","****","******");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("dbname", $con);
$result = mysql_query("SELECT DJ from dj_schedule order by dj_schedule_id desc limit 1");
while($row = mysql_fetch_array($result))
{
echo ("This is the next DJ: " . $row['DJ'] . "
}
}
--/code
EDIT: just as well it's not Python, all the bloody indentation has dissapeared!
( , Tue 13 Oct 2009, 17:28, 2 replies, latest was 16 years ago)

I've really bitten off more than I can chew here. I've only just figured out how to install bloody WAMP.
/Edit
Thanks...
( , Tue 13 Oct 2009, 17:29, Reply)

it's not LAMP - much easier to setup and easier to use (IMO).
Seriously though, if it has a PHP interpreter, it's likely that it has MySQL or if not, you could probably install it if you have those rights.
Is it his own server? If so, this really isn't that difficult, and I'm willing to help you get it up and running.
( , Tue 13 Oct 2009, 17:32, Reply)

As I know precisely diddly-squat about them. Time to get learning!
( , Tue 13 Oct 2009, 19:52, Reply)

I got lost around when the marquee tag stopped being cool
( , Tue 13 Oct 2009, 17:45, Reply)

Except I can't see it going unpopular, I really really <3 jQuery.
( , Tue 13 Oct 2009, 18:16, Reply)

Don't put the connection function into the dj function. Every time it's called, it'll create a new connection to the DB.
///// Put this in something like "lib/settings.php" /////
$settings['host'] = "localhost";
$settings['user'] = "username";
$settings['pass'] = "password";
$settings['dbname'] = "dbname";
///// Put this in your "lib/head.php" file //////
include_once('settings.php');
include_once('functions.php');
$con = mysql_connect($settings['host'],$settings['user'],$settings['pass']);
if (!$con) {die('Could not connect: ' . mysql_error());}
mysql_select_db($settings['dbname'], $con);
////// Put this in 'lib/functions.php' /////////
function getLatestDJ(){
global $con;
$result = mysql_query("SELECT DJ from dj_schedule order by dj_schedule_id desc limit 1");
$row = mysql_fetch_assoc($result);
return $row;
}
////// Put this in your front page.
include('lib/head.php');
// put this where you want.
$x = getLatestDJ();
echo "Next DJ is ".$x['DJ']." <img src=\"".$x['']."\" />";
( , Tue 13 Oct 2009, 18:15, Reply)

but I believe he'd only need it once.
Yours is, however, far more elegant. I'd rushed mine off the top of my head to point in the right direction.
( , Tue 13 Oct 2009, 18:53, Reply)
« Go Back | See The Full Thread