repopulate...?
Posted: Tue Apr 19, 2005 8:25 am
Hello everyone!
I'm a newbie in php and i need some help .I have a dropdown select where i select an user (from a table -> date_clienti). I want to print out (in the same page where is located the dropdown menu) the rest of the information about the selected user ,from the same table (name,second-name,telephone,address...) .How can I do that? Tables are created in mysql .
I read some solution from this forum like viewtopic.php?t=30174&highlight=repopulate but I need some example please with code.Thank yuou for your patience!
feyd | Please review how to post code using
I'm a newbie in php and i need some help .I have a dropdown select where i select an user (from a table -> date_clienti). I want to print out (in the same page where is located the dropdown menu) the rest of the information about the selected user ,from the same table (name,second-name,telephone,address...) .How can I do that? Tables are created in mysql .
I read some solution from this forum like viewtopic.php?t=30174&highlight=repopulate but I need some example please with code.Thank yuou for your patience!
Code: Select all
<html>
<head>
<title></title>
</head>
<body>
<table align="center" border="1" cellspacing="10">
<tr>
<td>
<form name="myform" method="post" action="delete.php">
<select name="varclient_id" onChange="">
<option selected value="">
<?
include ("../conectare.php");
$sql="select client_id,name,second_name from date_clienti order by name asc";
$rezultat=mysql_query($sql);
$nr_rows=mysql_num_rows($rezultat);
if ($varclient_id>0) {
$varclientid=$varclient_id;
}
if ((isset($varclient_id) and ($varclient_id!=($nr_rows+1)) and ($varclient_id>0))) {
$populare=mysql_query("SELECT client_id,name,second_name from date_clienti where client_id=$varclient_id order by name asc");
$var_pop=mysql_fetch_array($populare);
$varclient_id=$var_pop['client_id'];
$n=$var_pop['name'];
$pren=$var_pop['second_name'];
echo("$n  $pren");
echo("<option value=($nr_rows+1)>Client\n");
}
else {
echo ("Client");
$varclient_id=($nr_rows+1);
}
$populare=mysql_query("SELECT client_id,name,second_name from date_clienti where client_id!=$varclient_id order by name asc");
while ($repopulare=mysql_fetch_array($populare)) {
$varclient_id=$repopulare['client_id'];
$n=$repopulare['name'];
$pren=$repopulare['second_name'];
echo("<option value='$varclient_id'>$n  $pren\n");
}
mysql_close;
?>
</select>
<input type="submit" value="Delete">
</form>
</td></tr>
</table>
</body>
</html>feyd | Please review how to post code using
Code: Select all
andCode: Select all
tags. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]