Jump to content

Archived

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

tensionx

Table to Table?

Recommended Posts

I am trying to build my DKP tracking tool. I have my beta up right now. My biggest conundrum is displaying my MySql table in an organized fashion with sort functions. my current out put is:


[code]$sql = "SELECT * FROM UFDKP";
$result = mysql_query($sql);
if ($myrow = mysql_fetch_array($result)) {
do
{

$USERID=$myrow["USERID"];
$Name=$myrow["Name"];
$Class=$myrow["Class"];
$SWR=$myrow["SWR"];
$RP=$myrow["RP"];
$Tier1=$myrow["Tier1"];
$Tier2=$myrow["Tier2"];
$Tier3=$myrow["Tier3"];
echo "<BR>USERID:  $USERID";
echo "<BR>NAME:  $Name";
echo "<BR>CLASS:  $Class";
echo "<BR>SWR:  $SWR";
echo "<BR>RP:  $RP";
echo "<BR>TIER 1:  $Tier1";
echo "<BR>TIER 2:  $Tier2";
echo "<BR>TIER 3:  $Tier3";
}
while ($myrow = mysql_fetch_array($result));
}
?>
[/code]
http://wekillmonsters.com/show.php
Its very dissapointing. lol
I tried a table Function
[code]
function GenerateTable($sqlResult, $Headers) {
                   $row = mysql_fetch_assoc($sqlResult);
                   $FieldList = Array_Keys($row);
                   echo "<table Border=2>";
                   Echo "<tr>";
                   For ($Cnt=0; $Cnt < Count($FieldList); $Cnt++) {
                            echo "<th>" . $Headers[$FieldList[$Cnt]] . "</th>";
                           }
                   echo "</tr>"; 
                   While ($row) {
                                 $RowColor = ($RowCnt % 2) ? "row1":"row2";
                                Echo "<tr>";
                                For ($Cnt=0; $Cnt < Count($FieldList); $Cnt++) {
                                         echo "<td class='$RowColor'>" . $row[$FieldList[$Cnt]] . "</td>";
                                        }
                                echo "</tr>"; 
                                $RowCnt++ ;
                                $row = mysql_fetch_assoc($sqlResult);
                                }
                    echo "</table>";                    } 
[/code]

I could not get it working. I am a beginner at this. The only thing I am confident in is my queries because thats my work.
If someone could point me in the write direction so I can figure out how to bring these 2 things together It would be much appreciated.

Thanks.

Share this post


Link to post
Share on other sites
Can you kindly tell me what look you want outputted cheers.

Share this post


Link to post
Share on other sites
[table]
[tr][td]<b>Name</b>[/td][/tr][/table]
Bob
Steve
Mark
Sara
John
[/table]

7 columns
the primary key is the userid
Sorts tied to the primary key.
Side by side like an excel spreadsheet hehe

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.