Salve a tutti quando esegui il While tramite questa funzione:
Codice PHP:
function display($content, $title, $topnav=true, $leftnav=true, $rightnav=true, $badstart=false) { // Finalize page and output to browser. global $numqueries, $userrow, $controlrow, $version, $build; if (!isset($controlrow)) { $controlquery = doquery("SELECT * FROM {{table}} WHERE id='1' LIMIT 1", "control"); $controlrow = mysql_fetch_array($controlquery); } if ($badstart == false) { global $starttime; } else { $starttime = $badstart; } // Make page tags for XHTML validation. $xml = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n" . "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"DTD/xhtml1-transitional.dtd\">\n" . "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n"; $template = gettemplate("primary"); if ($rightnav == true) { $rightnav = gettemplate("rightnav"); } else { $rightnav = ""; } if ($leftnav == true) { $leftnav = gettemplate("leftnav"); } else { $leftnav = ""; } if ($topnav == true) { $topnav = " <a href=\"index.php\">HOME</a> | <a href=\"index.php?do=hof\">HALL OF FAME</a> | <a href=\"mail.php\">MESSAGGI</a> | <a href=\"index.php?do=editinfo\">PROFILO</a> | <a href=\"login.php?do=logout\">ESCI</a> "; } else { $topnav = " - <a href=\"home.php\">HOME</a> | <a href=\"users.php?do=register\">REGISTRATI</a> | <a href=\"media.php\">MEDIA</a> | <a href=\"faq.php\">F.A.Q</a> | <a href=\"contattaci.php\">CONTATTACI</a> - "; } if (isset($userrow)) { // Get userrow again, in case something has been updated. $userquery = doquery("SELECT * FROM {{table}} WHERE id='".$userrow["id"]."' LIMIT 1", "users"); unset($userrow); $userrow = mysql_fetch_array($userquery); // Current town name. if ($userrow["currentaction"] == "In Città") { $townquery = doquery("SELECT * FROM {{table}} WHERE latitude='".$userrow["latitude"]."' AND longitude='".$userrow["longitude"]."' LIMIT 1", "towns"); $townrow = mysql_fetch_array($townquery); $userrow["currenttown"] = "Welcome to [b]".$townrow["name"]."[/b].
"; } else { $userrow["currenttown"] = ""; } if ($controlrow["forumtype"] == 0) { $userrow["forumslink"] = ""; } elseif ($controlrow["forumtype"] == 1) { $userrow["forumslink"] = "<a href=\"forum.php\">Forum</a>
"; } elseif ($controlrow["forumtype"] == 2) { $userrow["forumslink"] = "<a href=\"".$controlrow["forumaddress"]."\">Forum</a>
"; } // Format various userrow stuffs... if ($userrow["latitude"] < 0) { $userrow["latitude"] = $userrow["latitude"] * -1 . "S"; } else { $userrow["latitude"] .= "N"; } if ($userrow["longitude"] < 0) { $userrow["longitude"] = $userrow["longitude"] * -1 . "W"; } else { $userrow["longitude"] .= "E"; } $userrow["experience"] = number_format($userrow["experience"]); $userrow["gold"] = number_format($userrow["gold"]); if ($userrow["authlevel"] == 1) { $userrow["adminlink"] = " - <a href=\"admin.php\">Amministrazione</a>
- <a href=\"index.php?do=updatequery\">Reset Turni</a> "; } else { $userrow["adminlink"] = ""; } if ($userrow["skills"] == 0) { $userrow["skills"] = ""; } else { $userrow["skills"] = "[<a href=\"index.php?do=skills\">+".$userrow["skills"]." SP</a>]"; } /////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////// Checking mail ////////////////////////////////////////// $link = opendb(); include('config.php'); $table=$dbsettings["prefix"] . "_mail"; $result = @ mysql_query("SELECT * FROM $table WHERE UserTo='$userrow[id]' AND STATUS='unread'", $link); $num_rows = mysql_num_rows($result); if ( $num_rows > "0") { $userrow["check_mail"] = "<a href=\"mail.php\">Mail [".$num_rows."]</a>
"; } else { $userrow["check_mail"] = "<a href=\"mail.php\">Mail</a>
"; } ////////////////////////////// End Checking mail ////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////// HP - MP - TP bars /////////////////////////////////////////// ///////////////////////////// BY BLUE EYES /////////////////////////////////////////// // START CHARACTER ALIGNMENT ARRAY if ($userrow["charalign"] == 1) { $userrow["charalign"] = $controlrow["align1name"]; } elseif ($userrow["charalign"] == 2) { $userrow["charalign"] = $controlrow["align2name"]; } elseif ($userrow["charalign"] == 3) { $userrow["charalign"] = $controlrow["align3name"]; } elseif ($userrow["charalign"] == 4) { $userrow["charalign"] = $controlrow["align4name"]; } elseif ($userrow["charalign"] == 5) { $userrow["charalign"] = $controlrow["align5name"]; } elseif ($userrow["charalign"] == 6) { $userrow["charalign"] = $controlrow["align6name"]; } elseif ($userrow["charalign"] == 7) { $userrow["charalign"] = $controlrow["align7name"]; } // END CHARACTER ALIGNMENT ARRAY $stathp = ceil($userrow["currenthp"] / $userrow["maxhp"] * 100); $stattp = ceil($userrow["currenttp"] / $userrow["maxtp"] * 100); if ($userrow["maxmp"] != 0) { $statmp = ceil($userrow["currentmp"] / $userrow["maxmp"] * 100); } else { $statmp = 0; } $stattable = "<table width=\"100\"><tr><td width=\"33%\">\n"; $stattable .= "<table cellspacing=\"0\" cellpadding=\"0\"><tr><td style=\"padding:0px; width:100px; height:7px; border:solid 0px black; vertical-align:bottom;\">\n"; $stattable .= "<tr><td>[b][/b]HP: [/b]$userrow[currenthp] / $userrow[maxhp]</td></tr>"; $stattable .= "<table cellspacing=\"0\" cellpadding=\"0\"><tr> <td style=\"padding:0px; width:100px; height:7px; border:solid 0px black; vertical-align:bottom;\">\n"; if ($stathp >= 66) { $stattable .= "<div style=\"padding:0px; width:".$stathp."px; border-top:solid 0px black; background-image:url(images/bars_green.gif);\"> <img src=\"images/bars_green.gif\" alt=\"\" /></div>"; } if ($stathp < 66 && $stathp >= 33) { $stattable .= "<div style=\"padding:0px; width:".$stathp."px; border-top:solid 0px black; background-image:url(images/bars_yellow.gif);\"> <img src=\"images/bars_yellow.gif\" alt=\"\" /></div>"; } if ($stathp < 33) { $stattable .= "<div style=\"padding:0px; width:".$stathp."px; border-top:solid 0px black; background-image:url(images/bars_red.gif);\"> <img src=\"images/bars_red.gif\" alt=\"\" /></div>"; } $stattable .= "<tr><td>[b]MP: [/b]$userrow[currentmp] / $userrow[maxmp]</td></tr>"; $stattable .= "<table cellspacing=\"0\" cellpadding=\"0\"><tr> <td style=\"padding:0px; width:100px; height:7px; border:solid 0px black; vertical-align:bottom;\">\n"; if ($statmp >= 66) { $stattable .= "<div style=\"padding:0px; width:".$statmp."px; border-top:solid 0px black; background-image:url(images/bars_green.gif);\"> <img src=\"images/bars_green.gif\" alt=\"\" /></div>"; } if ($statmp < 66 && $statmp >= 33) { $stattable .= "<div style=\"padding:0px; width:".$statmp."px; border-top:solid 0px black; background-image:url(images/bars_yellow.gif);\"> <img src=\"images/bars_yellow.gif\" alt=\"\" /></div>"; } if ($statmp < 33) { $stattable .= "<div style=\"padding:0px; width:".$statmp."px; border-top:solid 0px black; background-image:url(images/bars_red.gif);\"> <img src=\"images/bars_red.gif\" alt=\"\" /></div>"; } $stattable .= "<tr><td>[b]TP: [/b]$userrow[currenttp] / $userrow[maxtp]</td></tr>"; $stattable .= "<table cellspacing=\"0\" cellpadding=\"0\"> <tr><td style=\"padding:0px; width:100px; height:7px; border:solid 0px black; vertical-align:bottom;\">\n"; if ($stattp >= 66) { $stattable .= "<div style=\"padding:0px; width:".$stattp."px; border-top:solid 0px black; background-image:url(images/bars_green.gif);\"> <img src=\"images/bars_green.gif\" alt=\"\" /></div>"; } if ($stattp < 66 && $stattp >= 33) { $stattable .= "<div style=\"padding:0px; width:".$stattp."px; border-top:solid 0px black; background-image:url(images/bars_yellow.gif);\"> <img src=\"images/bars_yellow.gif\" alt=\"\" /></div>"; } if ($stattp < 33) { $stattable .= "<div style=\"padding:0px; width:".$stattp."px; border-top:solid 0px black; background-image:url(images/bars_red.gif);\"> <img src=\"images/bars_red.gif\" alt=\"\" /></div>"; } $stattable .= "</td></tr></table></td>\n"; $stattable .= "</table>\n"; $userrow["statbars"] = $stattable; ////////////////// /////////// END BARS DISPLAY /////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////// // Now make numbers stand out if they're low. if ($userrow["currenthp"] <= ($userrow["maxhp"]/5)) { $userrow["currenthp"] = "<blink><span class=\"highlight\">[b]*".$userrow["currenthp"]."*[/b]</span></blink>"; } if ($userrow["currentmp"] <= ($userrow["maxmp"]/5)) { $userrow["currentmp"] = "<blink><span class=\"highlight\">[b]*".$userrow["currentmp"]."*[/b]</span></blink>"; } $spellquery = doquery("SELECT id,name,type FROM {{table}}","spells"); $userspells = explode(",",$userrow["spells"]); $userrow["magiclist"] = ""; while ($spellrow = mysql_fetch_array($spellquery)) { $spell = false; foreach($userspells as $a => $b) { if ($b == $spellrow["id"] && $spellrow["type"] == 1) { $spell = true; } } if ($spell == true) { $userrow["magiclist"] .= "<a href=\"index.php?do=spell:".$spellrow["id"]."\">".$spellrow["name"]."</a>
"; } } if ($userrow["magiclist"] == "") { $userrow["magiclist"] = "None"; } // Travel To list. $townslist = explode(",",$userrow["towns"]); $townquery2 = doquery("SELECT * FROM {{table}} ORDER BY id", "towns"); $userrow["townslist"] = ""; while ($townrow2 = mysql_fetch_array($townquery2)) { $town = false; foreach($townslist as $a => $b) { if ($b == $townrow2["id"]) { $town = true; } } if ($town == true) { $userrow["townslist"] .= "<a href=\"index.php?do=gotown:".$townrow2["id"]."\">".$townrow2["name"]."</a>
\n"; } } } else { $userrow = array(); } $finalarray = array( "dkgamename"=>$controlrow["gamename"], "title"=>$title, "content"=>$content, "rightnav"=>parsetemplate($rightnav,$userrow), "leftnav"=>parsetemplate($leftnav,$userrow), "topnav"=>$topnav, "totaltime"=>round(getmicrotime() - $starttime, 4), "numqueries"=>$numqueries, "version"=>$version, "build"=>$build); $page = parsetemplate($template, $finalarray); $page = $xml . $page; if ($controlrow["compression"] == 1) { ob_start("ob_gzhandler"); } echo $page; die(); }
Il while stampa solo 1 risultato (While in questione):
Codice PHP:
$sqls = mysql_query("SELECT * FROM dk_gilde ORDER BY `nome` DESC"); while($row = mysql_fetch_array($sqls)) { $page = "<center>" . $row['nome'] . "
"; display($page,"Lista gilde"); }
Soluzioni