Jump to content

innerHTML == PHP ! Javascript


wyght

Recommended Posts

It has been ten years since I last wrote any code. I am trying to use PHP to write into a HTML element. I know JavaScript has the innerHTML function but I cannot seem to find any equivalent PHP function. My questions are

 

1) Is there an equivalent PHP function to innerHTML?

 

If not

 

2) Is there an intelligent method of using PHP fire JavaScript innerHTML

 

Why?

 

I want to get data from MySQL DB using PHP and print one record at a time to the webpage. I will be using a <div> tag as the data will be longer then one line so I do not want to use a span tag. I would like to force line breaks therefore I am using CSS with 'display:block;' I have not found a way to print the data from MySQL

Link to comment
Share on other sites

It sounds to me like you could simply apply the HTML within your PHP instead of the other way around (although the other way around is possible as well).

 

EG1:

 

<?phpecho "<div style='display: block;'>";echo $result;echo "</div>";?>

 

 

EG2:

 

<?phpecho "<div style='display: block;'>";while ($row = mysql_fetch_array($result, MYSQL_NUM)) {   echo $row[0] . "<br>"}echo "</div>";?>

 

 

EG3:

 

<div style="display: block;"><?php echo $result; ?></div>

 

EG3:

 

<div style="display: block;"><?php while ($row = mysql_fetch_array($result, MYSQL_NUM)) {   echo $row[0] . "<br>"}?></div>

 

 

Maybe I'm misunderstanding?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.