JQuery / PHP - Timetable based on button value
up vote
0
down vote
favorite
I am working on a timetable that uses hourly bookings. The front end is on the Bootstrap framework and the back end is using PHP, MySQL and JQuery.
My "events" table is setup like the following:
id | name | day | time | hotel | host
1 | Test | 1 | 01:00 | https://url.com | Name
1 | Test2 | 1 | 05:00 | https://url.com | Name
I am wanting to show the timetable based on the day selected from buttons labeled Mon, Tue, Wed, Thu and so on.
The following is what I have for the day buttons:
<form id="dayselect">
<div class="btn-group btn-group-justified" role="group" aria-label="...">
<div class="btn-group" role="group">
<button type="button" type="submit" class="btn btn-default dayselect" name="day" value="1">Mon</button>
</div>
<div class="btn-group" role="group">
<button type="button" type="submit" class="btn btn-default dayselect" name="day" value="2">Tue</button>
</div>
<div class="btn-group" role="group">
<button type="button" type="submit" class="btn btn-default dayselect" name="day" value="3">Wed</button>
</div>
<div class="btn-group" role="group">
<button type="button" type="submit" class="btn btn-default dayselect" name="day" value="4">Thu</button>
</div>
<div class="btn-group" role="group">
<button type="button" type="submit" class="btn btn-default dayselect" name="day" value="5">Fri</button>
</div>
<div class="btn-group" role="group">
<button type="button" type="submit" class="btn btn-default dayselect" name="day" value="6">Sat</button>
</div>
<div class="btn-group" role="group">
<button type="button" type="submit" class="btn btn-default dayselect" name="day" value="7">Sun</button>
</div>
</div>
</form>
The following is what I have for the current day's timetable:
<div class="row" id="timetableinfo">
<?php
$date_format = 'N';
$day = date($date_format);
for ($j = 0; $j <= 23; $j++) {
if ($j < 10) {
$time = "0{$j}:00";
} else {
$time = "{$j}:00";
}
$query = $dbh->prepare("SELECT * FROM events WHERE day=:day AND time=:time ORDER BY time ASC");
$query->execute(array(":day"=>$day, ":time"=>$time));
$queryData = $query->fetch(PDO::FETCH_ASSOC);
?>
<div class="col-md-2">
<div class="event-time-wrap">
<div class="event-time">
<p><?php echo $time; ?></p>
<p><?php echo $queryData['host'] ? $queryData['host'] : '-'; ?></p>
<?php
if ($queryData['name'] != "") {
if (filter_var($queryData['hotel'], FILTER_VALIDATE_URL)) {
?>
<a href="#" class="btn btn-gr eventlink">ENTER</a>
<?php
} else {
echo $queryData['name'];
}
}
?>
</div>
</div>
</div>
<?php
}
?>
</div>
The following is what I was using for the JQuery button clicks:
$('button.dayselect').click(function() {
var formData = $(this).attr("value");
$.ajax({
url: 'timetabledata.php',
type:'POST',
data: formData,
success: function(html)
{
$("#timetableinfo").html(html);
}
});
return false;
});
And the following is what I had for the timetabledata PHP file to show the new timetable/day:
<?php
require_once '../panel/includes/config.php';
$day = date($_REQUEST['day'], 'N');
for ($j = 0; $j <= 23; $j++) {
if ($j < 10) {
$time = "0{$j}:00";
} else {
$time = "{$j}:00";
}
$query = $dbh->prepare("SELECT * FROM events WHERE day=:day AND time=:time ORDER BY time ASC");
$query->execute(array(":day"=>$day, ":time"=>$time));
$queryData = $query->fetch(PDO::FETCH_ASSOC);
?>
<div class="col-md-2">
<div class="event-time-wrap">
<div class="event-time">
<p><?php echo $time; ?></p>
<p><?php echo $queryData['host'] ? $queryData['host'] : '-'; ?></p>
<?php
if ($queryData['name'] != "") {
if (filter_var($queryData['hotel'], FILTER_VALIDATE_URL)) {
?>
<a href="#" class="btn btn-gr eventlink">ENTER</a>
<?php
} else {
echo $queryData['name'];
}
}
?>
</div>
</div>
</div>
<?php
}
?>
It is not showing any data, but rather just the 24 blank boxes on each day I click on. When I refresh the page, it goes back to the current day's timetable.
Question Edit
The day value of 1, 2, 3 and so on is not being picked up, so it's not reading time correctly, which is causing blank values during the for loop.
The JQuery being used is the same setup I have on a different using a select dropdown and it works fine.
php jquery
add a comment |
up vote
0
down vote
favorite
I am working on a timetable that uses hourly bookings. The front end is on the Bootstrap framework and the back end is using PHP, MySQL and JQuery.
My "events" table is setup like the following:
id | name | day | time | hotel | host
1 | Test | 1 | 01:00 | https://url.com | Name
1 | Test2 | 1 | 05:00 | https://url.com | Name
I am wanting to show the timetable based on the day selected from buttons labeled Mon, Tue, Wed, Thu and so on.
The following is what I have for the day buttons:
<form id="dayselect">
<div class="btn-group btn-group-justified" role="group" aria-label="...">
<div class="btn-group" role="group">
<button type="button" type="submit" class="btn btn-default dayselect" name="day" value="1">Mon</button>
</div>
<div class="btn-group" role="group">
<button type="button" type="submit" class="btn btn-default dayselect" name="day" value="2">Tue</button>
</div>
<div class="btn-group" role="group">
<button type="button" type="submit" class="btn btn-default dayselect" name="day" value="3">Wed</button>
</div>
<div class="btn-group" role="group">
<button type="button" type="submit" class="btn btn-default dayselect" name="day" value="4">Thu</button>
</div>
<div class="btn-group" role="group">
<button type="button" type="submit" class="btn btn-default dayselect" name="day" value="5">Fri</button>
</div>
<div class="btn-group" role="group">
<button type="button" type="submit" class="btn btn-default dayselect" name="day" value="6">Sat</button>
</div>
<div class="btn-group" role="group">
<button type="button" type="submit" class="btn btn-default dayselect" name="day" value="7">Sun</button>
</div>
</div>
</form>
The following is what I have for the current day's timetable:
<div class="row" id="timetableinfo">
<?php
$date_format = 'N';
$day = date($date_format);
for ($j = 0; $j <= 23; $j++) {
if ($j < 10) {
$time = "0{$j}:00";
} else {
$time = "{$j}:00";
}
$query = $dbh->prepare("SELECT * FROM events WHERE day=:day AND time=:time ORDER BY time ASC");
$query->execute(array(":day"=>$day, ":time"=>$time));
$queryData = $query->fetch(PDO::FETCH_ASSOC);
?>
<div class="col-md-2">
<div class="event-time-wrap">
<div class="event-time">
<p><?php echo $time; ?></p>
<p><?php echo $queryData['host'] ? $queryData['host'] : '-'; ?></p>
<?php
if ($queryData['name'] != "") {
if (filter_var($queryData['hotel'], FILTER_VALIDATE_URL)) {
?>
<a href="#" class="btn btn-gr eventlink">ENTER</a>
<?php
} else {
echo $queryData['name'];
}
}
?>
</div>
</div>
</div>
<?php
}
?>
</div>
The following is what I was using for the JQuery button clicks:
$('button.dayselect').click(function() {
var formData = $(this).attr("value");
$.ajax({
url: 'timetabledata.php',
type:'POST',
data: formData,
success: function(html)
{
$("#timetableinfo").html(html);
}
});
return false;
});
And the following is what I had for the timetabledata PHP file to show the new timetable/day:
<?php
require_once '../panel/includes/config.php';
$day = date($_REQUEST['day'], 'N');
for ($j = 0; $j <= 23; $j++) {
if ($j < 10) {
$time = "0{$j}:00";
} else {
$time = "{$j}:00";
}
$query = $dbh->prepare("SELECT * FROM events WHERE day=:day AND time=:time ORDER BY time ASC");
$query->execute(array(":day"=>$day, ":time"=>$time));
$queryData = $query->fetch(PDO::FETCH_ASSOC);
?>
<div class="col-md-2">
<div class="event-time-wrap">
<div class="event-time">
<p><?php echo $time; ?></p>
<p><?php echo $queryData['host'] ? $queryData['host'] : '-'; ?></p>
<?php
if ($queryData['name'] != "") {
if (filter_var($queryData['hotel'], FILTER_VALIDATE_URL)) {
?>
<a href="#" class="btn btn-gr eventlink">ENTER</a>
<?php
} else {
echo $queryData['name'];
}
}
?>
</div>
</div>
</div>
<?php
}
?>
It is not showing any data, but rather just the 24 blank boxes on each day I click on. When I refresh the page, it goes back to the current day's timetable.
Question Edit
The day value of 1, 2, 3 and so on is not being picked up, so it's not reading time correctly, which is causing blank values during the for loop.
The JQuery being used is the same setup I have on a different using a select dropdown and it works fine.
php jquery
You need to loop$queryData
. Now you are accessing an invalid key. For example$queryData[0]['host']
can access the first key of your records. And yourfor
statement should end before$query
variable, it's not ok to call a query multiple times. Concatenate hours in a variable and change your query to something likeAND time in :time
where:time
is ` ( '00:00', '01:00', '02:00' ) `
– darklightcode
Nov 15 at 17:51
The query loop isn't my issue here. It's the data grab from my JQuery (which works on a different form) which isn't picking up the appropriate day value of 1, 2, 3, etc...
– Morgan Klaif
Nov 15 at 17:53
1
Changedata
on ajax todata: { day: $(this).val() },
– darklightcode
Nov 15 at 17:55
That worked! Thank you!
– Morgan Klaif
Nov 15 at 17:58
1
Your welcome! Consider refactoring your code to something more readable in the future. Have a look at the approved answer here stackoverflow.com/questions/4600419/endforeach-in-loops
– darklightcode
Nov 15 at 18:01
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am working on a timetable that uses hourly bookings. The front end is on the Bootstrap framework and the back end is using PHP, MySQL and JQuery.
My "events" table is setup like the following:
id | name | day | time | hotel | host
1 | Test | 1 | 01:00 | https://url.com | Name
1 | Test2 | 1 | 05:00 | https://url.com | Name
I am wanting to show the timetable based on the day selected from buttons labeled Mon, Tue, Wed, Thu and so on.
The following is what I have for the day buttons:
<form id="dayselect">
<div class="btn-group btn-group-justified" role="group" aria-label="...">
<div class="btn-group" role="group">
<button type="button" type="submit" class="btn btn-default dayselect" name="day" value="1">Mon</button>
</div>
<div class="btn-group" role="group">
<button type="button" type="submit" class="btn btn-default dayselect" name="day" value="2">Tue</button>
</div>
<div class="btn-group" role="group">
<button type="button" type="submit" class="btn btn-default dayselect" name="day" value="3">Wed</button>
</div>
<div class="btn-group" role="group">
<button type="button" type="submit" class="btn btn-default dayselect" name="day" value="4">Thu</button>
</div>
<div class="btn-group" role="group">
<button type="button" type="submit" class="btn btn-default dayselect" name="day" value="5">Fri</button>
</div>
<div class="btn-group" role="group">
<button type="button" type="submit" class="btn btn-default dayselect" name="day" value="6">Sat</button>
</div>
<div class="btn-group" role="group">
<button type="button" type="submit" class="btn btn-default dayselect" name="day" value="7">Sun</button>
</div>
</div>
</form>
The following is what I have for the current day's timetable:
<div class="row" id="timetableinfo">
<?php
$date_format = 'N';
$day = date($date_format);
for ($j = 0; $j <= 23; $j++) {
if ($j < 10) {
$time = "0{$j}:00";
} else {
$time = "{$j}:00";
}
$query = $dbh->prepare("SELECT * FROM events WHERE day=:day AND time=:time ORDER BY time ASC");
$query->execute(array(":day"=>$day, ":time"=>$time));
$queryData = $query->fetch(PDO::FETCH_ASSOC);
?>
<div class="col-md-2">
<div class="event-time-wrap">
<div class="event-time">
<p><?php echo $time; ?></p>
<p><?php echo $queryData['host'] ? $queryData['host'] : '-'; ?></p>
<?php
if ($queryData['name'] != "") {
if (filter_var($queryData['hotel'], FILTER_VALIDATE_URL)) {
?>
<a href="#" class="btn btn-gr eventlink">ENTER</a>
<?php
} else {
echo $queryData['name'];
}
}
?>
</div>
</div>
</div>
<?php
}
?>
</div>
The following is what I was using for the JQuery button clicks:
$('button.dayselect').click(function() {
var formData = $(this).attr("value");
$.ajax({
url: 'timetabledata.php',
type:'POST',
data: formData,
success: function(html)
{
$("#timetableinfo").html(html);
}
});
return false;
});
And the following is what I had for the timetabledata PHP file to show the new timetable/day:
<?php
require_once '../panel/includes/config.php';
$day = date($_REQUEST['day'], 'N');
for ($j = 0; $j <= 23; $j++) {
if ($j < 10) {
$time = "0{$j}:00";
} else {
$time = "{$j}:00";
}
$query = $dbh->prepare("SELECT * FROM events WHERE day=:day AND time=:time ORDER BY time ASC");
$query->execute(array(":day"=>$day, ":time"=>$time));
$queryData = $query->fetch(PDO::FETCH_ASSOC);
?>
<div class="col-md-2">
<div class="event-time-wrap">
<div class="event-time">
<p><?php echo $time; ?></p>
<p><?php echo $queryData['host'] ? $queryData['host'] : '-'; ?></p>
<?php
if ($queryData['name'] != "") {
if (filter_var($queryData['hotel'], FILTER_VALIDATE_URL)) {
?>
<a href="#" class="btn btn-gr eventlink">ENTER</a>
<?php
} else {
echo $queryData['name'];
}
}
?>
</div>
</div>
</div>
<?php
}
?>
It is not showing any data, but rather just the 24 blank boxes on each day I click on. When I refresh the page, it goes back to the current day's timetable.
Question Edit
The day value of 1, 2, 3 and so on is not being picked up, so it's not reading time correctly, which is causing blank values during the for loop.
The JQuery being used is the same setup I have on a different using a select dropdown and it works fine.
php jquery
I am working on a timetable that uses hourly bookings. The front end is on the Bootstrap framework and the back end is using PHP, MySQL and JQuery.
My "events" table is setup like the following:
id | name | day | time | hotel | host
1 | Test | 1 | 01:00 | https://url.com | Name
1 | Test2 | 1 | 05:00 | https://url.com | Name
I am wanting to show the timetable based on the day selected from buttons labeled Mon, Tue, Wed, Thu and so on.
The following is what I have for the day buttons:
<form id="dayselect">
<div class="btn-group btn-group-justified" role="group" aria-label="...">
<div class="btn-group" role="group">
<button type="button" type="submit" class="btn btn-default dayselect" name="day" value="1">Mon</button>
</div>
<div class="btn-group" role="group">
<button type="button" type="submit" class="btn btn-default dayselect" name="day" value="2">Tue</button>
</div>
<div class="btn-group" role="group">
<button type="button" type="submit" class="btn btn-default dayselect" name="day" value="3">Wed</button>
</div>
<div class="btn-group" role="group">
<button type="button" type="submit" class="btn btn-default dayselect" name="day" value="4">Thu</button>
</div>
<div class="btn-group" role="group">
<button type="button" type="submit" class="btn btn-default dayselect" name="day" value="5">Fri</button>
</div>
<div class="btn-group" role="group">
<button type="button" type="submit" class="btn btn-default dayselect" name="day" value="6">Sat</button>
</div>
<div class="btn-group" role="group">
<button type="button" type="submit" class="btn btn-default dayselect" name="day" value="7">Sun</button>
</div>
</div>
</form>
The following is what I have for the current day's timetable:
<div class="row" id="timetableinfo">
<?php
$date_format = 'N';
$day = date($date_format);
for ($j = 0; $j <= 23; $j++) {
if ($j < 10) {
$time = "0{$j}:00";
} else {
$time = "{$j}:00";
}
$query = $dbh->prepare("SELECT * FROM events WHERE day=:day AND time=:time ORDER BY time ASC");
$query->execute(array(":day"=>$day, ":time"=>$time));
$queryData = $query->fetch(PDO::FETCH_ASSOC);
?>
<div class="col-md-2">
<div class="event-time-wrap">
<div class="event-time">
<p><?php echo $time; ?></p>
<p><?php echo $queryData['host'] ? $queryData['host'] : '-'; ?></p>
<?php
if ($queryData['name'] != "") {
if (filter_var($queryData['hotel'], FILTER_VALIDATE_URL)) {
?>
<a href="#" class="btn btn-gr eventlink">ENTER</a>
<?php
} else {
echo $queryData['name'];
}
}
?>
</div>
</div>
</div>
<?php
}
?>
</div>
The following is what I was using for the JQuery button clicks:
$('button.dayselect').click(function() {
var formData = $(this).attr("value");
$.ajax({
url: 'timetabledata.php',
type:'POST',
data: formData,
success: function(html)
{
$("#timetableinfo").html(html);
}
});
return false;
});
And the following is what I had for the timetabledata PHP file to show the new timetable/day:
<?php
require_once '../panel/includes/config.php';
$day = date($_REQUEST['day'], 'N');
for ($j = 0; $j <= 23; $j++) {
if ($j < 10) {
$time = "0{$j}:00";
} else {
$time = "{$j}:00";
}
$query = $dbh->prepare("SELECT * FROM events WHERE day=:day AND time=:time ORDER BY time ASC");
$query->execute(array(":day"=>$day, ":time"=>$time));
$queryData = $query->fetch(PDO::FETCH_ASSOC);
?>
<div class="col-md-2">
<div class="event-time-wrap">
<div class="event-time">
<p><?php echo $time; ?></p>
<p><?php echo $queryData['host'] ? $queryData['host'] : '-'; ?></p>
<?php
if ($queryData['name'] != "") {
if (filter_var($queryData['hotel'], FILTER_VALIDATE_URL)) {
?>
<a href="#" class="btn btn-gr eventlink">ENTER</a>
<?php
} else {
echo $queryData['name'];
}
}
?>
</div>
</div>
</div>
<?php
}
?>
It is not showing any data, but rather just the 24 blank boxes on each day I click on. When I refresh the page, it goes back to the current day's timetable.
Question Edit
The day value of 1, 2, 3 and so on is not being picked up, so it's not reading time correctly, which is causing blank values during the for loop.
The JQuery being used is the same setup I have on a different using a select dropdown and it works fine.
php jquery
php jquery
edited Nov 15 at 17:55
asked Nov 15 at 16:53
Morgan Klaif
4010
4010
You need to loop$queryData
. Now you are accessing an invalid key. For example$queryData[0]['host']
can access the first key of your records. And yourfor
statement should end before$query
variable, it's not ok to call a query multiple times. Concatenate hours in a variable and change your query to something likeAND time in :time
where:time
is ` ( '00:00', '01:00', '02:00' ) `
– darklightcode
Nov 15 at 17:51
The query loop isn't my issue here. It's the data grab from my JQuery (which works on a different form) which isn't picking up the appropriate day value of 1, 2, 3, etc...
– Morgan Klaif
Nov 15 at 17:53
1
Changedata
on ajax todata: { day: $(this).val() },
– darklightcode
Nov 15 at 17:55
That worked! Thank you!
– Morgan Klaif
Nov 15 at 17:58
1
Your welcome! Consider refactoring your code to something more readable in the future. Have a look at the approved answer here stackoverflow.com/questions/4600419/endforeach-in-loops
– darklightcode
Nov 15 at 18:01
add a comment |
You need to loop$queryData
. Now you are accessing an invalid key. For example$queryData[0]['host']
can access the first key of your records. And yourfor
statement should end before$query
variable, it's not ok to call a query multiple times. Concatenate hours in a variable and change your query to something likeAND time in :time
where:time
is ` ( '00:00', '01:00', '02:00' ) `
– darklightcode
Nov 15 at 17:51
The query loop isn't my issue here. It's the data grab from my JQuery (which works on a different form) which isn't picking up the appropriate day value of 1, 2, 3, etc...
– Morgan Klaif
Nov 15 at 17:53
1
Changedata
on ajax todata: { day: $(this).val() },
– darklightcode
Nov 15 at 17:55
That worked! Thank you!
– Morgan Klaif
Nov 15 at 17:58
1
Your welcome! Consider refactoring your code to something more readable in the future. Have a look at the approved answer here stackoverflow.com/questions/4600419/endforeach-in-loops
– darklightcode
Nov 15 at 18:01
You need to loop
$queryData
. Now you are accessing an invalid key. For example $queryData[0]['host']
can access the first key of your records. And your for
statement should end before $query
variable, it's not ok to call a query multiple times. Concatenate hours in a variable and change your query to something like AND time in :time
where :time
is ` ( '00:00', '01:00', '02:00' ) `– darklightcode
Nov 15 at 17:51
You need to loop
$queryData
. Now you are accessing an invalid key. For example $queryData[0]['host']
can access the first key of your records. And your for
statement should end before $query
variable, it's not ok to call a query multiple times. Concatenate hours in a variable and change your query to something like AND time in :time
where :time
is ` ( '00:00', '01:00', '02:00' ) `– darklightcode
Nov 15 at 17:51
The query loop isn't my issue here. It's the data grab from my JQuery (which works on a different form) which isn't picking up the appropriate day value of 1, 2, 3, etc...
– Morgan Klaif
Nov 15 at 17:53
The query loop isn't my issue here. It's the data grab from my JQuery (which works on a different form) which isn't picking up the appropriate day value of 1, 2, 3, etc...
– Morgan Klaif
Nov 15 at 17:53
1
1
Change
data
on ajax to data: { day: $(this).val() },
– darklightcode
Nov 15 at 17:55
Change
data
on ajax to data: { day: $(this).val() },
– darklightcode
Nov 15 at 17:55
That worked! Thank you!
– Morgan Klaif
Nov 15 at 17:58
That worked! Thank you!
– Morgan Klaif
Nov 15 at 17:58
1
1
Your welcome! Consider refactoring your code to something more readable in the future. Have a look at the approved answer here stackoverflow.com/questions/4600419/endforeach-in-loops
– darklightcode
Nov 15 at 18:01
Your welcome! Consider refactoring your code to something more readable in the future. Have a look at the approved answer here stackoverflow.com/questions/4600419/endforeach-in-loops
– darklightcode
Nov 15 at 18:01
add a comment |
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53324325%2fjquery-php-timetable-based-on-button-value%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53324325%2fjquery-php-timetable-based-on-button-value%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
You need to loop
$queryData
. Now you are accessing an invalid key. For example$queryData[0]['host']
can access the first key of your records. And yourfor
statement should end before$query
variable, it's not ok to call a query multiple times. Concatenate hours in a variable and change your query to something likeAND time in :time
where:time
is ` ( '00:00', '01:00', '02:00' ) `– darklightcode
Nov 15 at 17:51
The query loop isn't my issue here. It's the data grab from my JQuery (which works on a different form) which isn't picking up the appropriate day value of 1, 2, 3, etc...
– Morgan Klaif
Nov 15 at 17:53
1
Change
data
on ajax todata: { day: $(this).val() },
– darklightcode
Nov 15 at 17:55
That worked! Thank you!
– Morgan Klaif
Nov 15 at 17:58
1
Your welcome! Consider refactoring your code to something more readable in the future. Have a look at the approved answer here stackoverflow.com/questions/4600419/endforeach-in-loops
– darklightcode
Nov 15 at 18:01