php - Why does this code miss the first entry? -


ok, have little problem code: doesn't first result? example: ban table may this: [http://i.stack.imgur.com/dyucd.png][1] data echoed miss first row, 1 reason rdmx3 , evade, , no name.

for example: here direct sourcebans: http://i.stack.imgur.com/snxzv.png

and here version using below code: http://i.stack.imgur.com/ecexb.png

note first ban, displayed on first image, not displayed on second image. (don't mind length on second image, i've gotta fix that.)

<?php $sql44 = "select * `sb_bans` order `created` desc limit 6"; $res44 = mysqli_query($globals["___mysqli_ston"], $sql44) or trigger_error(((is_object($globals["___mysqli_ston"])) ? mysqli_error($globals["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_error()) ? $___mysqli_res : false))); $row44 = mysqli_fetch_assoc($res44);  while($row44 = mysqli_fetch_array($res44)) { $sid1 = $row44['sid']; $name1 = $row44['name']; $steamid110 = $row44['authid']; $reason1 = $row44['reason']; $timesec = $row44['length']; $unbanstatus = $row44['removetype'];  if($unbanstatus == "u") { $type1 = "(u)"; } elseif($unbanstatus == "e") { $type1 = "(e)"; } else { $type1 = ""; } if($sid = 1) { $serv = "<img src='http://bans.versound.net/images/games/gmodttt.png' alt='ttt' />"; } elseif($sid = 2) { $serv = "tf2 au"; } elseif($sid = 3) { $serv = "sb au"; } else { $serv = "wtf"; } if($name1 == null) { $name1 = "no nickname present"; } else { $name1 = $name1; } if($timesec == "0") { $length1 = "permanent"; } else { $length2 = gmdate("d", $timesec); $length1 = "$length2 days"; } echo "<tr style='" . $type2 . "'>\n<td style='text-align:center'>" . $serv . "</td>\n<td><a href='http://bans.versound.net/index.php?p=banlist&amp;advsearch=" . $steamid110 . "&amp;advtype=steamid&amp;submit' target='_blank'>" . $name1 . "</a></td>\n<td>" . $reason1 . "</td>\n<td>" . $length1 . " " . $type1 . "</td>\n</tr>\n"; } ?> 

why occur? can me? also, use desc limit 6 because desc limit 5 misses first result, , outputs 4 results.

because calling 1 fetch unnecessarily , wasting before calling real fetch use.

$row44 = mysqli_fetch_assoc($res44);  //this line not needed , should go  while($row44 = mysqli_fetch_array($res44)) 

should be

while($row44 = mysqli_fetch_array($res44)) 

Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Automatically create pages in phpfox -

c# - Farseer ContactListener is not working -