Jump to content

mysql_fetch_object changing values of a property


mme

Recommended Posts

Hi,

 

I have the following code

$rs = mysql_query('SELECT * FROM transactions WHERE acid='.$acc);
$result = array();
while($row = mysql_fetch_object($rs))
{	
array_push($result, $row);
}
echo json_encode($result);

 

Now I wish to change the value of a certain column in each row that is returned from the database.

 

The column is called 'date' and contains a unix timestamo that I wish to format using my function stime($var,1).

 

How would I do this?

 

Kind Regards,

 

mme

Like... this?

 

while($row = mysql_fetch_object($rs)) {	
$row->date = stime($row->date, 1);
array_push($result, $row);
}

 

Thanks its all working! I tried $row['date'] before but I did not know it was possible to do it like you said ($row->date).

 

What does stime() do? Can it be done with MySQL functions instead?

 

It formats the date as well as checks it against a generated hash. But thank you for your suggestion.

Like... this?

 

while($row = mysql_fetch_object($rs)) {	
$row->date = stime($row->date, 1);
array_push($result, $row);
}

 

Thanks its all working! I tried $row['date'] before but I did not know it was possible to do it like you said ($row->date).

 

What does stime() do? Can it be done with MySQL functions instead?

 

It formats the date as well as checks it against a generated hash. But thank you for your suggestion.

Like... this?

 

while($row = mysql_fetch_object($rs)) {	
$row->date = stime($row->date, 1);
array_push($result, $row);
}

 

Thanks its all working! I tried $row['date'] before but I did not know it was possible to do it like you said ($row->date).

 

What does stime() do? Can it be done with MySQL functions instead?

 

It formats the date as well as checks it against a generated hash. But thank you for your suggestion.

 

Well, you used mysql_fetch_object rather than mysql_fetch_assoc

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.