Jump to content


Photo

theme switching and updating mysql row


  • Please log in to reply
3 replies to this topic

#1 soddengecko

soddengecko
  • Members
  • PipPipPip
  • Advanced Member
  • 43 posts

Posted 28 October 2006 - 01:41 PM

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?

#2 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 28 October 2006 - 04:12 PM

I don't understand your question.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#3 soddengecko

soddengecko
  • Members
  • PipPipPip
  • Advanced Member
  • 43 posts

Posted 28 October 2006 - 05:29 PM

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";
}
}
}

#4 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 28 October 2006 - 10:42 PM

Update it with what?
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users