I'm creating an event based website. For the sake of shortening the question, I'll give a minimal example.
I have an event.php page, with a dropdown menu which has each month in it. Underneath is a set of php include's one for each month, ie. (jan.php, feb.php). So when you click "January" in the dropdown, the jan.php shows.
Each event is it's own table, and each table has multiple rows, though for the sake of this I'm "echoing" 3 rows - showname, date, time.
Now my jquery is giving the desired effect of formatting the time & date (for time shortening it to 08:00:00 instead of 08:00:00.0000...etc, and for the date it's taking it from YYYY/MM/DD to DD/MM/YYYY.
My issue is - for each span class="._start", when it is copying the html of class="_startplace" (the formatted date/time), it will only copy the first one, and adds that into ._start on each table(event)
Ie. Table 1 : Bobs BBQ 08:00:00 12/02/2015
Table 2 : Suzy's Party 09:00:00 13/02/2015
Table 3, Table 4, etc...
So each table has it's own span._start, and I need each of those to be filled with the corresponding time ie Table 1's span class="_start" needs to say 08:00:00 Table 2's span class ="_start" needs to say 09:00:00. Currently, the span class="start" in Table 1 says 08:00:00, and the span class="_start" in Table 2 says 08:00:00
Any idea's on how to fix this? I'm basically looking for a way to "bind" the formatting, then "copying" to each specific table.
Each "month".php goes something like this (note shortened version)
var startdate = $('._startplace').html();
var subyear = (startdate).substr(0, 4);
var submonth = (startdate).substr(5, 2);
var subday = (startdate).substr(8, 2);
var starttime = (startdate).substr(11, 8);
var subfull = (subday + "-" + submonth + "-" + subyear);
$('._start, ._end').html(subfull + " " + starttime);
$sql = "SELECT id, date, time FROM january ORDER by date ASC, time ASC";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
echo 'Show';
// output data of each row
while($row = $result->fetch_assoc()) {
echo "<table class='col-lg-12' id='event-container_'>
<th>
<h1 class='event-title-words'>". $row["showname"]. "</h1>
</th>
<tr id='event-table_'>
<td class='column'>
<span class='_startplace'>" . $row["date"]. " " . $row["time"]. "</span>
<a href='http://example.com/link-to-your-event' title='Add to Calendar' class='addthisevent' id='addevent'>
Add to Calendar
<span class='_start'></span>
<span class='_end'></span>
</a>
</td>
</tr>
</table>
}
echo "Done";
} else {
echo "0 results";
}
$conn->close();
?>
EDIT: Basically I have data from an sql table being outputted in table format through PHP, with each SQL TABLE row, creating a new HTML TABLE, I am then trying to target the cell of outputted data which is displayed in the HTML table with jquery, format that data (ie. substr & create new variables with substrings to switch from YYYY/MM/DD to DD/MM/YYYY), and then copy that formatted data into a span with a class of "_start". I can either only display the data in the "_start" of the first table, or it displays the formatted data from the cell in row 1 (sql row), in all "_start" spans on the page. I need each HTML table to act as 1 "event" (think calendar), and for the row of Date & Time outputted by PHP & SQL to be formatted to a particular format, and copied into a span that is enclosed within an "a href". Example of why I need date and time formatted https://addthisevent.com/
My coding is certainly not the best, so if you notice anything I "shouldn't" be doing, or know of easier ways to achieve my desired effect I'd be happy to hear it! Cheers!