Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here's something to get you started. No error checking or other niceties included. I assume your db name is $db_name and the table you describe above is called 'site_params'.</p> <p>To get a single parameter from your table...</p> <pre><code>// select your db mysql_select_db($db_name); // get the uri setting $query = "SELECT value FROM site_params WHERE name='uri'"; $result = mysql_query( $query ); </code></pre> <p>If there aren't too many settings, you could just get all of them at once...</p> <pre><code>// get all the settings $query = "SELECT * from site_params"; $result = mysql_query( $query ); </code></pre> <p>Or get some of them...</p> <pre><code>// get uri and sitename $query = "SELECT * from site_params where name in ('uri', 'sitename') "; $result = mysql_query( $query ); </code></pre> <p>You can receive the result as an array called $site_info by adding...</p> <pre><code>$site_info = mysql_fetch_array($result, MYSQL_ASSOC); </code></pre> <p>Clarification: this puts a single row in $site-info. Call it repeatedly to get multiple rows of the result.</p> <p>To change one of the parameters...</p> <pre><code>// set new sitename $newsitename = 'http://mynewsite.com'; $query = "UPDATE site_params SET value='" . $newsitename . "' where name='sitename'"; $result = mysql_query( $query ); </code></pre> <p>Is that what you're looking for? Go to <a href="http://php.net" rel="nofollow noreferrer">http://php.net</a> for all the info you need. For example:</p> <p><a href="http://php.net/manual/en/function.mysql-query.php" rel="nofollow noreferrer">http://php.net/manual/en/function.mysql-query.php</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. COGreat! Thanks! I guess I was on the right path. I had a code similar to that. However i don't know how to get the value for 1 of the options. If i do this <?php while($row = mysql_fetch_array($result)) { $thumbnails_folder = $row["thumbnails_folder"]; } ?> I get nothing because the row doesn't exist. Sorry, i probably didn't explain this well. What i want to avoid is having a query for each parameter. I've been using while {} around the site, for example, to list users. I feel I need to use another function here, but i can't figure out which one. Thanks again!
      singulars
    2. COI'm not sure I understand what you're getting at (if the row doesn't exist then your query didn't pull it in), but it sounds like you might think that your while loop is doing multiple queries. But it isn't. The only query is happening when you call mysql_query. You either do a query that gets a single parameter (and multiple queries for multiple parameters) OR you do a single query for multiple parameters and then retrieve them from the result a row at a time.
      singulars
    3. COSorry, looks like I couldn't explain it well. I have, as in the example above, an entry for every site option (instead of a single entry table with lots of rows, where each one could be an option). What i want to do, is take the value of the 3rd row for EACH of the entries and store each one as a var (or an array). So, if I do and echo of the site parameter 'base_folder' (which is the entry with ID #3), it gives me the value '/folder1/folder2/'. I need that for EVERY entry in the db, and i think it can be done without a query for each one. Can it? Thanks for answering :D
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload