Help getting Info from Table
| From: | Michael Elliott | Date: | Thu, 08 Nov 2001 13:54:30 +0000 |
| Subject: | Help getting Info from Table | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-14137@lists.php.net to get a copy of this message | ||
Hello all. I am new to php and mySQL and I am trying to learn and do a
basic website at the same time. I have run into a problem trying to get
information from a table to use in a Option box. What I what is the user to
complete the following (See below):
Department __________________ <-- User enters Department name
as text
Parent __________________ <-- User selects from
previously entered Departments
Basically, the first time data is entered, the Department will be entered
(eg. Clothing) with a blank parent. This is then entered into the mySQL
database. The next entery could be Department = Mens with a Parent =
Clothing. What I want though is for the items previously entered to be
pulled from the mySQL database and the user only need to select the
appropriate Parent Department. (I hope this explains it)
Anyway, here is what I though would work and it doesn't. Any suggestions?
Thanks.
Name:
Parent: Warning: Supplied argument is not a valid MySQL-Link resource
in c:\program
files\nusphere\apache\nsdocs\golfparfection\admin\newdepartment.php on line
31 Warning: Supplied argument is not a valid MySQL result resource in
c:\program
files\nusphere\apache\nsdocs\golfparfection\admin\newdepartment.php on line
33 <?php
mysql_pconnect $DB_SERVER,$DB_LOGIN, $DB_PASSWORD);
$query = "Select Name from $DB.Departments";
$result = mysql_query($query, $link);
for ($i = 0; $i < mysql_num_rows($result); $i++)
echo("<OPTION>" . mysql_tablename($result, $i));
?>
Results in: (Nothing comes up in the Parent field)