Jump to content

Pythondesigns

Members
  • Posts

    17
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Pythondesigns's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I am working on a CODE script - the idea behind it is that a user is able to choose which modules he wants to display on his page. When I say a module all I mean is a block of code which is in a seperate CODE file (for example: news.php, weather.php, search.php etc). I have two tables. The first table is called 'modules' and simply contains a list of all the modules. It has ID, status, name, description and filename columns. The filename column is the path to the modules CODE file. The second table is called 'profiles_modules' and has the columns ID, profileID, moduleID, location and order. The modules can be in one of three different locations (held in the 'location' column of the profiles_modules table) on the page which are numbered 1, 2 and 3. Basically what I'm doing is first executing a query to get all the modules belonging to that profileID. Then I'm building up the array $modules to contain all of the data from the query. I then want to be able to loop through the $modules array in three different places on the page and display the appropriate modules. For example in location 1 I want to loop through and display modules with location = 1. In location 2 on the page I want modules with location = 2, etc. I cant get it to work though... Its working for location 1 but not for location 2 or 3. // Profile ID $profile[iD] = 1; // The query $query_modules = $DB->Query("SELECT profiles_modules.location, modules.filename FROM profiles_modules, modules WHERE modules.ID = profiles_modules.moduleID && modules.status = 1 && profiles_modules.profileID = '" . $profile[iD] . "' ORDER BY modules.ID ASC"); // Build $modules array while($array = $DB->FetchArray($query_modules)) { $modules[$array[location]][] = $array[filename]; } echo "<h1>Location 1</h1>"; // Display location 1 modules if(is_array($modules[1])) { foreach($modules[1] as $modulefilename) { // loadmodule() simply includes the file loadmodule($modulefilename, 1); } } else echo "No modules for 1"; echo "<h1>Location 2</h1>"; // Display location 2 modules if(is_array($modules[1])) { foreach($modules[2] as $modulefilename) { // loadmodule() simply includes the file loadmodule($modulefilename, 2); } } else echo "No modules for 2"; echo "<h1>Location 3</h1>"; // Display location 3 modules if(is_array($modules[3])) { foreach($modules[3] as $modulefilename) { // loadmodule() simply includes the file loadmodule($modulefilename, 3); } } else echo "No modules for 3"; I think I might either be building the $modules array wrong or perhaps even the loops are wrong. Any suggestions? Thanks
  2. Geez, I thought this was a PHP [b]Help[/b] forum. Guess I was wrong  :o
  3. Ok, Im coding a league system... Each league can have multiple divisions. Here are three tables... leagues(id, name); divisions(id, leagueID); scores(id, leagueID, userID, score); For this example lets assume that there is one league, three divisions within that league and 20 rows in the scores table. I want to loop through and display a table for each division. I want to order the scores table by the score field ASC. Then display them in the divisions (10 per divisions). So in division one it has the top 10 scores. In division two the 11-20 top scores In division three 21-30 top scores. Can you help me. Thanks
  4. Its ok Ive figured it out. Thanks
  5. Hello, I am trying to create a search feature in PHP where my users can type in keywords and it will return the results. But it will be using two tables and use a sort of tag system. Here are my tables tags([u]id[/u], tag); files([u]id[/u], title, desc, url, tagIDs*); Ok, if for example someone typed into the search form the keywords "apple ipod". I want it to search the tags table for first "apple" and then "ipod". If those tags arent already present in the tags table insert them. If they are present then get their ID's. Then search through the files table for all rows which has got the tag's ID in the tagIDs field. Then display the result and if possible order them by relevance. So basically this is a search script which keeps track and records the different keywords used and assigns each record in the files table a number of tags. The tagIDs field in the files table can contain more than one tag ID. Could any one show me how I could do this. Thanks
  6. Hey, I have an array like this which is called $CFG. [quote]Array (     [online] => 1     [sitename] => MySite     [indexurl] => http://mysite.com     [areas] => Array         (             [home] => Array                 (                     [id] => 1                     [text] => Home                     [order] => 0                     [navshow] => 1                 )             [profile] => Array                 (                     [id] => 2                     [text] => Profile                     [order] => 1                     [navshow] => 1                 )             [jobs] => Array                 (                     [id] => 3                     [text] => Jobs                     [order] => 3                     [navshow] => 1                 )             [business] => Array                 (                     [id] => 4                     [text] => Business                     [order] => 4                     [navshow] => 1                 )             [finance] => Array                 (                     [id] => 5                     [text] => Finance                     [order] => 5                     [navshow] => 1                 )         ) )[/quote] As you can see the $CFG[areas] is another array. And then within each again is an array. Basically each of the values inside the $CFG[areas] are links for a menu Im making and what I want to do is to cycle through them all (theres 5 of them) and display its relevant id. So at the end I want this... [quote]Home (which links to homes id) Profile (which links to profiles id) Jobs (which links to jobs id) And so on...[/quote] How can I do this? Thanks
  7. Ok, The way I have done it was... I found out the time difference in seconds from a set date & time (which wont change) and the current time. Then I multiplied this by 7 and added it onto the current time. So now I have the variable $gametime which equals the in game time which is 7 times faster than real time. The next thing I would like to do is construct some sort of basic calendar based off this speeded up date/time. If someone could show me how I could just view the current month in a day by day view and then I will modify and expand to allow more months to be viewed. Thanks
  8. Hello, I want to work out what the time would be if I was to add a variety of time amounts to it. Basically I want to take the current time using the time() function and add to it x years, x months, x days, x hours and x minutes. Each of thesewill be held in a variable. For example $numdays will hold the number of days to add to the current time. Thanks
  9. This is quite an odd question which I havent found it being asked anywhere else. Basically Im working on an online web based RPG game. Now I want there to be an in-game time. This in-game time runs a lot faster than real time. I want it so that 1 day real time means 7 days in game time. So what I need to know is how I can display the in-game time on my site. Eventually I will use AJAX to display a more dynamic/live version of it but for now is there a way which I can just perhaps store the game time in a text file. Let me know. Thanks
  10. I have a table in a MySql database like this: id url I know that there are some rows which have got the same url. How can I check for these in PHP and display them....
×
×
  • 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.