![]() |
PHP and MySQL question
If you want to get all possible values for a SET column, you should use: SHOW COLUMNS FROM table_name LIKE set_column_name and parse the SET definition in the second column.
Ok, that's nice, but what the hell does it mean? Say I have a SET column in my database, with 10 values. I want to create an HTML select item, with the values being the values from the possible values in the SET column. I found how to do this from items already entered. I found (sorta) how to get the possible values...but I don't know how to access them... Any ideas? MPEDrummer |
If it is just the SQL that you are talking about, then the statement is a SELECT statement.
The output that you need will vary wildly on the data that you need to extract from the table(s). The basic format would be "Select [fields] from [table(s)] where [criteria];" A better guide can be found here: http://www.devhood.com/tutorials/tut...tutorial_id=74 The best way to extract/display data is to use SQL for the extraction and then PHP/HTML/Whatever to display the data. That way you don't have to worry about creating some rocket science code to parse data that you have taken from the db to display. Just my $0.02... Let me know if this helps. Thx, Scyther |
Unless I'm missing something, that's not really what I'm looking for. I need to display the actual column information, not the column contents.
|
I sorta got it, but I have another question, this time with examples.
Code:
function get_set($table,$column) { 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 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 |
Whoops! Makes more sense now that I can see (in code) what it is that you were trying to do.
Sorry to lead you down the wrong path. I am working on something similar right now myself. Good luck! Scyther |
All times are GMT -8. The time now is 10:54 AM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
Search Engine Optimization by vBSEO 3.6.0 PL2
© 2002-2012 Tilted Forum Project