Jump to content

theme switching and updating mysql row


soddengecko

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?
Link to comment
https://forums.phpfreaks.com/topic/25396-theme-switching-and-updating-mysql-row/
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";
}
}
}

Archived

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

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