SQL/PHP project - easy you think?

Soldato
Joined
4 Nov 2006
Posts
2,738
Location
Yorkshire
Hi,

I want to develop a little service status for our work. Basically I want a page that has something like:

• Service 1 - ONLINE (maybe online.gif)
• Service 2 - ONLINE
• Service 3 - OFFLINE (maybe offline.gif)

etc etc and I want this to be pulled from a little SQL database which is controlled by a small admin.php page which has each service listed, with maybe either a dropdown box or checkbox saying whether it's online or not, and then the changes made here will reflect the front page

Do you think that would be easy? Also, if that worked a treat, i'd like to also be able to put in a little schedule for example when I knew we had planned downtime at a particular time, it would auto change?

Thanks
 
Soldato
OP
Joined
4 Nov 2006
Posts
2,738
Location
Yorkshire
ok ok ... anyone want to help me begin?

I guess it would be something easy like IF STATUS = OFFLINE then <html snippet> etc etc

I could probably do that myself, but would i have to write that query for every service I have or can you do that in one array or something? sorry for sounding like a pleb
 
Soldato
Joined
9 May 2005
Posts
4,524
Location
Nottingham

That was a question, I don't know your database schema so I can't answer that. If you can then you would simply issue that query and return the results in an array. You can then iterate the results array and generate the required status information.
 
Soldato
Joined
15 Nov 2008
Posts
5,060
Location
In the ether
You'd create a table with something like

CREATE TABLE status (ID INT(10),NAME VARCHAR(80), STATUS INT(1))

you'd have a PHP page that first connects to the database

(normally this is something like $conn = mysql_connect($db,$user,$passwd);

then you'd execute an SQL select statement something like
$sql = SELECT * FROM STATUS;
$stmt = mysql_prepar($conn,$sql);
$res = mysql_execute($conn,$stmt);

then have something like

print "<table><tr><td>ID</td><td>NAME</td><td>STATUS</td></tr>
while(@record = statement.fectchrow()){
print "<tr>";
$crec=1;
foreach(@record as $colum){
if($crec==3){
if($column ==1){
print "<TD>SYSTEM IS UP</TD>";
}else{
print "<TD>SYSTEM IS DOWN</TD>";
}
}else{
print "<TD>$column</TD>";

}
print "</TR>"
}

print "</TABLE>";
}
 
Soldato
Joined
26 Dec 2003
Posts
16,522
Location
London
You'd create a table with something like

CREATE TABLE status (ID INT(10),NAME VARCHAR(80), STATUS INT(1))

you'd have a PHP page that first connects to the database

(normally this is something like $conn = mysql_connect($db,$user,$passwd);

then you'd execute an SQL select statement something like
$sql = SELECT * FROM STATUS;
$stmt = mysql_prepar($conn,$sql);
$res = mysql_execute($conn,$stmt);

then have something like

print "<table><tr><td>ID</td><td>NAME</td><td>STATUS</td></tr>
while(@record = statement.fectchrow()){
print "<tr>";
$crec=1;
foreach(@record as $colum){
if($crec==3){
if($column ==1){
print "<TD>SYSTEM IS UP</TD>";
}else{
print "<TD>SYSTEM IS DOWN</TD>";
}
}else{
print "<TD>$column</TD>";

}
print "</TR>"
}

print "</TABLE>";
}

You realise this has about 50 syntax errors in it, right?
 
Top Bottom