A
Anonymous
Guest
Hello Every one!!
I am having problem with passing value through a pull down menu and then using that value in a PHP while to execute a query using mysql. So it would be great if you take a look of my code and give me some suggestion. Thank you. :?
Here is my code of HTML pull down menu:
I am getting following worning
Warning: Supplied argument is not a valid MySQL result resource in /home/public_html/ShowDomainDescription1.php on line 12
There is no Domain called , Please check the Domain list again.
Here is my code for ShowDomainDescription1.php
I am having problem with passing value through a pull down menu and then using that value in a PHP while to execute a query using mysql. So it would be great if you take a look of my code and give me some suggestion. Thank you. :?
Here is my code of HTML pull down menu:
Code:
<?php
require("");
$link = mysql_connect($host,$user,$pass);
if (!$link)
die("Couldn't connect to MySQL");
mysql_select_db($db)
or die("Couldn't open $db: ".mysql_error());
$result = mysql_query("SELECT Name FROM Domain");
$num_rows = mysql_num_rows($result);
if ($num_rows)
{
print "There are currently $num_rows Domain in the Database <p>";
print "<table border = 1>\n";
while($a_row = mysql_fetch_row($result))
{
print "<tr>\n";
foreach ($a_row as $field)
print "\t<td>$field</td>\n";
$Domain_Name[] = $field;
print "</tr>\n";
}
print "</table>\n";
?>
<form action = "ShowDomainDescription1.php" Method = "POST">
Select any of the domain for more information<br>
<select name = "DomainMenu">
<?php
foreach ($Domain_Name as $Existing_Domain)
print " <option value=\"$Existing_Domain \">$Existing_Domain</option>";
?>
</select>
<input type = "submit" value = "Show" >
</form>
<?php }
else
print "There is no data available in the database";
mysql_close($link); ?>
I am getting following worning
Warning: Supplied argument is not a valid MySQL result resource in /home/public_html/ShowDomainDescription1.php on line 12
There is no Domain called , Please check the Domain list again.
Here is my code for ShowDomainDescription1.php
Code:
<?
require("");
$link = mysql_connect($host,$user,$pass);
if (!$link)
die("Couldn't connect to MySQL");
mysql_select_db($db)
or die("Couldn't open $db: ".mysql_error());
if($_POST['DomainMenu'] == $Existing_Domain)
$result = mysql_query("SELECT Description FROM Domain where Name = '$Existing_Domain'");
$num_rows = mysql_num_rows($result);
if ($num_rows > 0)
{
$Domain_Description = mysql_result($result, 0, 'Description');
print "<h1> $Existing_Domain Description </h1>\n";
print "$Domain_Description";
}
else
print "There is no Domain called $Existing_Domain, Please check the Domain list again.";
mysql_close($link);
?>