ger_mac74 Posted March 8, 2006 Share Posted March 8, 2006 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.Regards. Quote Link to comment Share on other sites More sharing options...
txmedic03 Posted March 8, 2006 Share Posted March 8, 2006 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].<?php$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)); mysql_close($conn); echo str_replace('[SCROLL]', $data['scroll'], $template);} else { echo str_replace('[SCROLL'], 'Nothing to scroll'], $template);}?>[/code]I hope this will point you in the right direction. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.