Jump to content

Table Fields in a dropdown


reecec

Recommended Posts

Here's basically how you'd do it:
<?php
// Connect to database

$query = "SELECT id, name FROM fields";
$result = mysql_query($query);
echo '<select name="fields">';
while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
    echo '<option value="'.$row[0].'">'.$row[1].'</option>';
}
echo '</select>';
?>

Of course, replace the values you're working with to make it work.
Link to comment
Share on other sites

[b]describe[/b] provides ALL the information - http://www.webdevelopersnotes.com/tutorials/sql/mysql_lesson_mysql_tables.php3

get the column (field) names [b]only[/b] - see the snippet by jamesl at si-usa dot com at http://ca.php.net/manual/en/function.mysql-field-name.php

You should be able to do what you want based on that snippet and a little coding.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.