Jump to content


Display select statement results in a scrolling window within html template

  • Please log in to reply
1 reply to this topic

#1 ger_mac74

  • Members
  • PipPip
  • Member
  • 24 posts

Posted 08 March 2006 - 04:37 PM

Hi I am new enough to php.

I have designed a website and want to have certain ahref links on this website activate php programs. This is what I would like the php programs to do:

When the link is clicked the php program is actived.
I would like this php program to load up a certain html template webpage that I have designed and within this template I would like to have a scrolling window that displays the results of a select statement. Each php program and therefore each ahref link will run a different select statement, the statements results will be viewed inside the same scrolling window which will be inside the same website template. Any ideas on how I might do this? I understand that I 'include' the html page at the start of each of these php programs but I dont know how to tell this php program where in the html template the scrolling window will be displayed and also I dont know how to get the select script to run in the scrolling window. Also I dont know if there is a way to view this select statements in scrolling windows. Hope you can help.


#2 txmedic03

  • Members
  • PipPipPip
  • Advanced Member
  • 313 posts
  • LocationCall, TX, USA

Posted 08 March 2006 - 10:24 PM

You need to use two includes and include a header and a footer rather than the whole template or read the contents of the template and replace a tag like [SCROLL THING HERE] with your scrolling select results then echo it. The scrolling can be done with JavaScript. Please note that your PHP is not a program, but a script. Scripts are processed by an interpreter and are unmodified from the original flat file format written by the author. A program however is compiled code which does not require an interpreter to execute. Your PHP script is processed by an interpreter on the server-side then the results, if any, are passed along with any HTML that was on the page to the end-user's browser. Making the text scroll would be a question for the HTML / Javascript / CSS forums, but I can help you with retrieving data from a mysql select statement and passing it along.

Let's assume your template is template.html and in it where the scrolling text should be is [SCROLL].


$template = implode('\r\n', file('template.html'));

if ( isset($_GET['scroll']) ) {
$conn = mysql_connect('localhost','user','pass') or die("ERROR: ".mysql_error());
mysql_select_db('database', $conn) or die("ERROR: ".mysql_error());
$data = mysql_fetch_assoc(mysql_query("SELECT * FROM table WHERE id=".$_GET['scroll']." LIMIT 1", $conn));
echo str_replace('[SCROLL]', $data['scroll'], $template);
} else {
echo str_replace('[SCROLL'], 'Nothing to scroll'], $template);


I hope this will point you in the right direction.


I can't stop you from doing something silly, but at least I can help you do it right.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users