Jump to content

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?
Link to comment
https://forums.phpfreaks.com/topic/16181-little-help-with-mysql/
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.
Link to comment
https://forums.phpfreaks.com/topic/16181-little-help-with-mysql/#findComment-67285
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.
Link to comment
https://forums.phpfreaks.com/topic/16181-little-help-with-mysql/#findComment-67408
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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