Separately display all records in a recordset

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
pdawallace
Forum Newbie
Posts: 1
Joined: Fri Dec 04, 2009 2:53 am

Separately display all records in a recordset

Post 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!
Marinusjvv
Forum Commoner
Posts: 29
Joined: Wed Dec 02, 2009 5:59 am

Re: Separately display all records in a recordset

Post by Marinusjvv »

My guess is that if you're going to have to combine it with javascript, as php does server side scripting..
User avatar
daedalus__
DevNet Resident
Posts: 1925
Joined: Thu Feb 09, 2006 4:52 pm

Re: Separately display all records in a recordset

Post 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. :\
Post Reply