Havsbris lista fom, editerad 2021-01-18/MA

[insert_php]

// ”who1^” /Mats Ahlklo
// 2019-02-19 Added field ”Typ av evenemang” => ”event1^” /Mats Ahlklo
// 2019-08-26 Query date from 2019-01-01 /Mats Ahlklo
// 2019-12-08 Added field ”Cost”
// 2021-01-18 Query date selects actual Year /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(”2021-01-01”); // Query date from !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

$date= date(”Y”).”-01-01″; // Always select actual Year

// Select statement

$query = ”SELECT wp_domsten_nu_booking.booking_id, sort_date, booking_date, form, cost 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, 10);
$data= stristr(”{$row[’form’]}”,”starttime1″);
$stime = substr(”$data”,11, 5);
$data = stristr(”{$row[’form’]}”,”endtime1^”);
$etime = substr(”$data”,9, 5);
$cost = ”({$row[cost]})”;

// 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
”;
echo ”$bid;$bdate;$stime;$etime;$cost;”;

// 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
”;
echo ”$data2;”;

// Hämta upp Typ av evenemang ? Field $data is ”select-one^who1^DIK~text^event1^Årsmöte DIK~select-one^starttime1^19:00….”
$data= stristr(”{$row[’form’]}”,”event1^”); // In which pos do we find ”event1^”
$pos= strpos(”$data”, ”~select-one”) -7; // In which pos do we find ”~select-one” => 12, – length of ”event1^”
$data2= substr(”$data”,7, $pos); // Extract data from pos 7, ie after ”event1^” and with length of $pos
// echo ”TYP; $data2
”;
echo ”$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”;
echo ”$data2;”;

// Hämta upp efternamn
$data= stristr(”{$row[’form’]}”,”secondname1^”);
$pos= strpos(”$data”, ”~text”) -12;
$data2= substr(”$data”,12, $pos);
// echo ” $data2
”;
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
”;
echo ”$data2;”;

// Hämta upp telefon
$data= stristr(”{$row[’form’]}”,”phone1^”);
$pos= strpos(”$data”, ”~text”) -7;
$data2= substr(”$data”,7, $pos);
// echo ”TELEFON; $data2
”;
echo ”$data2
”;

$bid_l = ”({$row[booking_id]})”;
$bdate_l = $bdate;

}

// echo ”
”;

}

// ?>
[/insert_php]