Jump to content

blakogre

New Members
  • Posts

    8
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

blakogre's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I also tried adding a line like krsort($members['Level']) and got: Warning: krsort() expects parameter 1 to be array, string given in C:\Inetpub\boc\guildviewer.php on line 137 added right before the last echo<<<output above (ditched the sort/$level stuff)
  2. The initial array: [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]$classes = [b]array();[/b] foreach ($guilddata['Members'] as $name => $info) { if (empty($classes[$info['Class']])) { $classes[$info['Class']] = array(); } $classes[$info['Class']][$name] = $info; }[/quote] So -- I think in the () I need values I can reference for the sort? Tried putting things in -- got errors....
  3. Well, I added: OUTPUT; [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]ksort($classes); foreach ($classes as $ckey => $class) { ksort($class); echo <<<OUTPUT <tr> <td colspan="4"><b>{$ckey}</b></td> </tr> OUTPUT; [b]sort($level);[/b] foreach ($level as $member) { [b]sort($level);[/b] $member['Name'] = htmlentities($member['Name']); $member['Rank'] = htmlentities($member['Rank']); $member['Note'] = htmlentities($member['Note']); echo <<<OUTPUT <tr> <td>{$member['Name']}</td> <td>{$member['Level']}</td> <td>{$member['Rank']}</td> <td>{$member['Note']}</td>[/quote] Of course, not working. I don't have 100% understanding or even close -- the "<--" comments in the first post are mine, trying to wrap my brain around it all.
  4. Thanks to all who've helped before: [a href=\"http://www.blakogre.com/epix/altdkp.php\" target=\"_blank\"]http://www.blakogre.com/epix/altdkp.php[/a] was the result. THANKS! I've snipped the following code from a page which I've partially modified, but it's still not quite what I want: [a href=\"http://www.blakogre.com/guildviewer.php\" target=\"_blank\"]http://www.blakogre.com/guildviewer.php[/a] [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]<tr> <td><b>Name</b></td> <td><b>Level</b></td> <td><b>Rank</b></td> <td><b>Note</b></td> </tr> OUTPUT; ksort($classes); <-sorting by classes? This makes my major grouping? foreach ($classes as $ckey => $class) { <-ckey -- that's defined here as teh $class variable ksort($class); <- but... this sorts by class... so I'm not sure why there are 2. maybe created array? lost. echo <<<OUTPUT <tr> <td colspan="4"><b>{$ckey}</b></td> <-- and this line is where ckey/class is inserted at each group </tr> OUTPUT; foreach ($class as $member) { $member['Name'] = htmlentities($member['Name']); $member['Rank'] = htmlentities($member['Rank']); $member['Note'] = htmlentities($member['Note']); echo <<<OUTPUT <tr> <td>{$member['Name']}</td> <td>{$member['Level']}</td> <td>{$member['Rank']}</td> <td>{$member['Note']}</td> </tr> OUTPUT; } } echo <<<OUTPUT </table> OUTPUT; ?>[/quote] Within each "Class" I want to sort by descending level as well: can I add another ksort in there? I've tried that, but I know my synatx is off, as I don't quite 100% understand what each line does. The pure HTML I get, it's the rest. I added my notes/what I think is going on. But again, I"m not a programmer, I come from an admin background. Thx -- any help appreciated. My goals are simply for it to work, however, understanding it is great too. I love to learn by tweaking and playing and trying to get results I want. So, it creates major class groupings, and then within that, ideally: Sort by descending lvl and within lvl Sort by ascending name Bob 60 Charles 60 Alan 55 Trudie 30 Jack 28 Kevin 28 (The data is stored in another PHP page -- page one "parser.php" parses a text file, which creates page 2 "data.php", which feeds into this page, "viewer.php")
  5. Tossed in your code, tweaked it, results are now: [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--] echo '<div align="center"><table bordercolorlight="#000000" bordercolordark="#C0C0C0" border="1">'; echo '<tr><td width="115"><font face="Verdana" size="1"><b>Member</b></font></td><td><font face="Verdana" size="1"><b>DKP</b></font></td>'; while ($row = mysql_fetch_assoc($result)) { echo '<b><tr><td width="115"><font face="Verdana" size="1">'.$row['member_name']. '</font></b></td>'; echo '<b><td width="50"><font face="Verdana" size="1">'.$row['member_sumdkp']. '</font></b></td></tr>'; } echo '</table>';[/quote] Added page/site header info. Needs a few more links, but done. again, th anks.
  6. [!--quoteo(post=386549:date=Jun 21 2006, 02:29 PM:name=Buyocat)--][div class=\'quotetop\']QUOTE(Buyocat @ Jun 21 2006, 02:29 PM) [snapback]386549[/snapback][/div][div class=\'quotemain\'][!--quotec--] Ok so you've got the while loop going through result rows, I suggest something like this: for just line breaks this will suffice... echo $row['member_name'] . '<br/>'; You need the period and the quotes around the <br/>. If you want it to be a little fancier, like a table with the first printed value in a row and the second one in another then try: echo '<table>' while ... echo '<tr>'; echo '<td>' . $row[1] . '</td>'; echo '<td>' . $row[2] . '</td>'; etc etc echo '</tr>'; ... echo '</table>'; I am just using the $row[1] etc as placeholders, be sure to put your own appropriate values in. Also keep in mind the </table> tag comes after the while loop is completed. [/quote] Got it: tossed in the <br> and it's readable now. I'll make it pretty later, but it functions! Thanks so much for the quick and accurate assistance!!!
  7. Found the typo: [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]$query = sprintf("( SELECT T1.username AS member_name, sum( T3.member_earned + T3.member_adjustment - T3.member_spent ) AS member_sumdkp FROM eqdkp_users T1, eqdkp_member_user T2, eqdkp_members T3 WHERE T1.user_id = T2.user_id AND T2.member_id = T3.member_id GROUP BY T1.username ) UNION ( SELECT T5.member_name AS member_name, sum( T5.member_earned + T5.member_adjustment - T5.member_spent ) AS member_sumdkp FROM eqdkp_member_user T4, eqdkp_members T5 WHERE T4.user_id = NULL AND T4.member_id = T5.member_id GROUP BY T4.member_id ) ORDER BY member_sumdkp DESC");[/quote] Didn't finish off $query right. Now: How can I format the results? I added a <br> after the echo $row with no effect but an error. [!--quoteo(post=386547:date=Jun 21 2006, 02:22 PM:name=blakogre)--][div class=\'quotetop\']QUOTE(blakogre @ Jun 21 2006, 02:22 PM) [snapback]386547[/snapback][/div][div class=\'quotemain\'][!--quotec--] Found the typo: Didn't finish off $query right. Now: How can I format the results? I added a <br> after the echo $row with no effect but an error. [/quote] You guys are quick! :-) I did some troubleshooting/poking it around and found the error. I just want to clean up the output now. It's at "http://www.blakogre.com/epix/altdkp.php" If I need to rework how I query and output, I can do that, let me know. Just remember i'm nub.
  8. I know very little about PHP, but I've got the query I need, and want the display output into a web page. I've already got PHP set up on IIS. [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]( SELECT T1.username AS member_name, sum( T3.member_earned + T3.member_adjustment - T3.member_spent ) AS member_sumdkp FROM eqdkp_users T1, eqdkp_member_user T2, eqdkp_members T3 WHERE T1.user_id = T2.user_id AND T2.member_id = T3.member_id GROUP BY T1.username ) UNION ( SELECT T5.member_name AS member_name, sum( T5.member_earned + T5.member_adjustment - T5.member_spent ) AS member_sumdkp FROM eqdkp_member_user T4, eqdkp_members T5 WHERE T4.user_id = NULL AND T4.member_id = T5.member_id GROUP BY T4.member_id ) ORDER BY member_sumdkp DESC[/quote] I put it in the page: [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]<?php define('EQDKP_INC', true); $eqdkp_root_path = './'; include_once($eqdkp_root_path . 'common.php'); // Formulate Query // This is the best way to perform a SQL query // For more examples, see mysql_real_escape_string() $query = sprintf("( SELECT T1.username AS member_name, sum( T3.member_earned + T3.member_adjustment - T3.member_spent ) AS member_sumdkp FROM eqdkp_users T1, eqdkp_member_user T2, eqdkp_members T3 WHERE T1.user_id = T2.user_id AND T2.member_id = T3.member_id GROUP BY T1.username ) UNION ( SELECT T5.member_name AS member_name, sum( T5.member_earned + T5.member_adjustment - T5.member_spent ) AS member_sumdkp FROM eqdkp_member_user T4, eqdkp_members T5 WHERE T4.user_id = NULL AND T4.member_id = T5.member_id GROUP BY T4.member_id ) ORDER BY member_sumdkp DESC", // Perform Query [b]$result = mysql_query($query);[/b] // Check result // This shows the actual query sent to MySQL, and the error. Useful for debugging. if (!$result) { $message = 'Invalid query: ' . mysql_error() . "\n"; $message .= 'Whole query: ' . $query; die($message); } // Use result // Attempting to print $result won't allow access to information in the resource // One of the mysql result functions must be used // See also mysql_result(), mysql_fetch_array(), mysql_fetch_row(), etc. while ($row = mysql_fetch_assoc($result)) { echo $row['member_name']; echo $row['member_sumdkp']; } // Free the resources associated with the result set // This is done automatically at the end of the script mysql_free_result($result); ?>[/quote] I tweaked syntax I got from another page. I get this error: Parse error: parse error, unexpected ';' in C:\Inetpub\boc\epix\altdkp.php on line 28 I bolded line 28 for easy reading. I am an utter PHP noob. I'm not sure if the sql query will even work in PHP. It works fine when executed in mysql admin tools Any help appreciated. I'm simply trying to take the 2 columsn returned, and output them to a php page.
×
×
  • 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.