PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, January 23, 2022

[FIXED] PHP database information placed in a table to display on a website

 January 23, 2022     html, php, phpmyadmin     No comments   

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
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing