Hi ...

I'm trying to make a drop down list box populated from a mysql table.

It all looks OK on the screen, but there is an error that I cant seem to fix.

The error is:

Notice: Undefined index: xxx in C:\Documents and Settings\GSW\My Documents\xxx\test.php on line 29

and the code is:

<?php


include("openatname.php");  // access database

$result= mysql_query("SELECT DISTINCT d_sec FROM domains WHERE d_genre LIKE 'family'");  // find records that include 'family' in the d_genre column.

$domainecho ="";    // put the form in an echo for easier positioning on an html page


$domainecho.="<form name='GetDomain' method='post'>";
$domainecho.="<select name=xxx size=12 style='width: 150px'>";



	while($row = mysql_fetch_array($result))
	{
	$y=$row['d_sec'];
$domainecho.="<option value=$y>$y</option>";
	}


$domainecho.="	</select>
		<input type=submit>
		</form>";

echo  $domainecho;      // this form output can be placed anywhere on page using <div>

$domain=$_POST['xxx'];

echo "<br><br><br>". $domain;

?>

Any ideas?
G-fer

Recommended Answers

All 2 Replies

Hi ...

I'm trying to make a drop down list box populated from a mysql table.

It all looks OK on the screen, but there is an error that I cant seem to fix.

The error is:

Notice: Undefined index: xxx in C:\Documents and Settings\GSW\My Documents\xxx\test.php on line 29

and the code is:

<?php


include("openatname.php");  // access database

$result= mysql_query("SELECT DISTINCT d_sec FROM domains WHERE d_genre LIKE 'family'");  // find records that include 'family' in the d_genre column.

$domainecho ="";    // put the form in an echo for easier positioning on an html page


$domainecho.="<form name='GetDomain' method='post'>";
$domainecho.="<select name=xxx size=12 style='width: 150px'>";



	while($row = mysql_fetch_array($result))
	{
	$y=$row['d_sec'];
$domainecho.="<option value=$y>$y</option>";
	}


$domainecho.="	</select>
		<input type=submit>
		</form>";

echo  $domainecho;      // this form output can be placed anywhere on page using <div>

$domain=$_POST['xxx'];

echo "<br><br><br>". $domain;

?>

Any ideas?
G-fer

:) hey there g-fer!

[give this a try] i hope this helps :

<?php


include("openatname.php");  // access database

$result= mysql_query("SELECT DISTINCT d_sec FROM domains WHERE d_genre LIKE 'family'");  // find records that include 'family' in the d_genre column.

$domainecho ="";    // put the form in an echo for easier positioning on an html page


$domainecho.="<for method='post'>"; // [ name='GetDomain'] attribute is removed [not really sure this affects but for less confusions though.  ~_^]
$domainecho.="<select name='xxx' size=12 style='width: 150px'>"; // and [name=xxx] added [' '] to it.



	while($row = mysql_fetch_array($result))
	{
	$y=$row['d_sec'];
$domainecho.="<option value=$y>$y</option>";
	}


$domainecho.="	</select>
		<input type=submit>
		</form>";

echo  $domainecho;      // this form output can be placed anywhere on page using <div>

$domain=$_POST['xxx'];

echo "<br><br><br>". $domain;

?>

great day ahead man! ~_^

Hmm...

Nup ... didn't make any difference.

I've just noticed that the error is actually a notice ... the selection echo's ok, (line 31) but I'm wondering if it will cause any problems later down the line

G-fer

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.