Lifelesspeople.com

 Forum FAQsForum FAQs  Knowledge BaseKnowledge Base  RulesRules   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   HostingHosting   RegisterRegister 
 DonateDonate   WikiWiki   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

displaying different things from sql

 
Lifelesspeople.com Forum Index -> Web Architects' Abode
Post new topic   Reply to topic View previous topic :: View next topic  
Author Message
Desbrina
Jadeite


Joined: 11 Jun 2005
Posts: 2972
Location: Earth

PostPosted: Wed Dec 05, 2007 11:14 am    Post subject: displaying different things from sql Reply with quote

i've actually almost got it working myself.

The only problem i'm having is it shows the sets as either all there, or none at all, when theres at least 1 from each set
I think its to do with my sql query, but am unsure as to how to fix it

Code:
   $counter = 1;
   $con = mysql_connect('localhost', '****', '*******') or die('Could not connect to database!');
    mysql_select_db('*****', $con);
   $sql = mysql_query("SELECT cards.alttext,cards.url,user_inventory.item_id,cards.deck,user_inventory.deck FROM user_inventory,cards WHERE user_inventory.name = '".mysql_real_escape_string($_GET['user'])."' AND user_inventory.status = 'collecting' AND user_inventory.deck = cards.deck ORDER BY cards.category, cards.deck ASC");       
   if (mysql_num_rows($sql)) {   
   print $row['deck'];
      $i = 0;
      while ($row = mysql_fetch_array($sql)) {
         if (preg_match("/ja(0[1-9]|1[0-8])|(jase[1-2])|(future)|(menaceobi)|(sithadult)|(sithjunior)|(menaceamidala)|(menaceanakin)|(menacejunior)|(menacemaul)|(clonesadult)|(clonesjunior)/i", $row['deck']))
      define('CARDS_PER_ROW', 3);
   else
      define('CARDS_PER_ROW', 5);
         if($counter <= 9) {
            $deck = "{$row['deck']} 0{$counter}";
         } else {
            $deck = "{$row['deck']} {$counter}";
         }
         $deck1 = $row['deck'];
            if($deck == $row['alttext']) {
               echo "<img src=\"{$row['url']}\" alt=\"{$row['alttext']}\" />" ;
               ++$counter;
               if (++$i % CARDS_PER_ROW == 0)
                 echo '<br />';
            } else {
               $sql2 = mysql_query("SELECT * FROM cards00 where deck = '".$deck1."'");       
               if (mysql_num_rows($sql2)) {      
               while ($row = mysql_fetch_array($sql2)) {
                  echo "<img src=\"{$row['url']}\" alt=\"{$row['alttext']}\" />" ;
                  ++$counter;
                  if (++$i % CARDS_PER_ROW == 0)
                    echo '<br />';
               }
            }
         }
      }
   }
}

_________________
Midnight Tempest - A Sailor Moon TCG
Balanced Force - A Star Wars TCG
Back to top
 
Display posts from previous:   
Post new topic   Reply to topic    Lifelesspeople.com Forum Index -> Web Architects' Abode All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Home | Hosting | News | Forum | Links | System Status | About | Archive | Donate ]
Powered by phpBB © 2001, 2002 phpBB Group
All trademarks and copyrights on this page are owned by their respective owners. Posts and comments are owned by the poster. Everything else © 2001 - 2007 Lifelesspeople.com