3s-gtech Posted March 14, 2012 Posted March 14, 2012 Hey - we're hoping someone out there who has much greater coding power than myself and my apprentice coder monkey can help! We use Xibo to display school notices, photos etc on our digital signage. All good there, just use Powerpoint for the bulk of the content. What we'd like to do though, is have a simple page which displays whose birthday it is today. This can be as simple as possible - I was thinking to just dump the birthdays from SIMS as a text or csv file which can be easily changed every year - then to have a bit of script in a webpage or similar which referenced this, looked at today's date, and outputted the names on the screen. Probably pretty straightforward, but my programming is limited to C64 basic and html - nothing further yet! Can anyone help, or do you have a similar system in place we could borrow (with application of appropriate virtual snack treat). Thanks!
3s-gtech Posted March 16, 2012 Author Posted March 16, 2012 We've done this now as simply as we could. Dumped Forename, Surname and DOB from SIMS into a csv, whacked PHPMyAdmin on the Xibo Server (it's not on the internet) and imported the csv into the MySQL in a new database. Then some simple php calls the DB and searches for dd/mm from the DOB and matches it against today's date (NTP for the server will help, but just manually set it for now). The result is pretty good!
glennda Posted March 16, 2012 Posted March 16, 2012 If you design an HTML page that you want it to look like I'll knock up the php side for you
3s-gtech Posted March 16, 2012 Author Posted March 16, 2012 Cheers, we've done it now though. The html was a massive cheat - the main Xibo display is a Powerpoint slideshow with a background made of different elements, we just print-screened it to a png, then set it to the background property for the webpage for consistency. Cheating, but works fine.
glennda Posted March 16, 2012 Posted March 16, 2012 Cheers, we've done it now though. The html was a massive cheat - the main Xibo display is a Powerpoint slideshow with a background made of different elements, we just print-screened it to a png, then set it to the background property for the webpage for consistency. Cheating, but works fine. Ah right I read i ignored the second post lol!
BKGarry Posted May 30, 2012 Posted May 30, 2012 sorry to resurect this old post, but could you send me a copy of your PHP script? not too good with php and would like to do this too
3s-gtech Posted May 30, 2012 Author Posted May 30, 2012 Send me a PM and I'll remember in the morning. Just remember to dump the csv of students and DoBs into MySQL via PHPMyAdmin or similar. I'll copy in the format used by the php if I can find it now!
titch Posted October 9, 2012 Posted October 9, 2012 Any chance of a step by step for this? Would love to get this going on our xibo but am unsure about the PHP and msql etc. Cheers in advance. Rich
3s-gtech Posted October 9, 2012 Author Posted October 9, 2012 The MySQL is a simple DB (called birthdays) imported into PHPMyAdmin from a csv file dumped from SIMS using Forename, Surname and DoB (dd/mm/yyyy). The server needs to be running Apache, MySQL and PHP. The PHP itself is fairly simple: include('config.php'); ?> Untitled Document <br /> body {<br /> margin-left: 0px;<br /> margin-top: 0px;<br /> margin-right: 0px;<br /> margin-bottom: 0px;<br /> background-image: url(Background.png);<br /> background-repeat: no-repeat;<br /> }<br /> body,td,th {<br /> font-family: "Segoe UI Light";<br /> color: #000;<br /> font-size: large;<br /> }<br /> </pre><table width="100%" border="0" cellspacing="0" cellpadding="0"> $myDate = date('d/m'); $badgesql = mysql_query("SELECT * FROM birthdays.students WHERE `Date` LIKE '%$myDate%'"); // birthdays is the DB, the table is called students - you can change these $badgecheck = mysql_num_rows($badgesql); $check = $badgecheck; if($check==0) echo('No birthday\'s today!'); else if($badgecheck!=0) { while($badge = mysql_fetch_array($badgesql)) { echo(''.$badge[Firstname].' '.$badge[surname].' '); } } </
titch Posted October 9, 2012 Posted October 9, 2012 Thank you thats great. Let you know if I get it up and running.
titch Posted October 10, 2012 Posted October 10, 2012 Thanks for the help. I have gone a slightly different route though and modified a script I found on the net. You can just add it into an embedded region on xibo. I have an excel spreadsheet that will convert usernames birthdays into the correct format so they can just be copied into the script. One thing to note is that names cant have symbols in them as it throws an error. I am sure this script could be tidied up but I am no script master, and it works so have left it at that. var arrBday = [ ['Joe Blogs Class4','09/28/2001'], ['Michael Ball Class4','09/28/2001'], ['Donald Duck Class6','01/22/2004'] ]; function displayBdayList(today){ var bday,strList=''; for (var i=0;i bday = new Date(arrBday[1]); if (!isNaN(bday) && bday.getMonth()==today.getMonth() && bday.getDate()==today.getDate()) strList+='- '+arrBday[0]+" ("+(today.getFullYear()-bday.getFullYear())+")"; } if (strList=='') strList='- NONE' document.write("Today's Birtdays:"+strList) } displayBdayList(new Date()); ??
titch Posted October 10, 2012 Posted October 10, 2012 Actually can anyone help with my script. Whatever I do the text size doesn't seem to increase. What am I doing wrong? Cheers
3s-gtech Posted October 10, 2012 Author Posted October 10, 2012 You'll need: <br /> #text {<br /> font-family: Arial;<br /> font-size: 14px;<br /> }<br /> <br /> <br /> var arrBday = [<br /> ['Joe Blogs Class4','09/28/2001'],<br /> ['Michael Ball Class4','09/28/2001'],<br /> ['Donald Duck Class6','01/22/2004']<br /> ];<br /> <br /> function displayBdayList(today){<br /> var bday,strList='';<br /> for (var i=0;i<arrBday.length;i++){<br /> bday = new Date(arrBday[i][1]);<br /> if (!isNaN(bday) && bday.getMonth()==today.getMonth() && bday.getDate()==today.getDate())<br /> strList+='- '+arrBday[i][0]+" ("+(today.getFullYear()-bday.getFullYear())+")<br>";<br /> }<br /> if (strList=='') strList='- NONE'<br /> document.write("<div id="text"><h4>Today's Birthdays:"+strList) } displayBdayList(new Date()); To change the formatting, change the code in the css in the head of the page. 1
titch Posted October 10, 2012 Posted October 10, 2012 Thanks for that. Doesnt seem to have worked though. Not sure what I am doing wrong or if it is something to do with xibo. Any chance anyone can test it on another xibo install? TA
cleverleyson Posted March 1, 2013 Posted March 1, 2013 (edited) Im having a little problem trying to get this to work, I've created a database in Phpmyadmin called Birthdays.students with a table of three fields, Forname, Surname and Dob. I then add the code above into an emded page in xibo. I think this might be where i'm going wrong. Do I need to create a .php or put said code into xibo? Also where should i put config.php I feel like I'm nearly there! Thanks for all the help above! Update: Seems i've got config.php to connect to the database! but i get this error when viewing .birthday.php " [h=1]Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\xampp\htdocs\Birthdays.php on line 49 No birthday's today!"[/h] Edited March 1, 2013 by cleverleyson
BKGarry Posted March 1, 2013 Posted March 1, 2013 I have a birthdays.php running on a seperate webserver and just get xibo to view that webpage :-) Just a basic LAMP server nothing special, runs several websites, including wordpress, but the birthdays.php just sits in its own folder and works :-) Hope this helps
3s-gtech Posted March 1, 2013 Author Posted March 1, 2013 Im having a little problem trying to get this to work, I've created a database in Phpmyadmin called Birthdays.students with a table of three fields, Forname, Surname and Dob. I then add the code above into an emded page in xibo. I think this might be where i'm going wrong. Do I need to create a .php or put said code into xibo? Also where should i put config.php I feel like I'm nearly there! Thanks for all the help above! We get Xibo to display an external webpage running on a webserver. Nothing embedded.
cleverleyson Posted March 1, 2013 Posted March 1, 2013 Ahhh Cheers for the advice, I still get get it to work tho! been trying to find out why i get the error message " [h=1][/h][h=1]"Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\xampp\htdocs\birthdays\Birthdays.php on line 48 No birthday's today!" I think it might be the way ive setup the tables? I think its something simple. Losing alot of time to this already![/h][h=1]"[/h]
glennda Posted March 1, 2013 Posted March 1, 2013 what is your host setup? thats looking for an absolute path - is that written in the code (i've not seen it)
cleverleyson Posted March 1, 2013 Posted March 1, 2013 (edited) Im using the code posted from above. <?php include('config.php'); ?> Untitled Document body { margin-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; background-image: url(Background.png); background-repeat: no-repeat; } body,td,th { font-family: "Segoe UI Light"; color: #000; font-size: large; } <?php $myDate = date('d/m'); $badgesql = mysql_query("SELECT * FROM birthdays.students WHERE `Date` LIKE '%$myDate%'"); // birthdays is the DB, the table is called students - you can change these $badgecheck = mysql_num_rows($badgesql); $check = $badgecheck; if($check==0) echo('No birthday\'s today!'); else if($badgecheck!=0) { while($badge = mysql_fetch_array($badgesql)) { echo(''.$badge[Firstname].' '.$badge[surname].''); } } $host = "localhost"; // if the database is locally installed $dbuser = "'Birthdays"; $dbpwd = "XXXX"; $db = "birthdays."; // this is the database name $connect = mysql_pconnect($host, $dbuser, $dbpwd); if(!$connect) echo("Could not connect to database..."); else $select = mysql_select_db($db); ?> The database is on the same server as xibo server, hence localhost. could it be the the tables need to be a type (its text atm) Also Would i need to move the year from date? Edited March 1, 2013 by cleverleyson
MHUK Posted March 4, 2013 Posted March 4, 2013 (edited) @cleverleyson I had this error. In the table, is the column with the dates in called dob? I had mine called "Date of Birth" but once renamed to "Date" to match the code it worked. I set my First/Last name columns to VARCHAR and the DOB to Date. Edited March 4, 2013 by MHUK
jaminben Posted March 5, 2013 Posted March 5, 2013 (edited) @cleverleyson I had this error. In the table, is the column with the dates in called dob? I had mine called "Date of Birth" but once renamed to "Date" to match the code it worked. I set my First/Last name columns to VARCHAR and the DOB to Date. Just as a FYI you could have also changed the SQL query to match the database column name... From: $badgesql = mysql_query("SELECT * FROM birthdays.students WHERE `Date` LIKE '%$myDate%'") To: $badgesql = mysql_query("SELECT * FROM birthdays.students WHERE `[b]Date of Birth[/b]` LIKE '%$myDate%'") This may make it easier to work out in the future if you ever come back to it as the DB column name will be what your expecting it to be (i.e a DOB). The reason for the error is that your code is expecting a result of some number of rows but you had an error in the query which the mysql_num_rows() couldn't interpret. You could prevent this with something like: $badgesql = "SELECT * FROM birthdays.students WHERE `[b]Date of Birth[/b]` LIKE '%$myDate%'" if (mysql_query($badgesql)){ echo "This Worked - Continue Code Here"; }else{ echo "This Failed - Exit Code Here: " . mysql_error(); exit(); } Edited March 5, 2013 by jaminben 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now