So I am new to programming with MySql and PHP so I am not sure how to parse the data from a PHP script to an HTML tooltip.
Here is my PHP:
<?php
$servername = "server";
$username = "username";
$password = "password";
$dbname = "dbname";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "select courseCode, courseName from building b, room r, occupy o, timeslot t, meet m, section s, course c, timespan ts, day d, class cl where b.name = 'BH' and r.roomNum = '128' and b.buildingID = r.buildingID and o.roomID = r.roomID and t.timeID = o.timeID and t.timeID = m.timeID and m.sectionID = s.sectionID and c.courseID = s.courseID and t.spanID = ts.spanID and ts.start = '10:05' and ts.end = '11:25' and t.dayID = d.dayID and d.dayOfWeek = 'M' and cl.roomID = r.roomID and cl.sectionID = s.sectionID";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo "Course Code: " . $row["courseCode"]. " - Name: " . $row["courseName"]."<br>";
}
} else {
echo "0 results";
}
$conn->close();
?>
Ultimately I would like to place the selected data into a tooltip I have placed on a list item where it says title="". Any suggestions?
HTML:
<div class="list-group">
<a class="list-group-item list-group-item-action list-group-item-success listmargin"><abbr title="" rel="tooltip">HH 201</abbr></a>
<a class="list-group-item list-group-item-action list-group-item-success listmargin"><abbr title="From DB </em>." rel="tooltip">HH 203</abbr></a>