Jump to content

PHP code in html


gw32

Recommended Posts

This doesn't work inside html.

<tr valign="top">
                <td height="22" align="right" valign="middle"><!-- <img src="images/bult-gamblingtemplatesdotnet.jpg" width="11" height="11"> --></td>
                <td height="22" valign="middle"><class="navbar3">
                <?php
		include("config.php");
		$result = mysql_query("SELECT name, lic_num, purpose FROM charity where sysdate() between start_date and end_date");
		while ($row = mysql_fetch_array($result,MYSQL_ASSOC)) {
		print "<b>Charity: </b>".$row{'name'}."<br><b>License #: </b>".$row{'lic_num'}."<br><b>Purpose: </b>".$row{'purpose'}."<p>";
		}
		mysql_close($dbh);
	?></td>

 

This is the output on the website.

Charity: ".$row{'name'}."
License #: ".$row{'lic_num'}."
Purpose: ".$row{'purpose'}."

"; } mysql_close($dbh); ?>

 

When I do this

<tr valign="top">
     <td height="22" align="right" valign="middle"><!-- <img src="images/bult-gamblingtemplatesdotnet.jpg" width="11" height="11"> --></td>
     <td height="22" valign="middle"><class="navbar3"><?php include("test.php"); ?></td>
</tr>

 

I get this



 

Can someone please point me in the correct direction?

Also if I run the code as a stand alone it works perfectly.

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/235120-php-code-in-html/
Share on other sites

It's in a .php file and I'm using include

Here is the test.php file;

<?php
include("config.php");
$result = mysql_query("SELECT name, lic_num, purpose FROM charity where sysdate() between start_date and end_date");
while ($row = mysql_fetch_array($result,MYSQL_ASSOC)) {
print "<b>Charity: </b>".$row{'name'}."<br><b>License #: </b>".$row{'lic_num'}."<br><b>Purpose: </b>".$row{'purpose'}."<p>";
}
mysql_close($dbh);
?>

 

Where config.php is the database connect info.

 

Link to comment
https://forums.phpfreaks.com/topic/235120-php-code-in-html/#findComment-1208357
Share on other sites

I'm thinking that the query is returning an empty result set. Do you get any results returned if you paste the query "SELECT name, lic_num, purpose FROM charity where sysdate() between start_date and end_date" in to phpMyAdmin (or whatever you prefer to use) and execute it?

 

From looking at it, it seems like it should read more like:

SELECT name, lic_num, purpose FROM charity where start_date < NOW() AND end_date > NOW()

Link to comment
https://forums.phpfreaks.com/topic/235120-php-code-in-html/#findComment-1208375
Share on other sites

In my HTML code I am using it like this:

<tr valign="top">
     <td height="22" align="right" valign="middle"><!-- <img src="images/bult-gamblingtemplatesdotnet.jpg" width="11" height="11"> --></td>
     <td height="22" valign="middle"><class="navbar3"><?php include("test.php"); ?></td>
</tr>

 

Here is the webiste as it sits using the above: http://dswdesigns.net/pp4c/index.html

Here is the stand alone code of test.php and it works: http://dswdesigns.net/pp4c/test.php

 

Thanks

 

 

Link to comment
https://forums.phpfreaks.com/topic/235120-php-code-in-html/#findComment-1208388
Share on other sites

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.