Jump to content

Convert php result to HTML


magie

Recommended Posts

Hey guys

 

I have a little question, i tryed to figure out. I have a program site, who only can use HTML scripts. And I have my Php script, that sent the form result to my sql database, and then another script pick it up by echo.

 

But is there there any way that maybe a html script to pick up the result from mysql or a php script to convert the result to Html.

Link to comment
Share on other sites

PHP and HTML are different things, but you do not need to convert from one the the other, you just generate the HTML in your PHP script. Also, HTML can reside inside a PHP file, together, as the PHP server will execute the PHP code, output the remaining HTMl to the browser, and that's exactly what your seeing now with PHP Freaks...

 

Example...

 

echo("<p>".$row['comments']."</p>");

 

That will output the comments in a paragraph, you can use code similar to this in any part of the HTML, because the server executes it before it hits the browser.

 

Happy Xmas!

ILMV

 

 

Link to comment
Share on other sites

Hey ILMV

 

I helped a little, but still it just write the code, not the result.

 

Its because im using E107

 

But my code is like this

 

<?php
// set database server access variables:
$host = "localhost";
$user = "twossdow_siteadm";
$pass = "******";
$db = "twossdow_recentrealism";

$connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!");

// select database
mysql_select_db($db) or die ("Unable to select database!");

// create result
$result = mysql_query("SELECT * FROM Opponent");

while($row = mysql_fetch_array($result))

  echo ("<p>".$row['Opponent']."</p>");

// create result
$result = mysql_query("SELECT * FROM Winner");

while($row = mysql_fetch_array($result))

  echo ("<p>".$row['Winner']."</p>");

// create result
$result = mysql_query("SELECT * FROM Result");

while($row = mysql_fetch_array($result))

  echo ("<p>".$row['Result']."</p>");

?>

 

Link to comment
Share on other sites

Hey ILMV

 

I helped a little, but still it just write the code, not the result.

 

Its because im using E107

 

But my code is like this

 

<?php
// set database server access variables:
$host = "localhost";
$user = "twossdow_siteadm";
$pass = "******";
$db = "twossdow_recentrealism";

$connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!");

// select database
mysql_select_db($db) or die ("Unable to select database!");

// create result
$result = mysql_query("SELECT * FROM Opponent");

while($row = mysql_fetch_array($result))

  echo ("<p>".$row['Opponent']."</p>");

// create result
$result = mysql_query("SELECT * FROM Winner");

while($row = mysql_fetch_array($result))

  echo ("<p>".$row['Winner']."</p>");

// create result
$result = mysql_query("SELECT * FROM Result");

while($row = mysql_fetch_array($result))

  echo ("<p>".$row['Result']."</p>");

?>

 

If the file is a .HTML file then that's exactly what you would see, because that's what the server does with that kind of file. Changing it to .PHP would solve that problem.

Link to comment
Share on other sites

Hang on I think I get it, they are using E107 which is a CMS, but he/she is trying to add PHP code within via the CMS  system, so it treats it as text and not native PHP code.

 

Just like you would expect when replying here, you could enter PHP code, but it would display it as text, because that's its job.

 

ILMV

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.