This forum is in archive mode. You will not be able to post new content.

Author Topic: PHP update HTML  (Read 506 times)

0 Members and 1 Guest are viewing this topic.

Offline Code.Illusionist

  • Royal Highness
  • ****
  • Posts: 687
  • Cookies: 39
  • Compile or die trying
    • View Profile
PHP update HTML
« on: 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:

Code: [Select]
$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?
Vae Victis - suffering to the conquered

Offline Schalla

  • VIP
  • Peasant
  • *
  • Posts: 81
  • Cookies: 29
    • View Profile
Re: PHP update HTML
« Reply #1 on: November 26, 2014, 12:21:44 PM »
Hello Code.Illusionist,

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

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

To access the value:
$domelement->nodeValue;


« Last Edit: November 26, 2014, 12:57:15 PM by Schalla »

Offline Code.Illusionist

  • Royal Highness
  • ****
  • Posts: 687
  • Cookies: 39
  • Compile or die trying
    • View Profile
Re: PHP update HTML [Solved]
« Reply #2 on: November 26, 2014, 12:55:35 PM »
Thank you , sir.
Vae Victis - suffering to the conquered

 



Want to be here? Contact Ande, Factionwars or Kulverstukas on the forum or at IRC.