Вопрос

I searched for this answer and on Google and found nothing that is what I need done for my client so here I am askin y'all for some help!

Simply put, my client wants to enter in data into a form on a blog entry that in turn, when submitted, simultaneously populates a list on a different page on his site. That page will just be a list that says (for example) name, release date, rating, how many times sampled (in this case, if the item was entered for multiple blog entries, then the list would reflect how many times it was entered in total), and which member suggested it.

I know I will be using a blog plug in to create the form, but I am not sure WHICH plugin will best suit this tast. I know I will be using PHP to send the data where I want it sent, but I have only used PHP to send data to emails, and never before to send it to a live list.

So which plugin? Any one?

How do I direct the PHP to display live page data without having up reupload a page every time the user wants the new data displayed?

Sorry if these are dumb questions but this is new to me. Please help me learn!

Thank you!

Это было полезно?

Решение

Make this file get_list.php:

<?php

$sql = mysql_query("SELECT * FROM list_table LIMIT 15")
if (!$sql || mysql_num_rows($sql)==0)
    exit("There are no list items");

while ($item = mysql_fetch_array($sql)) {
    echo "<li> format it here";
    echo $item['name'];
    echo "</li>"
}


?>

And in your main file:

<ul class="list">
    <li>Blabla 1</li>
    <li>Blabla 2</li>
</ul>

<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>

    function updateList() {
        $('.list').load('get_list.php', function (data, status) {
            if (status) return alert('Error updating the list');
            setTimeout(updateList, 2000);
        });
    }
    updateList();

</script>

...and your list will be updated every two seconds.

Good luck!!

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top