Dear sir,
"Depending on 1-st list selection, the 2-nd list should get populated."
I have written code. I am getting parse error. please look the code and send the reply soon.
Regards,
sara.
This is my code
<head>
<title>List</title>
</head>
<body>
<?php
$user = "administrator";
$pass = "1234";
$db = "addressbook";
$link = mysql_connect( "localhost", $user, $pass );
if ( ! $link )
die( "couldn't connect to MYSQL" );
mysql_select_db( $db, $link )
or die ( "Couldn't open $db: ".mysql_error() );
?>
<form action="<? print $PHP_SELF ?>" method="POST">
<select name="type">
<option value="name">name</option>
<option value="phone">phone</option>
<option value="email">email</option>
</select>
<?
if ($type == 'phone')
{
print $type;
<select phone = "ID">
$result = mysql_query( "SELECT phone, ID FROM addressbook" );
while( $a_row = mysql_fetch_object( $result ) )
{
print "<option value=\"$a_row->ID\" ";
if ( isset($id) && $id == $a_row->id )
print "selected";
print "> $a_row->phone\n";
}
</select>
}
elseif ($type == 'name')
{
<select name = "ID">
$result = mysql_query( "SELECT name, ID FROM addressbook" );
while( $a_row = mysql_fetch_object( $result ) )
{
print "<option value=\"$a_row->ID\" ";
if ( isset($id) && $id == $a_row->id )
print "selected";
print "> $a_row->name\n";
}
</select>
}
elseif ($type == 'email')
{
<select email = "ID">
$result = mysql_query( "SELECT email, ID FROM addressbook" );
while( $a_row = mysql_fetch_object( $result ) )
{
print "<option value=\"$a_row->ID\" ";
if ( isset($id) && $id == $a_row->id )
print "selected";
print "> $a_row->email\n";
}
</select>
}
mysql_close( $link );
?>
</form>
</body>