Jump to content


This topic is now archived and is closed to further replies.


Variable Issues Using A Form

Recommended Posts

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\" /]

<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>

    $searchOption = $_POST['searchMenu'];
    $selectOption = $_POST['selectedMenu'];

    $fp = 'events_database.txt';
    $tmp_array = file($fp);
    $row = 0;

        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]);
        case 'city':
            bassically same code as above
        case 'sport':
            bassically same code as above
        case 'month':
            bassically same code as above
            $arrays = count($col) - 1;
            $loop = -1;
            while ($loop < $arrays) {
                echo '
                        <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>  

Share this post

Link to post
Share on other sites
you should use the $_GET method to pass on the information you are looking at, the _POST variables are lost otherwise

Share this post

Link to post
Share on other sites


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.