the title is a little under specific but its best i could explain in one line.
my problem is basically, i have a table in my db which i query with;
<?php
include 'connect.php';
$query = mysql_query("SELECT * FROM mobs WHERE zone='Darnolth' ORDER BY lvl ") or die(mysql_error());;
echo "<table border='1' cellpadding='2' cellspacing='0' width=800 id='mob' class='tablesorter'><thead>";
echo "<tr> <th> </th> <th>Mob Name</th> <th>Level</th> <th>Health</th> <th>Drops</th> <th>Effects</th> <th>Zone</th></tr></thead><tbody>";
while($row = mysql_fetch_array( $query )) {
echo "<tr><td>";
echo $row['image'];
echo "</td><td width=200>";
echo $row['mobname'];
echo "</td><td width=50>";
echo $row['lvl'];
echo "</td><td width=50>";
echo $row['health'];
echo "</td><td width=200>";
echo $row['drops'];
echo "</td><td width=100>";
echo $row['effects'];
echo "</td><td width=75>";
echo $row['zone'];
echo "</td></tr>";
}
echo "</tbody></table>";
?>
now this is all fine, but the drops row needs to pull images of all the items which are dropped by that mob from the items table in my db
so it would need to call on the items table for the images from the rows that have a dropped by name the same as the mob name from the above query.
i tried adding another query within the but that did nothing, i cant think of anything else.
thanks.
tried to mod my code using INNER JOIN to;
<?php
include 'connect.php';
$query = mysql_query("SELECT mobs.image, mobs.mobname, mobs.lvl, mobs.health, mobs.drops, mobs.effects, mobs.zone, misc.droppedby FROM mobs JOIN misc ON mobs.drops = misc.droppedby") or die(mysql_error());;
echo "<table border='1' cellpadding='2' cellspacing='0' width=800 id='mob' class='tablesorter'><thead>";
echo "<tr> <th> </th> <th>Mob Name</th> <th>Level</th> <th>Health</th> <th>Drops</th> <th>Effects</th> <th>Zone</th></tr></thead><tbody>";
// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $query )) {
// Print out the contents of each row into a table
echo "<tr><td>";
echo $row['image'];
echo "</td><td width=200>";
echo $row['mobname'];
echo "</td><td width=50>";
echo $row['lvl'];
echo "</td><td width=50>";
echo $row['health'];
echo "</td><td width=200>";
echo $row['drops'];
echo "</td><td width=100>";
echo $row['effects'];
echo "</td><td width=75>";
echo $row['zone'];
echo "</td></tr>";
}
echo "</tbody></table>";
?>
but now this is only causing my mobs table to load each mob by the amount of items in my misc table, so i have mob1 100 times and mob2 100 times and so on, but it doesnt pull the images from the misc table and put them in the drops column in the mobs table.
Aucun commentaire:
Enregistrer un commentaire