Page 1 of 1

Separately display all records in a recordset

Posted: Fri Dec 04, 2009 5:11 am
by pdawallace
Hi Guys!

I am quite new to PHP and have been assigned the job of designing a web page for our company intranet that will display staff announcements that are entered into an SQL 2005 database.
What i would like to do is display each announcement separately for x seconds before moving on to display the next record until the end of the recordset is reached. Once the end is reached, I would like the process to start again.
This has so far proved quite difficult (for me!)

Can anyone give me any advice as to whether this is possible and if so, how would be the best way to go about it? I assume some sort of loop will be involved but if I am correct a standard loop would display all records at once and this is not what I need!

Here is the code I have so far, not a lot unfortunately:

<?php

$conn=odbc_connect('Noticeboard','','');
if (!$conn)
{exit("Connection Failed: " . $conn);}

$sql="select CommentID, Comment FROM tblDisplayed";

$rs=odbc_exec($conn,$sql);
$comment=odbc_result($rs, "Comment");

if (!$rs)
{exit("[Error in SQL]");}



echo "<table><tr>";
echo "<td><h3><span class=style2 style2>$comment</h3></span></td></tr>";
echo "</table>";


odbc_close($conn);

?>

Is there any straightforward way to edit this code so that it meets my requirements?

Many Thanks in advance for any replies!

Re: Separately display all records in a recordset

Posted: Fri Dec 04, 2009 5:56 am
by Marinusjvv
My guess is that if you're going to have to combine it with javascript, as php does server side scripting..

Re: Separately display all records in a recordset

Posted: Fri Dec 04, 2009 6:09 am
by daedalus__
php is a pre-processed scripting language.

it only applies to the side of the page that is generated on the server.

you could use ajax to call the script that queries then database then display the new results or put the data into a javascript array and use javascript to modify the content of the pape displaying the data.

this is something you should probably know if you are an IT person for a company. :\