Hi I’m starting out on php and I have the following script
<?php $username = 'firstleg_floa'; $password = '**'; $hostname = '***1'; $db = 'firstleg_bank'; $guildUser = strtolower('grissiom'); $dbh = mysql_connect( $hostname, $username, $password) or die ('Unable To Connect'); $connectDB = mysql_select_db($db, $dbh); $results = mysql_query('SELECT * FROM Bank where userId ='' .$guildUser.'''); $i = 0; $rsArr = array(); While ($row = mysql_fetch_array($results, MYSQL_ASSOC)) { $rsArr [$i] [0] = $row{'userId'}; $rsArr [$i] [1] = $row{'item'}; $rsArr [$i] [2] = $row{'amount'}; $rsArr [$i] [3] = $row{'position'}; $i++; } ?> <?='ghdfdgdfg '. $rsArr[$i][1];}.' ----';?> <? echo $rsArr[$i][0]; ?> <table> <tr><td>Item</td><td>Amount</td></tr> <?for ($x=0;$x <= $i; $x++) {?> <tr><td><?=$rsArr[$x][3];?></td><td><?=$rsArr[$x][2];?></td></tr> <?}?> </table> <?php mysql_close($dbh); ?>
and I have the following data in the database
1 – grissiom – Silk Cloth – 100 – 1
with the above data and the above script all I can manage to pull out is the amount(100) and the position(1) how come i am unable to pull anything else out? can someone help me please
after loop is finished $i is equal to 1, but $rsArr[$i] is not defined, so variables $rsArr[$i][0] and $rsArr[$i][1] doensn’t exists, try using $rsArr[0][0] and $rsArr[0][1] like this: