PHP displaying row using ADOdb

5.3k views Asked by At

This is my ADOdb code:

$sql  = "SELECT m.*, s.photo, s.gender
         FROM mail AS m, signup AS s
         WHERE m.receiver = '" .mysql_real_escape_string($username). "'
         AND m.sender = s.username AND inbox = '1' AND status = '1'
         ORDER BY send_date DESC LIMIT " .$limit;
// my date is in the format 2012-08-02 02:20:05

$rs1  =  $conn->execute($sql);
$time =  $rs1->GetAssoc('send_date'); //GetArray Or GetRows
echo $time;

The echo shows an array, but what I need is to display the row send_date.

(Instead of ->GetAssoc, I've had also tried ->GetArray and ->GetRows.)

How can I display the row send_date?

1

There are 1 answers

1
dev-null-dweller On

You are not using adodb properly. It has built-in mechanism for escaping arguments, as well as separate method for limited results:

$sql  = "SELECT m.*, s.photo, s.gender
         FROM mail AS m, signup AS s
         WHERE m.receiver = ?
         AND m.sender = s.username 
         AND inbox = '1' 
         AND status = '1'
         ORDER BY send_date DESC";
$rs1  =  $conn->selectLimit($sql, $limit, -1, array($username));

// You will recive recordset with maximum of $limit rows, so you have to iterate through it:
while($row = $rs1->FetchRow()){
   echo $row['send_date'] . "\n";
}