PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
reecec
Forum Contributor
Posts: 218 Joined: Sun Apr 02, 2006 7:12 am
Post
by reecec » Wed Jul 26, 2006 9:58 am
Hi all
how would i make it so that it will display all the fields from the table and put them in a dropdown what is wrong with this
Code: Select all
$result = mysql_query("select * from $url limit 100");
if ($result) {
?>
Search
<form action="" method="post">
<input name="search" type="text" />
<select name="field"><option><? while (mysql_fetch_field($result)) ?></option></select>
thanks reece
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Wed Jul 26, 2006 10:02 am
getting the fields, would be a DESCRIBE query, not a SELECT.
reecec
Forum Contributor
Posts: 218 Joined: Sun Apr 02, 2006 7:12 am
Post
by reecec » Wed Jul 26, 2006 10:16 am
o sorry i copied it from the wrong code thanks i know what to do know
thanks
reecec
Forum Contributor
Posts: 218 Joined: Sun Apr 02, 2006 7:12 am
Post
by reecec » Wed Jul 26, 2006 11:27 am
hi all
shouldnt this work
i get this error
Parse error: parse error, unexpected T_STRING.
it doesnt like having the value in a drop down but will do an echo.
Code: Select all
<?php
$resource = mysql_query("DESCRIBE `profiles`");
while ($data = mysql_fetch_assoc($resource))
{
?>
<elected><option><? ' .$data['Field']. ' ?> </option><selected>"
<?
}
?>
thanks reece
klarinetking
Forum Commoner
Posts: 59 Joined: Mon Jul 24, 2006 9:43 am
Post
by klarinetking » Wed Jul 26, 2006 1:41 pm
Hi,
Try this:
Code: Select all
<?php
$resource = mysql_query("DESCRIBE `profiles`");
while ($data = mysql_fetch_assoc($resource))
{
?>
<elected><option><?php echo $data['Field']; ?> </option><selected>
<?
}
?>
reecec
Forum Contributor
Posts: 218 Joined: Sun Apr 02, 2006 7:12 am
Post
by reecec » Thu Aug 03, 2006 4:06 pm
thanks for your help i have sorted it now
reece