Bokningar
[insert_php]
// ”who1^” /Mats Ahlklo
session_start();
ob_start();
$host=”s410.loopia.se”; // Host name
$username=”cal_read@d68805″; // Mysql username
$password=”Havsbris1290″; // Mysql password
$db_name=”domsten_nu”; // Database name
$date= date(”Y-m-d”); // Get system date. Make as a comment when Query a date
// $date= date(”2017-01-01”); // Query date from !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// Select statement
$query = ”SELECT wp_domsten_nu_booking.booking_id, sort_date, booking_date, form FROM wp_domsten_nu_booking RIGHT JOIN wp_domsten_nu_bookingdates ON wp_domsten_nu_booking.booking_id=wp_domsten_nu_bookingdates.booking_id WHERE (booking_date >= ’$date’ AND `trash` = 0) ORDER BY booking_date”;
// Connect to server and select database
$conn = mysqli_connect($host, $username, $password, $db_name);
if(!$conn)
{
echo ’Database Error: ’ . mysqli_connect_error() ;
exit;
}
// Choose correct char set
mysqli_set_charset($conn,”utf8″);
// Fetch Data
$result = mysqli_query($conn,$query);
// Display Data
while ($row = mysqli_fetch_array($result))
{
// Lägga ihop Bokningsdatum + stopptid
$bid = ”({$row[booking_id]})”;
$bdate = substr(”{$row[’booking_date’]}”, 0, 11);
$data= stristr(”{$row[’form’]}”,”starttime1″);
$stime = substr(”$data”,11, 5);
$data = stristr(”{$row[’form’]}”,”endtime1^”);
$etime = substr(”$data”,9, 5);
// echo ” $bid $bdate
”;
if ($bid == $bid_l AND $bdate == $bdate_l) { // If current booking id and booking date is the same as the last, skip showing info
// NOP because single bookings have 2 posts in file wp_domsten_nu_bookingdates
}
else {
echo ”BOKNING $bid fom $bdate $stime tom $etime
”;
// Registrerat datum
// echo ”REGISTRERAT; {$row[’modification_date’]}
”;
// Hämta upp Vem har bokat ?
$data= stristr(”{$row[’form’]}”,”who1^”); // Field $data is ”who1^DBF~text^event1^1,6……..”
$pos= strpos(”$data”, ”~text”) -5; // In which pos do we find ”~text” => 9, – length of ”who1^”
$data2= substr(”$data”,5, $pos); // Extract data from pos 5, ie after ”who1^” and with length of $pos
echo ”TYP; $data2
”;
// Hämta upp förnamn
$data= stristr(”{$row[’form’]}”,”name1^”);
$pos= strpos(”$data”, ”~text”) -6;
$data2= substr(”$data”,6, $pos);
echo ”BOKAT AV; $data2”;
// Hämta upp efternamn
$data= stristr(”{$row[’form’]}”,”secondname1^”);
$pos= strpos(”$data”, ”~text”) -12;
$data2= substr(”$data”,12, $pos);
echo ” $data2
”;
// Hämta upp e-mail
$data= stristr(”{$row[’form’]}”,”email1^”);
$pos= strpos(”$data”, ”~text”) -7;
$data2= substr(”$data”,7, $pos);
echo ”EMAIL; $data2
”;
// Hämta upp telefon
$data= stristr(”{$row[’form’]}”,”phone1^”);
$pos= strpos(”$data”, ”~text”) -7;
$data2= substr(”$data”,7, $pos);
echo ”TELEFON; $data2
”;
$bid_l = ”({$row[booking_id]})”;
$bdate_l = $bdate;
}
echo ”
”;
}
// ?>
[/insert_php]