Jump to content

[SOLVED] Radio button array


Thomisback

Recommended Posts

I don't see why not.

 

I'm not sure of the specific code for the job, but it'd be a mysql_query("") with a while and a mysql_fetch_array.

 

something like this:

 

$read_tables = mysql_query(" sql query goes here (cheack the MySQL Manual for this)");

//this will read each table and output its values to a variable called table
while($table = mysql_fetch_array($read_tables))
{

print'
<label>
$table['name'] 
<input type="radio" id="'.$table['name'].'" name"'.$table['name'].'"  />
</label>
<br />';

}

 

 

I successfully did it but I now have too many tables (lol) so I changed my mind to a combo box but I can't figure out how to do it.

 

For my radio input I now have:

echo "<label>";
print "$row[0]\n";
echo "<input type=radio id=";
print "$row[0]\n";
echo "name=";
print "$row[0]\n";
echo "/>
</label>
<br>";

 

So how would I configure a combo box like this to do the same?

<input type="select" name="OS">
  <option value="Win95">Windows 95/98</option>
  <option value="WinNT">Windows NT/2000</option>
  <option value="OSX">Macintosh OS X</option>
  <option value="OS9">Macintosh OS 9</option>
  <option value="Linux">Linux</option>
  <option value="Solaris">Solaris</option>
  <option value="BSD">FreeBSD</option>
</input>

<?php

mysql_connect("localhost", "root", "");

$result = mysql_list_tables("test");

$num_rows = mysql_num_rows($result);

 

echo "<select name=''>";

for ($i = 0; $i < $num_rows; $i++) {

echo "<option value=''>".mysql_tablename($result, $i)."</option>";

}

echo "</select>";

   

 

 

mysql_free_result($result);

?>

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.