Jump to content

Archived

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

AncientSage

Little help with MySQL...

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
[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.

Share this post


Link to post
Share on other sites

×

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.