SitePoint Sponsor |
|
User Tag List
Results 1 to 10 of 10
Thread: Parsing variables within DB?
-
Jul 6, 2001, 13:23 #1
- Join Date
- Apr 2001
- Posts
- 63
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Parsing variables within DB?
lets say I have two tables in my DB, settings, and main.
in the settings table, it has some settings, duh, like bgcolor1, bgcolor2, etc.
now, in main, I put certain things that I want output onto my site, like the main nav table that goes on the left. in that table, I want to use some of the settings, like bgcolor1.
how do I get the output file to parse the contents of the main DB so that it uses the value of bgcolor1, instead of printing "bgcolor1"?
-
Jul 6, 2001, 13:26 #2
- Join Date
- Aug 1999
- Location
- Pittsburgh, PA, USA
- Posts
- 3,910
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I think you'll want to have all variables set (for example, a query to make sure all variables, IE "bgcolor", or whatever you might be using, are available to the script). After that, you should be able to use PHP's eval() function to parse the variables inside the templates. Check it out.
http://www.php.net/eval
Good luck.
-
Jul 6, 2001, 13:37 #3
- Join Date
- Apr 2001
- Posts
- 63
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
thanks for the quick reply, checking it out now
-
Jul 6, 2001, 13:38 #4
- Join Date
- Apr 2001
- Posts
- 63
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
thanks dude, works like a charm
-
Jul 6, 2001, 13:50 #5
- Join Date
- Apr 2001
- Posts
- 63
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
ok, maybe not like a charm, exactly
what do you mean byI think you'll want to have all variables set (for example, a query to make sure all variables, IE "bgcolor", or whatever you might be using, are available to the script).
-
Jul 6, 2001, 13:52 #6
- Join Date
- Apr 2001
- Posts
- 63
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
ok, I have this:
PHP Code:$settings = mysql_query("SELECT * FROM tq_settings") or die ("Error:".mysql_error());
$settings_row = mysql_fetch_array($settings);
-
Jul 6, 2001, 14:46 #7
- Join Date
- Aug 1999
- Location
- Pittsburgh, PA, USA
- Posts
- 3,910
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Code:$settings = mysql_query("SELECT * FROM tq_settings") or die ("Error:".mysql_error()); $settings_row = mysql_fetch_array($settings);
-
Jul 6, 2001, 18:10 #8
- Join Date
- Apr 2001
- Posts
- 63
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
oh, I see, I'll look into it tonight, thanks
I was just making $settings_row global and using it like that, $settings_row["bgcolor1"], but I was gonna do it another way anyway, but this looks better
-
Jul 9, 2001, 19:03 #9
- Join Date
- Apr 2001
- Posts
- 63
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
ok, so far it works fine, but now I'm trying to create an edit page. what I want is to put the contents of the "contents" field into a textarea so it can be edited. here is the code I have
PHP Code:$contents = stripslashes($blocks_row["contents"]);
PHP Code:<textarea cols="80" rows="20" name="contents" value="<?php echo $contents; ?>"></textarea>
PHP Code:<tr bgcolor=\"$bgcolor3\"><td nowrap>test</td></tr>
PHP Code:<TEXTAREA cols=80 name=contents rows=20 $bgcolor3? value="<tr bgcolor="><td nowrap>test</td></tr>"></TEXTAREA>
-
Jul 9, 2001, 19:18 #10
- Join Date
- Apr 2001
- Posts
- 63
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
nevermind, stupid mistake
Bookmarks