[SOLVED]Loading mysql results into an array

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Tubby
Forum Commoner
Posts: 28
Joined: Thu Oct 17, 2002 5:55 pm

[SOLVED]Loading mysql results into an array

Post 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.
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post 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
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post 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
User avatar
Tubby
Forum Commoner
Posts: 28
Joined: Thu Oct 17, 2002 5:55 pm

Post 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.
Post Reply