Page 1 of 1

Select from table

Posted: Thu Jun 20, 2002 1:45 am
by ccjob2
Hi,
Is there a way to populate a select tag, in an insert form, with table content ? And if it's possible, how can I insert into new table, into specific field, the selection I made ?

Thanks
Carlo

Posted: Thu Jun 20, 2002 7:46 am
by riley
I hope this is what you are looking for!

Code: Select all

$Mp2SomResult = MSSQL_QUERY($query);
$number = MSSQL_NUM_ROWS($Mp2SomResult);

Code: Select all

<Select Name='Location'>
	<Option></Option>
	<?
	$i=0;
	if ($number > 0) :
		while ($i < $number) :
			$Location = mssql_result($Mp2SomResult,$i,"Location");
			print "<Option Value='$Location'>$Location</Option>";
			$i++;
		endwhile;
	endif;
	?>
</Select>

I think of yes

Posted: Thu Jun 20, 2002 10:16 am
by ccjob2
Thanks,
I asked for MySQL solution, but I think is the same way ... I asked also how to insert info from select variable (in your case $Location) to MySQL field destination.
For example if I use a table:
ID
Location
How can I insert Location content ?

Thanks

Carlo