Jump to content

displaying PHP in innerHTML


newbie_07

Recommended Posts

I have CSS Tabs.

I want to display php code in innerHTML.

 

my code is:

 

if (tab=="admin"){
main.innerHTML="<center><strong>Admin Details</strong></center>
<?php 
            $sql = "select * from payments where client_id = $_POST[c_id]";
            print $sql;
            $res = mysql_query($sql);
            $row = mysql_fetch_assoc($res);
            $b_name = $row['bank_name'];
            echo "$b_name";
        ?>
            
        ";
    }

 

The php code isn't dispalying.

Plz Help

Link to comment
https://forums.phpfreaks.com/topic/106040-displaying-php-in-innerhtml/
Share on other sites

PHP runs on the server and sends the output to the client.

 

Javascript runs on the client after the page has been sent.

 

If you want to call PHP from the client wou will need AJAX, sending an xmlhttp request to the server and then assigning the output returned by the request to main.innerHTML.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.