AncientSage Posted August 1, 2006 Share Posted August 1, 2006 Hello, I'm in need of knowing how to get data from one field, and from another, and so that they are associated. For example...[code]CREATE TABLE config ( config_name varchar(255) NOT NULL, config_value varchar(255) NOT NULL, PRIMARY KEY (config_name));INSERT INTO config (config_name, config_value) VALUES ('max_file_size', '10000');[/code]I'd want to get config_name's row max_file_size, and then have it draw the value 10000 out associated with it. This is what I have so far...[code] SELECT config_name, config_value FROM config WHERE config_name = "max_file_size" ORDER BY config_name[/code]Will it work because it is primary key? Or do I have to do something else? Quote Link to comment Share on other sites More sharing options...
AncientSage Posted August 1, 2006 Author Share Posted August 1, 2006 Well, so yes, it appears this would be fine after doing a bit more research (config_name and config_value...values, were submitted into the same row. So I'd guess it draws the value of that row (max_file_size, as well).Now, if this syntax isn't correct, please do, find my problem in it.Anyway, I need to put the information into this: $hidden_field = "<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"" . $maxfilesize . "\" />";So yes, $maxfilesize is probably not putting what I want, as I want the config_value put into value, and not config_name. But I want the config_name to get me the value of the row, and then put it in $maxfilesize. Quote Link to comment Share on other sites More sharing options...
king arthur Posted August 1, 2006 Share Posted August 1, 2006 [code]SELECT config_name, config_value FROM config WHERE config_name = "max_file_size" ORDER BY config_name[/code]You don't have to pull the config_name out of the database since you already know it. So, "SELECT config_value FROM config WHERE config_name='max_file_size'" will get the data you want, if I understand what it is you're trying to do. Quote Link to comment Share on other sites More sharing options...
AncientSage Posted August 1, 2006 Author Share Posted August 1, 2006 Ah, thanks, that will get what I want from the database. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.