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 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 />";
    }
?>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.