I sorta got it, but I have another question, this time with examples.
Code:
function get_set($table,$column) {
$sql = "SHOW COLUMNS FROM $table LIKE '$column'";
if (!($ret = mysql_query($sql))){
die("Error: Could not show columns");
}
$line = mysql_fetch_assoc($ret);
$set = $line['Type'];
$set = substr($set,5,strlen($set)-7); // Remove"set(" at start and ");" at end
return preg_split("/','/",$set); // Split into and array
}
That's the function I'm using to create the array that contains the information I need.
http://test.komta.com/test%20form.php
You can see it in action there. All the select items were created this way, using the following call...
Code:
// Create colorType select field
$colorset = $db->get_set(iris, colorType);
echo 'select name="colorType" size="1"\n';
foreach ($colorset as $row) {
echo "option value =\"$row\">$row</option>\n";
}
echo '</select><br>';
// End colorType /select
// I had to get rid of the < before select and option, TFP was trying to render it
I have the function in an included class ($db), that's why the function is called that way.
So, here's my question...if you look at the selects, you'll notice that 3 of them have an ' in front of the first value. I don't know where it's coming from, and I'd really like to get rid of it...
I don't think it's the function, because it works with the other ones with no problem.
Shit. I know what it is...the ones that aren't working are ENUM, not SET, so when I remove the first 5 characters of $set, I'm not removing enough...ok, nevermind. I'm posting this anyway because it was a pain in the ass to type.
MPEDrummer