By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,746 Members | 1,924 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,746 IT Pros & Developers. It's quick & easy.

Relaying messages through php to a html page...

P: 15
What im trying to do is get messages from php script (using a database) to show up on a html page but with a forum type feel to it as in the ability ot delete messages after they are no longer needed. Whats the best way to do this if any?

DD
Aug 19 '08 #1
Share this Question
Share on Google+
7 Replies


Markus
Expert 5K+
P: 6,050
What have you done? What haven't you done?
Please show what you have already written.
Aug 19 '08 #2

P: 15
at the moment i havent got anything other than the html pag i wish to use... im not after someone to do it for me i just need a nudge in the right direction thats all..

just before anyone pips up and goes about security issues its not for use online its for my own computer page..

as i said im just looking for a nudge in the right direction so if anyone can help or point me to a helpful site or anything that would be great..

DD
Aug 20 '08 #3

pbmods
Expert 5K+
P: 5,821
Heya, DD.

Will you have PHP code stored in the database that you need to execute, or do you just need to output HTML?
Aug 20 '08 #4

P: 15
Heya, DD.

Will you have PHP code stored in the database that you need to execute, or do you just need to output HTML?
At the present time just out put to HTML and as i said earlier with the ability to delete the message from the html page (like an email inbox type probably best way to put it)

DD
Aug 20 '08 #5

nathj
Expert 100+
P: 938
Hi there,

So you have information in a table that you want to display, you also want to be able to add, edit and delete is that correct?

If that's correct then I would have a PHP page for each of those major functions, plus one main page that display it all.

On the main page I would use PHP to retrieve the info from the DB and echo out the results as HTML. This page would also include some buttons/links to execute the functions above. On these buttons/links I would have a call to a relevant JS function that would, via AJAX, call the required PHP function. this PHP function would execute the required code and echo the output to a container on the main PHP Page. this would keep you always on the same page without any refreshes.

In summary then I would have:
1. JS function in a separate file that is used to execute the PHP code
2. One main page written in PHP that displays the information and functions
3. One PHP pager per main function that I wish to execute
4. A DB with all the stored data in.

Does that help out? If you need further examples I have plenty as this pretty much how I build most of my sites.

Cheers
nathj
Aug 20 '08 #6

P: 15
Any examples would be great to get me going... as im not overly skilled with php right now and any help would be great.

except about the tables i use css to layout things with mine but pretty much you hit the nail on the head Nathj.

Thanks for the help here people.

DD
Aug 20 '08 #7

nathj
Expert 100+
P: 938
Any examples would be great to get me going... as im not overly skilled with php right now and any help would be great.

except about the tables i use css to layout things with mine but pretty much you hit the nail on the head Nathj.

Thanks for the help here people.

DD
When I mentioned tables I meant as in a database - I never use tables on a website - I hate them, it's css all the way - though css3 promises CSS tables which look interesting.

Anyway I digress. It's examples you are after. Here's a simple code snippet from my code library that will get information from a table and display it as HTML
[PHP]
function __autoload($pcClassName)
{
require_once '../lib/' . $pcClassName . '.php' ;
}

$loDataObject = new dataObject() ;

$lcDisplay = "" ;

$lnPageID = $_GET['page'] ;

$lcSelect =
"SELECT
a.ID, a.menuID, a.title, a.content
FROM tbl_content a
WHERE a.ID = $lnPageID" ;

$laContent = $loDataObject->queryGetData(false, $lcSelect) ;

if($laContent)
{
foreach($laContent as $laContentRow)
{
$lcDisplay .= '<h1>' . $laContentRow['title'] . '</h1>' ;
$lcDisplay .= $laContentRow['content'] ;
}
echo $lcDisplay ;
}
[/PHP]
for information on the dataObject read this article

this code simply gets information from a DB and displays the heading adn the paragraphs. any specific formatting can be done in the field content as this is a longtext field in a MyISAM DB.

As for the SJAX side of things I recommend having a read of the PHP tutorial especially the sections about MySQL and AJAX.

This should get you started, if you get stuck with any specifics as you go give me a shout and I'll do my best to help out.

Cheers
nathj
Aug 20 '08 #8

Post your reply

Sign in to post your reply or Sign up for a free account.