Page 1 of 1

[SOLVED]Loading mysql results into an array

Posted: Thu Feb 26, 2004 7:08 am
by Tubby
Hello,
I'm trying to get the archive of a blog displayed as a calendar type thing, I found an opensource calendar that does the job nearly, but needs a tiny bit of modification to get it to work exactly as I want.

Here is the script and an explanation of what I want it to do in the end, hope it makes sense :)

Any help and code appreciated.

Posted: Thu Feb 26, 2004 2:10 pm
by infolock
dunno, hard to understand ur explaining... so, what i'll do is write a little loop that will generate an array for you. i think this should be enough to get you started at least :

Code: Select all

//....
$sql = "SELECT * FROM rants WHERE rantid='0' AND year='".$in_year."' AND month='".$in_month."'";
$result = mysql_query($sql) or die(MySQL_Error());

$blog = array();
$
$days = array();

// this loop assumes there is a field named Blog and a field named Day since i have no idea what your table's field structure looks like..
while($row=mysql_fetch_array($result))
{
    $blog[] = $row['blog'];
    $days[] = $row['days'];
}

myarray = array();
for($i=0; $i<count($blog); $i++)
{
   $myarray[] = array($blog[$i] -> $days[$i]);
}
dunno.. i coudlnt' really tell what this :
$days = array(
2=>array('/blog/2','linked'),
3=>array('/blog/13','linked'),
8=>array('/blog/14','linked'),
22=>array('/blog/17','linked'),
is suposed to be... i mean, what is 2,3,8,22 ?? what is the linked for ? are they all field values in the table? is the blog and link field values?

more information por favor :P

Posted: Thu Feb 26, 2004 2:12 pm
by malcolmboston
this is exactly the reason i dont use other peoples scripts

.......if you write it yourself, you are using your own coding styles and have a full and clear understanding of what your are coding, what bit of the script does what.........

........if its someone elses you may not

Posted: Thu Feb 26, 2004 2:19 pm
by Tubby
'salright, I got bored over the last few hours and wrote my own using bits from his script and so far it seems to be working well :)

Thanks for your replies though, they are appriciated.