How to create wordpress-like option table and get values for each row? (PHP-MySQL)
Posted
by Nacho
on Stack Overflow
See other posts from Stack Overflow
or by Nacho
Published on 2010-05-06T19:49:21Z
Indexed on
2010/05/06
19:58 UTC
Read the original article
Hit count: 122
mysql-query
|data-structures
Hi guys. I'm looking to create an options table in my db that makes every record a system option, so i can work with a little number of fields.
my db has the following structure:
3 columns named id, name, and value
following data is inserted as an example
--
id - name - value
1 - uri - www.example.com
2 - sitename - Working it out
3 - base_folder - /folder1/folder2/
4 - slogan - Just a slogan for the site
--
that way i can include a large number of customizable system options very easily
the problem is that i don't know how to retrieve them
how do i get the value of uri and store it as a var?
and better yet, how do i get, for exmaple, values of id 1 and 4 only without making a query each time? (i assume multiple queries are useless and a pretty ugly method)
i know the question is pretty basic but i'm lost here.
i'd really appreciate your answer!
Thanks in advance
© Stack Overflow or respective owner