EvilZone

Programming and Scripting => Web Oriented Coding => : Code.Illusionist November 26, 2014, 09:54:56 AM

: PHP update HTML
: Code.Illusionist November 26, 2014, 09:54:56 AM
Hello there, I am interested to know how can I update HTML paragraph with some ID with PHP script. Let's assume I have separated HTML page and PHP script. When user type text in textbox and click submit, it activates PHP script to change something. I had stupid idea (it's just for learning purposes), to search for word in text and when script finds it, replace it to be bold. I would use this function:

:
$find = $_POST['something']; //get user's input
// str_replace($find,'<b>{$find}</b>',HERE GOES CONTENT OF PARAGRAPH);

I repeat, this is only to practice a bit with PHP, I know that no one do finding words like this. Anyone have idea how to take this paragraph string from some ID?
: Re: PHP update HTML
: Schalla November 26, 2014, 12:21:44 PM
Hello Code.Illusionist,

you are looking for DomDocument: http://php.net/manual/de/class.domdocument.php (http://php.net/manual/de/class.domdocument.php)

Especially this function:
http://php.net/manual/de/domdocument.getelementbyid.php (http://php.net/manual/de/domdocument.getelementbyid.php)

To access the value:
$domelement->nodeValue;


: Re: PHP update HTML [Solved]
: Code.Illusionist November 26, 2014, 12:55:35 PM
Thank you , sir.