PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
this is my current problem
i need to get out 3 diffrent rows from the datarows while its in a WHILE...
i got the while now i need to tell it to place "first" at datatable 1 and "second" at datatable 2 and "third" at datatable 3 and so on
<table border="1">
<tr>
<th>Units</th>
<th>AtkArm</th>
<th>Buyfor</th>
<th>Sellfor</th>
<th>Swordmen</th>
</tr>
<!-- starting the while -->
<?php while ($row1 = mysql_fetch_assoc($result1)): ?>
<tr>
<th><?php echo $row1['Units'] ;?></th>
<th><?php echo $row1['AtkHp'] ;?></th>
<th><?php echo $row1['Buyfor'] ;?></th>
<th><?php echo $row1['Sellfor'] ;?></th>
<!-- need to get out three diffrent tabledatas... but on the same row so to say -->
<th><?php echo $swordmen ?></th> <--------------Here i got the problem
<!--it should have theses too-->
<!-- <th><?php echo $macemen?></th> --> <!--- picture will show --->
<!-- <th><?php echo $pikemen?></th> -->
<th>
<font color="black" valign= "top"><input style='width:45;height:20' type="text" name="input ITD1" size="250" class="textbox" value=""></font>
<input style='width:45;height:30;font-weight:bold' name="submit" type="submit" class="submit" value="Buy!">
</th>
</tr>
<!-- ending the while -->
<?php endwhile; ?>
Attachments
well were it is red rings there i want 3 diffrent tabledatas like above code... $swordmen (8), $macemen(5), $pikemen(3) however it only returns first array (swsordmen) when i need it to collect from all 3
Problem.jpg (16.88 KiB) Viewed 346 times
Last edited by Goofan on Mon Nov 16, 2009 2:04 pm, edited 8 times in total.
<?php
// Get the database connector stuff
include "../login/database.php";
// Build our query
$sql1 = 'SELECT * FROM `infantries`';
// Get the result if there is one
// DO NOT die() IN PRODUCTION!!!
if (!$result1 = mysql_query($sql1))
{
die('The query<br /><strong>' . $sql1 . '</strong><br />failed:<br />' . mysql_error());
}
?>
<?php
$id =(isset($_GET['saved_id'])) ? (int)$_GET['saved_id'] : false;
if($id !== false) {
$sql="SELECT * FROM konto WHERE saved_id=$id"; //selecting all from DB "Konto" where saved_id is the same as in the array $id
}
else
{
echo "NO saved_id!";
}
$result = mysql_query($sql) or die(mysql_error());//Välj all info i tall. //hämtar all info från tabell
while($row = mysql_fetch_array( $result )) //hämtar info från tabell.
{
$swordmen=$row['swordmen'];
$macemen=$row['macemen'];
$pikemen=$row['pikemen'];
}
?>
the problem isnt that i need to access the (8)... i need to collect from swordmen (which containes the 8 ) then i got some others.... they got other value (like (5) and (7) and so on however as i put the array within a while i only get swordmens value got any idé on how to solve this problem? (for more info check the comment on the picture)
(tell me if i missunderstood ure answer and if so plz explain ure part abit more)