I am having fits with placing a snippit of php into a html file. The php works great by itself but when placed into the html it fails!?!?!
The php I’m placing:[php]<?php
require(“dealer_map_dbinfo.php”);
mysql_connect($local_host,$username,$password);
@mysql_select_db($database) or die( “Unable to select database”);
$state_name_query = “SELECT state_name FROM states_list”;
echo “”;
$state_name = mysql_query($state_name_query) or die(mysql_error());
$dropdown = “”;
while($row = mysql_fetch_assoc($state_name)) {
$dropdown .= “\r\n<option value=’{$row[‘state_name’]}’>{$row[‘state_name’]}”;
}
$dropdown .= “\r\n”;
echo $dropdown;
mysql_close();
?>
[/php]
and the html with the php in it:[code]
Dealer Locator <?php require("dealer_map_dbinfo.php"); mysql_connect($local_host,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $state_name_query = "SELECT state_name FROM states_list"; echo ""; $state_name = mysql_query($state_name_query) or die(mysql_error()); $dropdown = ""; while($row = mysql_fetch_assoc($state_name)) { $dropdown .= "\r\n{$row['state_name']}"; } $dropdown .= "\r\n"; echo $dropdown; mysql_close(); ?>Locator
Address or Zipcode:Radius: <select id="radiusSelect">
<option value="25" selected>25mi</option>
<option value="50">50mi</option>
<option value="100">100mi</option>
<option value="200">200mi</option>
</select>
<input type="button" onclick="searchLocations()" value="Search Locations"/>
<br/>
<br/>
|
When I run the html page using xampp or a live “test” page I get the same results:
"; $state_name = mysql_query($state_name_query) or die(mysql_error()); $dropdown = “DROP DOWN SHOWS HERE”; echo $dropdown; mysql_close(); ?> BUTTON SHOWS HERE
appears on the html page with the correct buttons where I’ve indicated USING ALL CAPS
So I tried to add in some start php, end php tags like so:
[php]<?php
require(“dealer_map_dbinfo.php”);
mysql_connect($local_host,$username,$password);
@mysql_select_db($database) or die( “Unable to select database”);
$state_name_query = “SELECT state_name FROM states_list”;
?>
'><?php{$row['state_name']}?><?php; } $dropdown .= ?>
<?php; echo $dropdown; mysql_close(); ?> [/php]
The php code does not show up but all the drop down has in it is '>
Thanks for any help.