Forum Moderators: coopster

Message Too Old, No Replies

Dymanic Drop down.

         

shruti

7:01 pm on Aug 1, 2008 (gmt 0)

10+ Year Member



I have a listbox, and if you click on one value"say #*$!" in it then it will display( select * from table where value='#*$!')

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.

mooger35

7:05 pm on Aug 1, 2008 (gmt 0)

10+ Year Member



Well without looking into it too closely

This:

echo "<option value=\"$row[CELLID]\">$row[CELLID]</option>\n";

Should be:

echo "<option value=\"".$row['CELLID']."\">".$row['CELLID']."</option>\n";

shruti

7:17 pm on Aug 1, 2008 (gmt 0)

10+ Year Member



it gets the data into the drop down..............that is not the problem.
Problem is that when you select something n submit, it does not display further data

mooger35

9:31 pm on Aug 1, 2008 (gmt 0)

10+ Year Member



if (isset($_GET['Submit'])){

shruti

3:32 pm on Aug 4, 2008 (gmt 0)

10+ Year Member




System: The following message was spliced on to this thread from: http://www.webmasterworld.com/php/3714831.htm [webmasterworld.com] by jatar_k - 11:41 am on Aug. 4, 2008 (est -4)


Hello All,
MY PROBLEM STILL PREVAILS
I have a problem with the dymanic drop down.
I have a drop down with gets the data from the MYSQL. (IT works)

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]

shruti

4:43 pm on Aug 4, 2008 (gmt 0)

10+ Year Member



got it