Connect to database
Posted: Wed May 19, 2010 2:41 am
Hi, I just started learning and looking for help.
On one of my computer the following code is working; php files in c:apache\htdocs\TTSystems and database in c:apache\mysql\data\TTSystems.
I installed Xampp on a new computer. Copied all php files in c:xampp\htdocs\TTSystems, and database files in c:xampp\mysql\data\TTSystem.
Now my following code is populating the list box with the values retreived from table "TroppoGroup", but not printing the selected option (Group_Selection). Please help me!!!
On one of my computer the following code is working; php files in c:apache\htdocs\TTSystems and database in c:apache\mysql\data\TTSystems.
I installed Xampp on a new computer. Copied all php files in c:xampp\htdocs\TTSystems, and database files in c:xampp\mysql\data\TTSystem.
Now my following code is populating the list box with the values retreived from table "TroppoGroup", but not printing the selected option (Group_Selection). Please help me!!!
Code: Select all
<form name="form1" method="post" action="file:htdoc/Troppo_Screen.php">
<p> </p>
<p align="center"><font face="Century Gothic">Function Types</font>
<select name="Group_Selection">
<option value></option>
<?php
$db = mysql_connect("localhost", "abc", "xyz");
mysql_select_db("mnop",$db);
$resultID = mysql_query("Select Group_options FROM TroppoGroup", $db);
while ($row = mysql_fetch_row($resultID))
{
foreach ($row as $field)
{
print "<option value = $field> $field";
}
print "</option>";
}
?>
</select>
</p>
<p align="center">
<input type="submit" name="Submit" value="Select">
</p>
</form>
<font size="2" face="Century Gothic">
<?php
if ($Group_Selection == "Under-5-years-Troppo")
{
$dash = "-";
$Group_Selection = str_replace($dash, " ",$Group_Selection);
print "<b>$Group_Selection.</b><br>";