Lost Password?


Go Back   CodeCall Programming Forum > Web Development Forum > PHP Forum

PHP Forum Use this forum to discuss all aspects of PHP Development. PHP is a server-side, cross-platform, HTML embedded scripting language that lets you create dynamic web pages.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-25-2006, 12:02 AM
John's Avatar   
John John is offline
Co-Administrator
 
Join Date: Jul 2006
Age: 20
Posts: 3,433
Last Blog:
Google Web Toolkit
Rep Power: 20
John has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond repute
Send a message via AIM to John Send a message via MSN to John
Default Comparing Values

ok, well ive managed to build 2 little scripts, 1 that lists all the themes for a cms that are located in a certian directory, and another script that lists all the themes for a cms that have been added to a the database. however, what i want to do, is have a list that shows all the themes in the directory that have not been added to the database yet.


Lists all the themes in the themes folder:
PHP Code:
$dir "../themes/";
if (
is_dir($dir)) {
   if (
$dh opendir($dir)) {
       while ((
$file readdir($dh)) !== false) {
            if(
file_exists("../themes/$file/theme.php")){
           
$themelist .= "$file ";
            }
       }
       
closedir($dh);
   }
}
$themelist explode(" "$themelist);
sort($themelist);

for (
$i=0$i sizeof($themelist); $i++) {
if(
$themelist[$i]!=""){

echo 
$themelist[$i] . "<br>";

}

Lists all the themes that have been added to the database:
PHP Code:
$q "SELECT * FROM nuke_theme_preview";
$result mysql_query($q) or die ('Something is wrong with query: ' $q '<br>'mysql_error());
while (
$row mysql_fetch_assoc($result))
{
echo 
$row['t_title'] . "<br>";

What i want done is something that will list all the themes in the directory that are not in the database. I believe I have to use the IN ( ) MySQL construct, but i have no idea how to format the syntax. could someone give me a hand

Thank You.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 07-25-2006, 10:41 AM
dirkfirst dirkfirst is offline
Programming Professional
 
Join Date: May 2006
Posts: 338
Rep Power: 12
dirkfirst is on a distinguished road
Default

You can use array to do this

PHP Code:

// Create array here
$themelist = array("");

$dir "../themes/"
if (
is_dir($dir)) { 
   if (
$dh opendir($dir)) { 
       while ((
$file readdir($dh)) !== false) { 
            if(
file_exists("../themes/$file/theme.php")){ 

                 
array_push($themelist$file); // Add value to array

           

       } 
       
closedir($dh); 
   } 


$q "SELECT * FROM nuke_theme_preview"
$result mysql_query($q) or die ('Something is wrong with query: ' $q '<br>'mysql_error()); 
while (
$row mysql_fetch_assoc($result)) 

     
array_push($themelist$row['t_title']); // Add value to array



[
size="3"][b]// Make the array only have unique values
$unqThemeList array_unique($themelist);

// Cycle through the $unqThemeList array and print
...... 
__________________
DirkFirst

Last edited by dirkfirst; 07-25-2006 at 10:43 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 07-25-2006, 01:22 PM
John's Avatar   
John John is offline
Co-Administrator
 
Join Date: Jul 2006
Age: 20
Posts: 3,433
Last Blog:
Google Web Toolkit
Rep Power: 20
John has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond repute
Send a message via AIM to John Send a message via MSN to John
Default

was this suppose to be in the code?

[size="3"][b]

Edit: i removed that line and it kind of works, however it lists every values, both in the directory and in the database.
Array ( [0] => [1] => 3D-Fantasy [2] => Anagram [3] => DeepBlue [4] => ExtraLite [5] => Kaput [6] => Karate [7] => Milo [8] => NukeNews [9] => Odyssey [10] => Sand_Journey [11] => Slash [12] => SlashOcean [13] => Sunset [14] => Traditional )

In the database i have these themes 3D-Fantasy, Anagram, DeepBlue, ExtraLite, and Kaput.
In the directory i have these themes 3D-Fantasy, Anagram, DeepBlue, ExtraLite, Kaput, Karat, Milo, NukeNews, Odyssey, Sand_Journey, Slash, SlashOcean, Sunset, and Traditional. Therefor i want the array to output

Array ( [0] => [1] => Karat [2] => Milo [3] => NukeNews [4] => Odyssey [5] => Sand_Journey [6], Slash[7], SlashOcean[8], Sunset[9], Traditional )

Its probabley just a minor adjustment, ill see what i can do, but in the mean time ill post it for everyone elses branes to work on too

Last edited by John; 07-25-2006 at 02:07 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 07-25-2006, 07:52 PM
John's Avatar   
John John is offline
Co-Administrator
 
Join Date: Jul 2006
Age: 20
Posts: 3,433
Last Blog:
Google Web Toolkit
Rep Power: 20
John has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond repute
Send a message via AIM to John Send a message via MSN to John
Default

well after a few hours of deep thought i got it, thank you for pushing me in the right direction

Finished Code:
PHP Code:
include("config.php");
// Create array here

echo "<select name='t_title'>";
$themelist = array();
$dir "../demo/themes/";
if (
is_dir($dir)) {
   if (
$dh opendir($dir)) {
       while ((
$file readdir($dh)) !== false) {
            if(
file_exists("../demo/themes/$file/theme.php")){

                 
array_push($themelist$file); // Add value to array

           
}
       }
       
closedir($dh);
   }
}
$dbThemeList = array();
$q "SELECT * FROM nuke_theme_preview";
$result mysql_query($q) or die ('Something is wrong with query: ' $q '<br>'mysql_error());
while (
$row mysql_fetch_assoc($result))
{
     
array_push($dbThemeList$row['t_title']); // Add value to array
}
$newThemes array_filter($themelistcreate_function('$elt''return !in_array($elt,' var_export($dbThemeListtrue) . ');'));


for (
$i=0$i sizeof($themelist); $i++) {
if(
$newThemes[$i]!=""){

echo 
"<option value='" $newThemes[$i] . "' name='t_title'>" $newThemes[$i] . "</option>";
}
}
echo 
"</select>"
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 07-25-2006, 07:57 PM
Lop's Avatar   
Lop Lop is offline
Speaks fluent binary
 
Join Date: May 2006
Posts: 1,149
Rep Power: 18
Lop will become famous soon enoughLop will become famous soon enough
Default

Nice work. I think you learn best when you figure out things this way.
__________________
Lop
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
List of Values in Column Chan PHP Forum 6 08-16-2007 07:37 AM
Help! Can't get values into database thesquirrel16 Database & Database Programming 5 04-21-2007 06:13 PM
attribute values question skilletsteve HTML Programming 1 09-30-2006 09:37 AM
Seperate values in a string Chan C# Programming 4 07-25-2006 10:17 AM
Sudoku can be solved using SQL..Take a look! roger Database & Database Programming 5 07-04-2006 03:20 PM


All times are GMT -5. The time now is 06:18 AM.

Contest Stats

WingedPanther ........ 2753.6
Xav ........ 2704
Brandon W ........ 1702.32
John ........ 1207.73
marwex89 ........ 1175.24
morefood2001 ........ 966.05
dcs ........ 655.75
Steve.L ........ 475.59
orjan ........ 418.58
Aereshaa ........ 383.54

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 97%

Ads