Jump to content

Recommended Posts

the website i'm working on is: [a href=\"http://poker.mwrarmyalaska.com/Points/overall2.php\" target=\"_blank\"]http://poker.mwrarmyalaska.com/Points/overall2.php[/a] (still a work in progress)

I want the top links on the table to send the corresponding names to the page so that it will ORDER BY

here is some of the code. I'm not sure if I have to use a form (im guessing so?) this is my first page i'm trying to create in PHP

I know I'm probably doing something stupidly wrong, but I've been playing with it all morning and can't get it to work. Thanks in advance for the help!

George

[code]
<?php


    $sortby = $_SESSION['SortByValue'];
    
    switch($sortby){
        case 'Name':
        $sortby = 'P.Last';
                ... snip ...
        default:
        $sortby = 't.OverAll';
                 }


$overall_query = "SELECT P.First, P.Last, P.PlayerID, t.Game1,t.Game2,t.Game3,t.Game4,t.Game5,t.Game6,t.Game7,t.Game8, t.OverAll FROM Player AS P, Tournament1Points AS t WHERE P.PlayerID = t.PlayerID AND t.OverAll > 0 ORDER BY $sortby DESC";

$overallresult = mysql_query($overall_query);

echo "<br /><table border=1 style='margin-right: auto; margin-left:auto'>" .
        "<tr>" .
        "<td><a href=\"overall2.php?SortByValue='Name'\">Name</a></td>" .
        "<td><a href=\"overall2.php?SortByValue='PlayerID'\">PlayerID</a></td>" .
        "<td><a href=\"overall2.php?SortByValue='Game1'\">Game 1</a></td>" .
        "<td><a href=\"overall2.php?SortByValue='Game2'\">Game 2</a></td>" .
        "<td><a href=\"overall2.php?SortByValue='Game3'\">Game 3</a></td>" .
        "<td><a href=\"overall2.php?SortByValue='Game4'\">Game 4</a></td>" .
        "<td><a href=\"overall2.php?SortByValue='Game5'\">Game 5</a></td>" .
        "<td><a href=\"overall2.php?SortByValue='Game6'\">Game 6</a></td>" .
        "<td><a href=\"overall2.php?SortByValue='Game7'\">Game 7</a></td>" .
        "<td><a href=\"overall2.php?SortByValue='Game8'\">Game 8</a></td>" .
        "<td><a href=\"overall2.php?SortByValue='OverAll'\">Over All</a></td>" .
        "</tr>";

while ($row = mysql_fetch_row($overallresult))
{
    $Fname = $row[0];
    $Lname = $row[1];
    $PlayerID = $row[2];
    $Game1 = $row[3];
    $Game2 = $row[4];
    $Game3 = $row[5];
    $Game4 = $row[6];
    $Game5 = $row[7];
    $Game6 = $row[8];
    $Game7 = $row[9];
    $Game8 = $row[10];
    $OverAll = $row[11];
echo "<tr>" .
        "<td> $Lname, $Fname </td>" .
        "<td> $PlayerID </td>" .
        "<td> $Game1 </td>" .
        "<td> $Game2 </td>" .
        "<td> $Game3 </td>" .
        "<td> $Game4 </td>" .
        "<td> $Game5 </td>" .
        "<td> $Game6 </td>" .
        "<td> $Game7 </td>" .
        "<td> $Game8 </td>" .
        "<td> $OverAll </td>" .
        "<tr>";

}
echo "</table>";
    mysql_close($conn);
?>

[/code]
Link to comment
https://forums.phpfreaks.com/topic/10455-_session-_get-etc-confusion/
Share on other sites

if you have 'sort by' links that you want the list to be sorted by, you would use the $_GET like so:

[code]$value = 'blah'; //whatever you are sorting by
echo "<a href='blah.php?SortByValue=".$value."'>Sort by ".$value."</a>";
[/code]

and then in blah.php:
[code]
$sortby = $_GET['SortByValue'];
[/code]

also you can get rid of a lot of those lines of code by making Game an array instead of doing Game1, Game2, etc.. and just looping the links and echoes...
Thanks Crayon Violent.. I really appreciate the fast response and I got it working!


[!--quoteo(post=377109:date=May 25 2006, 11:36 AM:name=Crayon Violent)--][div class=\'quotetop\']QUOTE(Crayon Violent @ May 25 2006, 11:36 AM) [snapback]377109[/snapback][/div][div class=\'quotemain\'][!--quotec--]
if you have 'sort by' links that you want the list to be sorted by, you would use the $_GET like so:

[code]$value = 'blah'; //whatever you are sorting by
echo "<a href='blah.php?SortByValue=".$value."'>Sort by ".$value."</a>";
[/code]

and then in blah.php:
[code]
$sortby = $_GET['SortByValue'];
[/code]

also you can get rid of a lot of those lines of code by making Game an array instead of doing Game1, Game2, etc.. and just looping the links and echoes...
[/quote]
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.