Search code examples
htmlmysqldatabasefeedlive

Advice on how to approach a live feed, containg data from a mysql databse


Hi all as you can probably tell by my two questions yesterday I'm new to wed development. I really need some help on how to approach the next part of my page. So and advice would be great. I'm not really looking for complete/complex code that I can't understand.. I really just want a point in the right direction so I can then work it out / learn myself. CHEERS :D

Okay so basically I have set up a database user accounts and I want to have a rolling feed of new members... . I want to get the feed to go in the main square, how do I code the feed... For the website so far I have used html and php for coding languages. The server is a mysql server. And tips / pointers would be really helpfull :)

my current code:

<?php
//Account validation
session_start();
if(!(isset($_SESSION['login']))){
header("location:welcome.php");

}

?>


<html>
<body>
<table width ="100%" border="1">
<tr>
<td width="25%">
<h1>TOOB</h1>
</td>
<td>

<!all links and stuff>
</td>
</tr>

<tr>
<td>
<h2>Start exploring the TOOB</h2>
</td>
<td width="75%">
</td>
<td>
<form>
<input type="button" value="Logout" onclick="window.location.href='logout.php'">
</form>

</td>
</tr>

</table>
<br>
<table border="1" align="center" width = "60%" height = "500">
<tr>
<td>
<!--FEED GOES HERE-->
</td>

</tr>
</table>

</body>
</html>

Solution

  • You will need to connect to your mysql database and retrieve your user information. Learn more about PDO, there are plenty of tutorials out there, just google 'php pdo'. When you are done with the connection and the retrieval of your data you will have an array you can loop through and display the rows in your page. For the rolling part, you can use javascript and make an ajax get request every few minutes to refresh the information.

    Also please consider using css for creating a layout for your page instead of a table. Let me know if you need more.