0

I am busy with a project for fun and I am finding it tricky to set balues for mysql queries.

If I do the following:

function CalcPostByTime(){
  include 'DB_connection.php';  
  $result = mysql_query("SELECT ztime FROM blogpost;");

What is the simplest way to set an array, which will be a return value of the function, for the ztime value. Basically it is a unix time value, and in this query it is the only thing that I want to get out.

I want to then iterate through it in date/time order and set a value numbers as keys to the array in another function. Or should I do that in the query itself? Basically I don't want to worry about keys in the database, so that I always have the option of deleting or changing. I what to iterate through the values each time to order the posts, and set my selecting from there.

Edited by Namibnat: n/a

2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by kekkaishi
0

I am busy with a project for fun and I am finding it tricky to set balues for mysql queries.

If I do the following:

function CalcPostByTime(){
  include 'DB_connection.php';  
  $result = mysql_query("SELECT ztime FROM blogpost;");

What is the simplest way to set an array, which will be a return value of the function, for the ztime value. Basically it is a unix time value, and in this query it is the only thing that I want to get out.

I want to then iterate through it in date/time order and set a value numbers as keys to the array in another function. Or should I do that in the query itself? Basically I don't want to worry about keys in the database, so that I always have the option of deleting or changing. I what to iterate through the values each time to order the posts, and set my selecting from there.

i dont really understand ur requirement, but c if the following code helps to get you started

<?php
// PHP 5
function returnArray(){
$colors = array('red', 'blue', 'green', 'yellow');
return $colors;
}
$ra = returnArray();
    for($i=0; $i<4; $i++){
        print $ra[$i]."<br />";
    }
?>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.