Jump to content

fleabel

Members
  • Posts

    6
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

fleabel's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I have a little form with two drop down menus. These two selections are used to pull required information from a flat file database. I have then integrated a piece of script that sorts the columns. This all works beautifully if I bipass the form and just hard code the two variables, however, if I use the form to set the varibles it works great to get the initial information but as soon as i try to sort it the info disappears. I have enough sense to know that this is because it is 'loosing' the varibles from the form but I have absolutely no idea how to fix it. I think the problem has something to do with the page being reloaded when you click on the header of the comlumn you want to sort by. But I could be completely off track. If someone can save me that would be much appriated [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /] [code] <tr class="contboxtxt" bgcolor="#CCCCCC">     <th><a class="contboxtxt" href="?"><strong>Date</strong></th>     <th><a class="contboxtxt" href="?month"><strong>Month</strong></th>     <th><a class="contboxtxt" href="?year"><strong>Year</strong></th>     <th><a class="contboxtxt" href="?sport"><strong>Sport</strong></th>     <th><a class="contboxtxt" href="?event"><strong>Event</strong></th>     <th><a class="contboxtxt" href="?venue"><strong>Venue</strong></th>     <th><a class="contboxtxt" href="?city"><strong>City</strong></th>     <th><a class="contboxtxt" href="?state"><strong>State</strong></th> </tr>';     $searchOption = $_POST['searchMenu'];     $selectOption = $_POST['selectedMenu'];     $fp = 'events_database.txt';     $tmp_array = file($fp);     $row = 0;     switch($searchOption){         case 'state':             foreach ($tmp_array as $value) {                 $curr = explode("|", $value);                 // check for whatever you want here                 if (trim($curr[7]) == $selectOption){                     if ($sortby == 'date') $sortkey = strtolower($curr[0]);                     if ($sortby == 'month') $sortkey = strtolower($curr[1]);                     if ($sortby == 'year') $sortkey = $curr[2];                     if ($sortby == 'sport') $sortkey = strtolower($curr[3]);                     if ($sortby == 'event') $sortkey = strtolower($curr[4]);                     if ($sortby == 'venue') $sortkey = strtolower($curr[5]);                     if ($sortby == 'city') $sortkey = strtolower($curr[6]);                     if ($sortby == 'state') $sortkey = strtolower($curr[7]);                     $col[$row] = array($sortkey, $curr[0], $curr[1], $curr[2], $curr[3], $curr[4], $curr[5], $curr[6], $curr[7]);                     $row++;                 };             };             break;         case 'city':             bassically same code as above         case 'sport':             bassically same code as above         case 'month':             bassically same code as above         default:             break;     };                  sort($col);             reset($col);                $arrays = count($col) - 1;                $loop = -1;             while ($loop < $arrays) {                 $loop++;                 echo '                     <tr>                         <td class="contboxtxt">'.$col[$loop][1].'</td>                         <td class="contboxtxt">'.$col[$loop][2].'</td>                         <td class="contboxtxt">'.$col[$loop][3].'</td>                         <td class="contboxtxt">'.$col[$loop][4].'</td>                         <td class="contboxtxt">'.$col[$loop][5].'</td>                         <td class="contboxtxt">'.$col[$loop][6].'</td>                         <td class="contboxtxt">'.$col[$loop][7].'</td>                         <td class="contboxtxt">'.$col[$loop][8].'</td>                       </tr>';             };[/code]
  2. Hallelujah it works! Sorry i'm a bit thick sometimes [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /]
  3. This is driving me nuts. Everything works except the if statement can somebody please have a look and tell me what i'm doing wrong. If I comment out the if statement and just have it print every line from the file it is fine but as soon as i try to get it to check for something i can't get it work. [code]<html> <body> <table border="1" cellpadding="3"> <tr bgcolor="#CCCCCC">     <td>Date</td>     <td>Month</td>     <td>Year</td>     <td>Sport</td>     <td>Event</td>     <td>Venue</td>     <td>City</td>     <td>State</td> </tr> <?php $fp = 'events_database.txt'; $tmp_array = file($fp); $state = 'VIC'; foreach ($tmp_array as $value) {     $curr = explode("|", $value);     // check for whatever you want here     if($curr[7] == $state){         // print it out however you like         echo '             <tr>                 <td>'.$curr[0].'</td>                 <td>'.$curr[1].'</td>                 <td>'.$curr[2].'</td>                 <td>'.$curr[3].'</td>                 <td>'.$curr[4].'</td>                 <td>'.$curr[5].'</td>                 <td>'.$curr[6].'</td>                 <td>'.$curr[7].'</td>             </tr>';     } } ?> </table> </body> </html>[/code]
  4. Sorry i'm a bit thick. Can you please elaborate on how I would use that. Thanks [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /]
  5. Here's a sample: [code]17th|June|2006|NRL|Sharks vs. Sea Eagles|Toyota Park|Sydney|NSW 18th|June|2006|NRL|Bulldogs vs. Cowboys|Carrara Stadium|Gold Coast|QLD 18th|June|2006|NRL|Storm vs. Raiders|Olympic Park|Melbourne|VIC 16th|June|2006|AFL|St. Kilda vs. Adelaide|Telstra Dome|Melbourne|VIC 17th|June|2006|Rugby Union|Cook Cup - Qantas Wallabies v England|Telstra Dome|Melbourne|VIC 17th|June|2006|AFL|Fremantle vs. Geelong|Subiaco|Perth|WA 17th|June|2006|AFL|Brisbane Lions vs. Western Bulldogs|Gabba|Brisbane|QLD 17th|June|2006|AFL|Port Adelaide vs. West Coast|AMMI Stadium|Adelaide|SA 18th|June|2006|AFL|Essendon vs. Melbourne|Telstra Dome|Melbourne|VIC 23rd|June|2006|NRL|Storm vs. Bulldogs|Olympic Park|Melbourne|VIC 24th|June|2006|NRL|Knights vs. Sharks|Energy Australia Stadium|Newcastle|NSW[/code] That is: Date|Month|Year|Sport|Event|Venue|City|State At a later date I would also like to have events added the file via a form, but that's for another day [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /]
  6. I have a flat file database containing various sporting events. I want to be able to have a simple search with a drop down menu containing, for example, a list of states. So that the person would select the state they want events from and then it would just display anything from that state not the whole file. Does that make sense? I could just use a different file for each state but then they might want to search by type of sport or month of the year so i don't want to have everything stored in two or three different files, one is much less effort. Please note: a mySQL or some such database is not an option in my particular situation. I haven't been able to find anything on the vastness of the web that explains how to do this or if it is even possible. Thank you in advance your help would be much appreciated.
×
×
  • 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.