Forum Moderators: coopster
I tired but i am getting an error
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<form id="form1" name="form1" method="get" action="<? echo $PHP_SELF; ?> ">
<?php
$host = "localhost";
$user =
$pass =
$dbname =
$connection = mysql_connect("localhost", "root", "") or die("Cannot connect to MySQL server: " .
mysql_error());
$db_selected = mysql_select_db(' ' , $connection);
$query ="select CELLID from comments";
$result=mysql_query($query);
echo "<select name='CELLID'>\n";
while($row=mysql_fetch_assoc($result)){
echo "<option value=\"$row[CELLID]\">$row[CELLID]</option>\n";
}
echo "</select>"; ?>
<input type="submit" name="Submit" value="Select" />
</form>
<hr>
<p>
<?
if (isset($_GET['submit'])){
$result=mysql_query("select problem, solution from comments where id='$select'");
while($row_list=mysql_fetch_assoc($result){
echo $row['problem'];
// End if statement.
}
// Close database connection.
mysql_close();
?>
</p>
</body>
</html>
It gets the cellids from the table but on submit it does not display the related data on the bottom of the page.
What the problem is that if you select one value and do submit it does not display other rows of the same table "comments"
I took reference from other threead and tried but it does not display anything. The page gets refreshed...........thats all what happens..
Can you please help me? Coz i tried to take so many refernces from internet but all in vein
MY code:
[PHP]
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>DROP DOWN</title>
</head>
<body>
<form id="form1" name="form1" method="get">
<select name="names" size="5">
<option value="">--- Select ---</option>
<?php
$connection = mysql_connect("localhost", "root", "") or die("Cannot connect to MySQL server: " .
mysql_error());
$db_selected = mysql_select_db('tmetrix', $connection);
$query ="select CELLID from comments";
$result=mysql_query($query);
// start the select box
while($row=mysql_fetch_assoc($result)){
echo "<option value=\"$row[CELLID]\">$row[CELLID]</option>\n";
}
?>
</select>
<input type="hidden" name="Submit" value="1">
<input type="submit" name="Submit" value="Select">
</form>
<!-- 2nd query to call the correlated data -->
<?php
if ((isset($_GET['Submit'])) AND ($GET['names'] !=""))
{ $query1 = "select * from comments ";
echo "hello";
// it does not even print hello on click ing submit?"
}
else
{
echo " Select something" ;
}
?>
</body>
</html>
[/PHP]