function getMidScore() { //connect to db $db = new dbConfig(); $db->getDbParams(); /*select main score*/ $result_select = getSelectMidScore($db); $scoreTable = ""; // html $scoreTable .= "<table id=\"midScore\" >\n"; $scoreTable .= "<tr><th>dkbbg</th><th>querido_amigo</th></tr>"; $data = array(); while ($row = mysqli_fetch_array($result_select, MYSQL_ASSOC)) { $data[] = $row; } $scoreTable .= "<tr>"; foreach ($data as $key => $value) { $scoreTable .= "<td id='D_mid'>" . $value['D_mid'] . "</td>"; $scoreTable .= "<td id='S_mid'>" . $value['S_mid'] . "</td>"; } $scoreTable .= "</tr>"; $scoreTable .= "</table>\n"; return $scoreTable; }
<?php //incudes include "includes/functions.php"; include "classes/config.php"; //connect to db $db = new dbConfig(); $db->getDbParams(); //check new record $record = $_GET['record']; if ($record == 'yes') { //get player data $name = '\'' . substr(str_replace('\'', '', $_GET['name']), 0, 15) . '\''; $score = $_GET['score']; //use functions to insert new recordds and select top-10 $result_insert = getInsert($db, $name, $score); $result_select = getSelect($db); // html echo "<table id=\"scoreTable\" >\n"; while ($row = mysql_fetch_array($result_select, MYSQL_ASSOC)) { echo "\t<tr id='{$row['name']}'>\n"; foreach ($row as $key => $value) { echo "\t\t<td>{$value}</td>\n"; } echo "\t</tr>\n"; } echo "</table>\n"; } else { if ($record == 'start') { //show highscores at new game //select top-10