Desbrina Jadeite

Joined: 11 Jun 2005 Posts: 2972 Location: Earth
|
Posted: Wed Dec 05, 2007 11:14 am Post subject: displaying different things from sql |
|
|
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 |
|