[thelist] using URL's to update mysql db

Mattias Thorslund mattias at thorslund.us
Tue Oct 31 02:07:09 CST 2006


I don't see that anyone has replied to this yet. So, just some small
pointers/opinions:

1. It seems you will need to decide whether to use MySQL as the source
for the list of themes or not. Ultimately, the "master" list of
available themes seems to be whatever is available in the themes folder,
so if you're using a the SQL table to keep the list of themes (better
performance? alternate names?), this must be synced with the folder
contents - preferably in some automated way. From what you have written,
it seems that MySQL isn't necessary here.

2. This line is pretty confusing, since the third part is not a
comparison but an assignment:

if ($file != "." && $file != ".." && $file="<a href=\"$file\">$file</a>\n"){
   //...
}


How about this? Easier to read, don't you think?

if ($file != "." && $file != ".."){
   $file="<a href=\"$file\">$file</a>\n";
   //...
}

As for the "making the url update mysql" part, a tutorial on SQL would
tell you how. SELECT/INSERT/UPDATE/DELETE, or by using MySQL's
proprietary REPLACE command. But again, I doubt you'll need any of it.

/Mattias


Mark Mckee wrote:
> hi all
>
> I am writing a small templating instruction and so far have everything
> working neatly. I have a few queries I would like to run by you guys as
> I'm having trouble finding the answer, I have looked in the usual places
> and found nothing that helps.
>
> each template sits in its own folder i.e.. themes/template1 or
> themes/default. I am using a mysql row to define the template, which is
> set at default to begin with and is outputted like so
>
> -----------------------------------------------
> 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";
> }
> }
> }
> -----------------------------------------------
>
> this is where I'm getting slightly stuck. I have a small script that
> will read the folder names from the template directory and output the
> folder name as a url
>
> -----------------------------------------------
> function gl_themechooser()
> {
> $handle=opendir('./themes');
>
> while ($file = readdir($handle)) {
> if ($file != "." && $file != ".." && $file="<a href=\"$file\">$file</a>\n")
> {
> echo ".$file.";
> }
> }
> closedir($handle);
> }
> -----------------------------------------------
>
> I would like to know how to make this url update the mysql row when
> clicked. I tried outputting them into a drop down box but a separate box
> was created for each folder in the template directory and ii was unable
> to solve this. any pointers on that would be great.
>
> Thanks in advance
>
> Mark M...
>   




More information about the thelist mailing list