Issue
Hey guys i just want to put the information from the database into a table which i can display on a website but i have no idea how to do it.
<?php
include 'database_conn.php'; // make db connection
$sql = "SELECT eventID, eventTitle, eventDescription, venueID, catID, eventStartDate, eventEndDate, eventPrice FROM AE_events ORDER BY eventTitle";
$queryResult = $dbConn->query($sql);
if($queryResult === false) {
echo "<p>Query failed: ".$dbConn->error."</p>\n</sample1>\n</html>";
exit;
}
else {
while($rowObj = $queryResult->fetch_object()){
$eventid = $rowObj->eventID;
$eventT = $rowObj->eventTitle;
$eventDe = $rowObj->eventDescription;
$venueid = $rowObj->venueID;
$catid = $rowObj->catID;
$eventStart = $rowObj->eventStartDate;
$eventEnd = $rowObj->eventEndDate;
$eventPr = $rowObj->eventPrice;
echo "<div class= event>
<span class= title>$eventT</span>
<span class= description>$eventDe</span>
<span class= start_date>$eventStart</span>
<span class= end_date>$eventEnd</span>
£ <span class= price>$eventPr</span>
</div>";
}
}
$queryResult->close();
$dbConn->close();
?>
Solution
THE RIGHT WAY The key is AJAX. For most uses, the simplest way to do that is generally to add jQuery to your web page and then use a $.ajax() call to call your PHP query and load the results into a when the user clicks on the link. There are a bunch of details involved, but spending a little time with a jQuery tutorial should get you going.
THE LAZY WAY Preload all the data but hide the window (<div> or <table> or whatever) using CSS and when the user clicks the link just change the CSS on that element to show it, possibly using CSS to hide other parts at the same time to make space. That can be done in pure Javascript easily enough, but even easier with jQuery.
Answered By - manassehkatz-Moving 2 Codidact
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.