Selecting listbox results
Posted: Sat May 09, 2009 4:50 pm
I'm a newbee with php and mysql. I am able to successfuly display the results of my database table to a web page.
Now I am working with making a list box that displays all the names, and I wish to be able to edit any of the fields based on what is selected in the list box.
I felt good about being able to get the list box displayed in the order I wanted, but stumped on creating text boxs on the same page with the contents of the fields based on the name selected.
Table Structure is
JediName VARCHAR(50)
Level INTEGER
Status VARCHAR(15)
Updated DATE
Updater VARCHAR(50)
Email VARCHAR(50)
Comments VARCHAR(50)
Jnum INTEGER (AUTO) (KEY)
If i can see how to get 1 textbox like Status with the status of the name selected in the list box, I should be ok from there.
Here is what I have so far:
Now I am working with making a list box that displays all the names, and I wish to be able to edit any of the fields based on what is selected in the list box.
I felt good about being able to get the list box displayed in the order I wanted, but stumped on creating text boxs on the same page with the contents of the fields based on the name selected.
Table Structure is
JediName VARCHAR(50)
Level INTEGER
Status VARCHAR(15)
Updated DATE
Updater VARCHAR(50)
Email VARCHAR(50)
Comments VARCHAR(50)
Jnum INTEGER (AUTO) (KEY)
If i can see how to get 1 textbox like Status with the status of the name selected in the list box, I should be ok from there.
Here is what I have so far:
Code: Select all
<?php header("Content-type: text/html; charset=utf-8");?>
<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<TITLE>Test of Listbox Display of Jedi Members Table</TITLE>
<BODY>
<p>Select Member<br>
<?
// Get $username $password $database from this included file
include("jedi.inc.php");
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die("Unable to select database");
$query="SELECT JediName FROM Members ORDER BY JediName";
// this will be needed to get special characters
mysql_query("SET NAMES 'utf8'");
$result=mysql_query($query);
echo "<select name=listbox size=10>Student Name</option>";
// printing the list box select command
while ($line = mysql_fetch_array($result)){//Array or records stored in $line
foreach ($line as $value)
{
echo "<OPTION value='$value'";
}
echo ">$value</OPTION>";
}
// $num=mysql_numrows($result);
mysql_close();
echo "</SELECT>";
?>
</BODY>
</HEAD>