Hello

Basically I have a huge list of info from a table in a database, the table has a field "week" in which I sort them by.

I want a drop down menu which displays the weeks, and when you pick a certain week, it populates the html table below the drop down with the info from the database for that week. If it won't work without refreshing the page that is okay.

Thanks

Do you have any code for us to troubleshoot?

This is the function that calls the info and puts ALL of it on the page. I want to make a dropdown using the past weeks from this info, then I want to only view the info of a certain week (and user but its already doing that.

To make the drop downs I was just gonna make a loop that runs while $count <= $week to get up to the current week.

function ShowUserPredictions($userid, $week) {
    global $dbasePredictionData, $dbaseUserData, $dbaseMatchData, $SID, $lid,$User;
    global $P, $W, $POS, $D, $D, $L, $Away, $Home, $F, $A, $GD, $User_Name,$PTS,$Date,$Result,$Predictions, $ViewUserPredictions;
    global $dbase, $Txt_v, $Result, $globaleams, $Txt_Sum, $Txt_Week, $Txt_Month;

    $userquery = "SELECT username FROM $dbaseUserData WHERE userid='$userid'";
    $unameres = $dbase->query($userquery);
    $usernameln = mysql_fetch_row($unameres);
    $username = stripslashes($usernameln[0]);
    
    $userquery = "SELECT week, bonuspoints, hometeam,awayteam,$dbasePredictionData.homescore,$dbasePredictionData.awayscore,$dbaseMatchData.matchid,matchdate, $dbaseMatchData.homescore as homeresult, $dbaseMatchData.awayscore as awayresult FROM $dbasePredictionData INNER JOIN $dbaseUserData on $dbasePredictionData.userid=$dbaseUserData.userid INNER JOIN $dbaseMatchData ON $dbasePredictionData.matchid=$dbaseMatchData.matchid AND $dbaseMatchData.lid=$dbasePredictionData.lid WHERE $dbasePredictionData.userid=\"$userid\" and $dbaseMatchData.lid='$lid' order by $dbaseMatchData.matchdate desc";
    $userresult = $dbase->query($userquery);

    // Display the username as a header.
?>
    <table width='100%' border='0'>
    <tr>
    <td class="TBLHEAD" colspan="11" align="center">
      <font class="TBLHEAD"><?php echo "$Predictions";?></font>
    </td>
    </tr>
    <tr>
    <td align="center" class="TBLHEAD">
      <font class="TBLHEAD"><?php echo $Date; ?></font>
    </td>
    <td align="center" class="TBLHEAD">
      <font class="TBLHEAD"><?php echo $Txt_Week; ?></font>
    </td>
    <td align="center" class="TBLHEAD">
      <font class="TBLHEAD">&nbsp;</font>
    </td>
    <td align="center" class="TBLHEAD">
      <font class="TBLHEAD"><?php echo $Away; ?></font>
    </td>
    <td align="center" class="TBLHEAD">
      <font class="TBLHEAD">&nbsp;</font>
    </td>
    <td align="center" class="TBLHEAD">
      <font class="TBLHEAD"><?php echo $Home; ?></font>
    </td>
    <td align="center" class="TBLHEAD">
      <font class="TBLHEAD">&nbsp;</font>
    </td>
    <td align="center" class="TBLHEAD">
      <font class="TBLHEAD"><?php echo $PTS; ?></font>
    </td>
    <td align="center" class="TBLHEAD">
      <font class="TBLHEAD"><?php echo $Result; ?></font>
    </td>
    </tr>
<?php
    $sum = 0;
    $mpoints = 0;
    $lastmonth = "";
    // First loop. Used to get all the users.
    while ($userline = mysql_fetch_array($userresult, MYSQL_ASSOC)) {
      // For each user display all their predictions.
      // against the actual result.
      $hometeam = stripslashes($userline["hometeam"]);
      $awayteam = stripslashes($userline["awayteam"]);
      $homescore = $userline["homescore"];
      $awayscore = $userline["awayscore"];
      $homeresult = $userline["homeresult"];
      $awayresult = $userline["awayresult"];
      $bonus = $userline["bonuspoints"];
      $week = $userline["week"];
      $points = 0;
      if ($homescore != "" and $homeresult != "") {
        $points = GameStats::CalculatePoints($homescore, $awayscore, $homeresult, $awayresult, $bonus);
      }
      $matchid = $userline["matchid"];
      $date = $userline["matchdate"];
      $datetext = GetDateFromDatetime($date);
      $time = GetTimeFromDatetime($date);
      $sum += $points;
      
      // If we have crossed a month, reset the points
      $thismonth = GetMonth($date);
      if ($thismonth != $lastmonth) {
        $mpoints = 0;
        $lastmonth = $thismonth;
      }
      $mpoints += $points;

      if ($ViewUserPredictions == "TRUE" || (CompareDatetime($date) < 0) || ($username == $User->username)) {
      
        if ($week >= GetThisWeek() - 1 ) {
?>
        <tr>
        <td class="TBLROW" align="center">
          <font class="TBLROW">
            <a href='index.php?<?php echo "cmd=matchpreds&matchid=$matchid&date=$date";?>'><?php echo $datetext;?></a> <?php echo $time;?>
          </font>
        </td>
        <td class="TBLROW" align="center">
          <font class="TBLROW"><?php echo $week; ?></font>
        </td>
<?
    if ($awayscore == "1") {
        echo "<td class=\"TBLROW\"><img src=\"./images/check.gif\"></td>";
        if ($awayresult > $homeresult) {
            echo "<td class=\"TBLROW\" align=\"center\"><font class=\"TBLROW\"><B>".$awayteam."</B></font></td>";
        } else {
            echo "<td class=\"TBLROW\" align=\"center\"><font class=\"TBLROW\">".$awayteam."</font></td>";
        }
     } else {
        echo "<td class=\"TBLROW\"></td>";
        if ($awayresult > $homeresult) {
            echo "<td class=\"TBLROW\" align=\"center\"><font class=\"TBLROW\"><B>".$awayteam."</B></font></td>";
        } else {
            echo "<td class=\"TBLROW\" align=\"center\"><font class=\"TBLROW\">".$awayteam."</font></td>";
        }
    }
?>

        <td class="TBLROW" align="center">
          <font class="TBLROW">at</font>
        </td>

<?
    if ($homescore == "1") {
        if ($awayresult < $homeresult) {
            echo "<td class=\"TBLROW\" align=\"center\"><font class=\"TBLROW\"><B>".$hometeam."</B></font></td>";
        } else {
            echo "<td class=\"TBLROW\" align=\"center\"><font class=\"TBLROW\">".$hometeam."</font></td>";
        }
        echo "<td class=\"TBLROW\"><img src=\"./images/check.gif\"></td>";
     } else {
        if ($awayresult < $homeresult) {
            echo "<td class=\"TBLROW\" align=\"center\"><font class=\"TBLROW\"><B>".$hometeam."</B></font></td>";
        } else {
            echo "<td class=\"TBLROW\" align=\"center\"><font class=\"TBLROW\">".$hometeam."</font></td>";
        }
        echo "<td class=\"TBLROW\"></td>";
    }
?>

        <td class="TBLROW" align="center">
          <font class="TBLROW"><?php echo $points; ?></font>
        </td>
        <td align="CENTER" class="TBLROW" align="center">
          <font class="TBLROW"><?php echo "$awayresult-$homeresult"; ?></font>
        </td>
        </tr>
<?php
       }}
    }
    echo "</table>";

    }

awesome post, alkaholik. sorry to hear about your condition.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.