Get help from the best in academic writing.

MYSQL / PHP Help – Selecting next available consecutive dates from a table

….Need
help! I have made this table with all the dates of the years going upto
2063, to keep it simple, it contains 3 columns which have been
pre-popluated, example as follows… 
$previousDate = mysql_query(“SELECT * FROM calendar WHERE
autoInc < $requestedDate AND status='available' ORDER BY autoInc
DESC”);
If you need more please let The story so far…
Actual table
AutoIncNo | BookingDate | Status
The calendar is in 2 parts.
1) Calendar to select a date
2) A list menu to select the amount of nights they wish to stay.
So I take the original date (the one they select) and rearrange the format to suit the table…
$CalendarDate = str_replace(“/”, “-“, “$CalendarDate”);
$QueryDate = date(“Y-m-d”, strtotime($CalendarDate));
Connect to the database…
include_once(‘../connect/connectdatabase.php’);
Run the first query to check if the dates they require are available.
$QueryDate is the date they select
$NightsForQuery is the amount of nights they want to stay
$CalendarQuery = mysql_query(“SELECT * FROM BookingsCalendar WHERE BookingDate=’$QueryDate’ LIMIT 1”);
while($row = mysql_fetch_array($CalendarQuery)) {$AutoInc = $row[“AutoIncNo”];}
$AutoInc2 = $AutoInc $NightsForQuery – 2;
$SelectDates = mysql_query(“SELECT * FROM BookingsCalendar WHERE AutoIncNo BETWEEN $AutoInc AND $AutoInc2”);
while($row = mysql_fetch_array($SelectDates)) {
$AutoIncNo = $row[“AutoIncNo”];
$BookingDate = $row[“BookingDate”];
$Status = $row[“Status”];

if ($Status == ‘booked’) {
$LastBookedDate = $BookingDate;
$LastAutoIncNo = $AutoIncNo;
$Handle = 1;
}
} // End – while($row = mysql_fetch_array($SelectDates)) {
if ($Handle !== 1) {echo ‘DATES AVAILABLE >> WRITE BOOKING CODE’;}
So if the handle is not equal to 1 its fine and they can book,
but, if the dates arn’t available (i.e, $Handle == 1) I need to check
the closest available dates either side (before and after) the date they
wanted where the Status is ‘available’ for the amount of nights they
wish to stay…
So I set out to establish the first available date in either
direction and thts where I got stuck. Looking at it I’m sure you could
run a while loop to find the next available block inside the code above,
but not sure how.
if ($Handle == 1) {
$FirstDateQuery = mysql_query(“SELECT * FROM BookingsCalendar WHERE
AutoIncNo < $LastAutoIncNo AND Status='available' ORDER BY AutoIncNo
DESC LIMIT 1″);
while($row = mysql_fetch_array($FirstDateQuery)) {
$AutoIncNo = $row[“AutoIncNo”];
$BookingDate = $row[“BookingDate”];
$Status = $row[“Status”];

} // End – while($row = mysql_fetch_array($SelectDates)) {
$FirstBookedDate = $BookingDate;
echo $FirstBookedDate . ‘ – ‘ . $LastBookedDate;
} // End – if ($Handle == 1) {
If you have a better more efficient way or can adapt what is already here, that would be grand… My brain hurts lol.
So for example, if someone tries to book from 2013.06.01 but
cant because its ‘booked’ for the next 4 days, the above script runs
and brings up 2013.05.31 – 2013.05.30 – 2013.05.29 – 2013.05.28 as a
result.
But if one of those dates are booked it will skip it and give me the
next one (selecting as it is the next 4 that meet the condition
‘available’)
So if say 2013.05.29 was booked it would show 2013.05.31 – 2013.05.30 –
2013.05.28 – 2013.05.27 missing out the day which is booked.
Now the thing is that we need the next 4 rows together
(undivided/continuous/without breaks in the dates) which are
‘available’.
Any ideas would be very helpful

Healthcare Leaders

They aspire to become directors, CNO’s, CIO’s, CFO’s, CEO’s, or maybe even owners of their own healthcare businesses. It is so important to prepare oneself for leadership before jumping into the chair. Summarize the sources, qualifications, and development programs for leadership in healthcare. Be sure to address the “paths for beginners.” Even for those of you who are not beginners, you will be mentoring others in your facilities who are novices.

PROMIS

nih.gov/clinicalresearch/overview-dynamicoutcomes.aspx  Efforts to improve the quality of healthcare can be seen everywhere in America these days. You can observe this at your own local healthcare facilities. Americans are justifiably dissatisfied with our healthcare system for many reasons. Case in point, a major initiative of the National Institutes of Health, aimed at improving the measurement of patient reported outcomes in medicine is the Patient Reported Outcomes Measurement Information System (PROMIS) program. What is the PROMIS intended to accomplish? Do you feel that this approach will ultimately have a significant impact on the quality of American healthcare? 200 word minimum, APA format

Explain how the law of demand affected your purchase

g. soda, diapers, takeout meals, milk, shoes, manicure/pedicure,
video game, etc.). Explain how the law of demand affected your purchase.
Give specific examples of how the determinants of demand and supply
affect this product (T-I-P-E-N and P-R-E-S-T). What happens to the
demand curve and the supply curve when any of these determinants change?
Give examples of scenarios that would cause a change in demand versus a
movement along the same demand curve and supply curve for this product.
Discuss the new equilibrium price and quantity that result from these
changes. Can you demonstrate some of these changes graphically?

hyper link using php

example:
im trying to make the “id” in a sql query link with the same number as the id
so like id = 1
create a hyper link that would make it localhost/?page=1
id = 2
localhost/?page=2
and so on
but more complicated like a product number 4567-2443
so it would be localhost/?page=4567-2443
The goal is I will have 28,000 items in a table split by categories.
when i click the product id i want to link to its page which will always
be www.yourdomain.com/?product=
any suggestions help. This is the code I have so far to display the table and pagination.

<?php
 
 $link = mysql_connect(
‘:/Applications/MAMP/tmp/mysql/mysql.sock’,
‘root’,
‘root’
);
mysql_select_db(‘products’);
 
 if (!$link){
 echo “Could not connect to database” . mysql_error();
 exit();
 }
$db_name = “products”;
 if (!mysql_select_db($db_name, $link)){
 die (“Could not select database” . mysql_error());
 }
 
$per_page = 2;
 
$pages_query = mysql_query(“SELECT COUNT(`id`) FROM `beans`”);
$pages = ceil (mysql_result($pages_query, 0) / $per_page);
 
$page = (isset($_GET[‘page’])) ? (int)$_GET[‘page’] : 1;
$start = ($page – 1) * $per_page;
 
$id = $query_row[‘id’];
 
$query = mysql_query(“SELECT * FROM `beans` LIMIT $start, $per_page”);
 while ($query_row = mysql_fetch_assoc($query)) {
 echo ‘

‘, $query_row[‘id’] ,$query_row[‘name’] ,’

‘;
 
 }
 
 if ($pages >= 1) {
 for ($x = 1; $x <= $pages; $x ) {
 echo ‘‘ . $x . ‘ ‘;
 }
 
 }
 
?>

Essay Writing at Proficient Essay

5.0 rating based on 10,001 ratings

Rated 4.9/5
10001 review

Review This Service




Rating: