Hi,

>From the code below $wk  gets the values (w1, w2, w3, etc.) as it goes
through the 'for' loop. w1, w2, etc. are also colums in the table manager.
What I can't figure out is why the select statement fails (no error, just no
data) when I use $wk as apposed to hardcoding w1, w2, etc. Is this possible
or am I missing something?

Note: the colums w1, w2, etc contain numbers which I am trying to select.

TIA

$db = mysql_connect("xxxxxxxxxx","xxxxxxxxxx","xxxxxxxxxx");
mysql_select_db("database");

echo "<TABLE ALIGN=center WIDTH=200 BORDER=0><TR>\n";

for ($i = 1; $i < 26; $i++) {

        $wk = "w$i";

        echo "<TR Width=200><TD ALIGN=center COLSPAN=2><B>Week
".$i."</B></TD></TR>\n";
        echo "<TR Width=200><TD COLSPAN=2><HR SIZE=5></TD></TR><TR>\n";
        echo "<TR WIDTH=100><TD ALIGN=left><B>Name</B></TD><TD
ALIGN=right><B>Points</B></TD>";
        echo "<TR Width=100><TD></TD></TR>\n";

        $query = "select name, $wk from manager order by $wk desc";
        $result = mysql_query($query) or die("Query failed");

        while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {

                echo "<TR WIDTH=150><TD ALIGN=left>".$line['name']."</TD><TD
ALIGN=right>".$line['$wk']."</TD>";

        }

echo "<TR Width=200><TD COLSPAN=2><HR SIZE=5></TD></TR>\n";


}



---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to