DragonPrime - LoGD Resource Community
Welcome Guest
  • Good morning, Guest.
    Please log in, or register.
  • December 11, 2018, 01:14:10 AM
Home Forums News Downloads Login Register Advanced Search
* * *
DragonPrime Menu
Login
 
 
Resource Pages
Search

Pages: [1]   Go Down
  Print  
Author Topic: Clan Weapon and Armor Shops  (Read 97 times)
0 Members and 1 Guest are viewing this topic.
TGTarheel
Codemeister
****
Offline Offline

Posts: 491


View Profile
« on: December 03, 2018, 01:32:15 AM »

ok, I do not understand something here.  When I go into the shops, the order of weapons available does nt seem to match the sql call.  Coding below.

According to what I see, it should order the rows by "value" which is the attack/defense strength of the weapon.

But the output I get is ordered by "shopid" - meaning someone who made a much weaker weapon, later than I made a powerful weapon....my weapon is showing up first...instead of ordering it by order of lowest value to highest value.

Here is the coding - I did not alter this from the original module in any way...except biggifying the type using <big> and </big>
Code:
rawoutput("<table border=0 cellpadding=2 cellspacing=1 bgcolor='#999999'>");
    rawoutput("<tr class='trhead'>");
   rawoutput("<td><big>$buy1</big></td><td><big>$wname</big></td><td><big>$watk</big></td><td><big>$wcost</big></td>");
    rawoutput("</tr>");
   $sql = "SELECT * FROM " .db_prefix("clanshop"). " WHERE type = '1' AND clan = '$clan' AND buyer < 1 AND value < '$dklimit' ORDER BY 'value'";
$res = db_query($sql);
   for ($i=0;$i<db_num_rows($res);$i++){
   $row = db_fetch_assoc($res);
     $id = $row['shopid'];
        $name = $row['name'];
     $value = $row['value'];
     $cost = $row['cost'];
       rawoutput("<tr class='".($i%2?"trlight":"trdark")."'>");
rawoutput("<td nowrap>[ <big><a href='runmodule.php?module=clanforge&op=buyweapon&id=$id'>$choose</big></a>]");
        addnav("","runmodule.php?module=clanforge&op=buyweapon&id=$id");
   output_notl("<td><big>`^%s</big></td>`0", $row['name'], true);
     output_notl("<td><big>`&%s`0</big></td>", $row['value'], true);
        output_notl("<td><big>`^%s`0</big></td>", $row['cost'], true);
        rawoutput("</tr>");
}
    rawoutput("</table>");

It eve says in the SQL call, ORDER BY "value" - so why is the output ordering by "shopid" instead?
Logged
TGTarheel
Codemeister
****
Offline Offline

Posts: 491


View Profile
« Reply #1 on: December 03, 2018, 01:43:24 AM »

Never mind.

I found my own problem.  The original coder put 'value' as is

ORDER BY 'value'

and it should be

ORDER BY value ASC

No quotes around value, and specify ascending versus descending order.

I like to play with this stuff to learn how things work and why.

I found my own answer this time.


Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  


*
DragonPrime Notices
Please take the time to read the FAQ and browse the DragonPedia

Support Us
No funds raised yet this year
Your help is greatly appreciated!
Recent Topics
DragonPrime LoGD
Who's Online
55 Guests, 0 Users
Home Forums News Downloads Login Register Advanced Search