Social tweak

Discuss here how to configure hoteldruid and better use its features.

Moderator: marco

Post Reply
bluealmondhostel
Posts: 64
Joined: Tue Sep 21, 2010 5:51 pm

Social tweak

Post 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.
bluealmondhostel
Posts: 64
Joined: Tue Sep 21, 2010 5:51 pm

Re: Social tweak

Post by bluealmondhostel »

This will work with the new version of Hotel druid.
bluealmondhostel
Posts: 64
Joined: Tue Sep 21, 2010 5:51 pm

Re: Social tweak

Post 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);
?>
Post Reply