Page 1 of 1

Social tweak

Posted: Fri Apr 08, 2011 12:13 am
by bluealmondhostel
Hi, i wanted to share this with everyone. Keep in mind that my coding skills sucks, and im pretty sure there's a million ways to do the same i did with better cleaner code no need to point that out.

I wanted something to tell people that visit my website when the last reservation was done, sort of like social sites. The script basically logs in into phpRES and copies the date and nationality of the last reservation and dumps it a text. THen is up to whatever CMS or type or website you are using for your hotel to show it. I use Joomla and i just dumped into a module.

You can see it live in www.bluealmondhostel.com (top right corner)


Create a file WHATEVER.PHP

copy the code below

Code: Select all

<?php
//CONNECT TO DATABASE
$link = @mysql_connect('SERVER', 'USERNAME', 'PASSWORD') or die(mysql_error());
$select = @mysql_select_db('DATABASE') or die(mysql_error());

//RETRIEVE FIRST ENTRY
$result = @mysql_query('SELECT res_prenota2011.datainserimento, res_clienti.nazionalita, res_clienti.idclienti, res_prenota2011.idclienti FROM res_prenota2011, res_clienti WHERE res_clienti.idclienti = res_prenota2011.idclienti ORDER BY `res_prenota2011`.`datainserimento` DESC LIMIT 1,1') or die(mysql_error());

while ($row = mysql_fetch_assoc($result)) {
echo "Last reservation was made on {$row['datainserimento']} from {$row['nazionalita']}
";
echo $row['post'];
}
@mysql_free_result($result);

//CLOSE DATABASE
@mysql_close($link);
?>
call it with your browser.

Re: Social tweak

Posted: Wed Aug 17, 2011 6:09 pm
by bluealmondhostel
This will work with the new version of Hotel druid.

Re: Social tweak

Posted: Tue Jan 10, 2012 9:16 pm
by bluealmondhostel
Code update for 2012.
<?php
//CONNECT TO DATABASE
$link = @mysql_connect('localhost', 'USERNAME', 'PASSWORD') or die(mysql_error());
$select = @mysql_select_db('DATABASE') or die(mysql_error());

//RETRIEVE FIRST FIVE ENTRIES
$result = @mysql_query('SELECT res_prenota2012.datainserimento, res_clienti.nazionalita, res_clienti.idclienti, res_prenota2012.idclienti FROM res_prenota2012, res_clienti WHERE res_clienti.idclienti = res_prenota2012.idclienti ORDER BY `res_prenota2012`.`datainserimento` DESC LIMIT 1,1') or die(mysql_error());

while ($row = mysql_fetch_assoc($result)) {
echo "<h5>Last reservation was made on {$row['datainserimento']} from {$row['nazionalita']}</h5>\n";
echo $row['post'];
}
@mysql_free_result($result);

//CLOSE DATABASE
@mysql_close($link);
?>