Call specific $row['time'] from php and show in hype


(strmiska) #1

i´m able to write i.e. time and name into a database and call the whole table using ajax into hype again.
something like a highscore.
what i cannot manage is to call a specific $row[‘zeit’] and show in hype. it always shows me the whole table.
also i want to sort this row ascending. in php i tried natsort(), but failed, because i´ve to use a array of numbers.
maby someone can give me a hint how to do this?
thank you.

my php:

include ('DB.php'); 
$con = mysqli_connect($host,$user,$pass,$databaseName);
if (!$con) {
    die('Could not connect: ' . mysqli_error($con));
$sql="SELECT * FROM $tableName ORDER BY zeit";
$result = mysqli_query($con,$sql);
echo "<table>
while($row = mysqli_fetch_array($result)) {
echo "<tr>";
echo "<td>" . $row['zeit'] . "</td>";
echo "<td>" . $row['username'] . "</td>";
echo "<td>" . $row['password'] . "</td>";
echo "</tr>";
echo "</table>";

my hype-function():

    url: 'dataBase.php',
    type: 'POST',
    dataType: 'HTML',
    data: {
          zeit: $('#zeit').val(),
     success: function(response){                    



try maybe

$sql = "SELECT zeit, username, password FROM $tablename ORDER by zeit ASC"
while ($row = mysqli_fetch_row($result)) {

As it returns an associative array you could perhaps output it like this:

echo "<td>" . $row[0] . "</td>"; //  $row[0] being 'zeit'
echo "<td>" . $row[1] . "</td>";
echo "<td>" . $row[2] . "</td>"

(strmiska) #3

unfortunately this isn´t working - the only thing is the same result, because
$row['zeit'] outputs the same as $row[1]


What about setting a limit


so it only brings back 1 row

You can order in your SQL.

"ORDER by (whatever) ASC"

P.S I’m away from main comp so can’t test. Just throwing out ideas :slight_smile:

(strmiska) #5

this is what i do, but don´t work.
$sql=“SELECT * FROM $tableName ORDER BY zeit ASC”;
so example “345” comes before"50" - this souldn´t be.

(strmiska) #6

YES!! GOT it! so simple - :innocent:
you´ve to write

"*1 ASC":
$sql="SELECT * FROM $tableName ORDER BY zeit * 1 ASC";`