Jump to content

Archived

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

soddengecko

theme switching and updating mysql row

Recommended Posts

hi all

i am using a little script that pull the folder names from a given directory. these names are then outputted as URL's for the end user to choose which theme they wish to use

here is the code

function gl_themechooser()
{
$handle=opendir('./themes');
while ($file = readdir($handle)) {
if ($file != "." && $file != ".." && $file="<a href=\"$PHP_SELF\">$file</a><br />\n")
{
echo "$file";
}
}
closedir($handle);
}


the theme is displayed like so

$sql = 'SELECT * FROM theme;';
$result = mysql_query($sql) or die('');
while ($row = mysql_fetch_assoc($result)){

$filename = "themes/".$row['theme']."";

if (file_exists($filename)) {
    include "themes/".$row['theme']."/sidebar.php";
} else {
    include "themes/default/sidebar.php";
}
}
}


depending on the row in the mysql db depends on what theme is used.

the trouble i am having is updatying that row depending on what URL is clicked. for some reason the variable keeps emptying when i tried using a form method and I cannot figure it out. anyone have any ideas?

Share this post


Link to post
Share on other sites
I don't understand your question.

Share this post


Link to post
Share on other sites
sorry, maybe not enough info

basically i have a script that gets the folder names from my templates directory. these folder names are outputted as URL's in the theme choice section. How do i use those links to update the mysql database corresponding to the theme? i have managed now to do it with a form, but would prefer to use links so i can use a screen shot of the template to show which is being chosen.

secondly, when the database row is empty, it does not default to the default theme, it just shows a blank page. this is the script i am using to show the theme

function gl_header()
{

$sql = 'SELECT * FROM theme;';
$result = mysql_query($sql) or die('');
while ($row = mysql_fetch_assoc($result)){

$filename = "themes/".$row['theme']."";

if (file_exists($filename)) {
    include "themes/".$row['theme']."/header.php";
} else {
    include "themes/default/header.php";
}
}
}

Share this post


Link to post
Share on other sites
Update it with what?

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.