RE: [PHP] Reverse (or backward?) Infinity Loop

2004-10-19 Thread trenton
This does not generate the exact look you are asking for, but can easily
be modified by changing the dashes to spaces etc.  I also left my naming
convention in, so that would have to be altered to your fields as well. 
It may not be the cleanest code, but it does work.

ca_caid,$row->ca_category,0,1);
}

function recursive ($id,$element,$tabs,$y) {
$dashes = str_repeat("---", $tabs);
echo "$dashes$element\n";
$result = "result$y";
$row = "row$y";
$$query = "SELECT * FROM categories WHERE ca_caidParent='$id'";
$$result = mysql_query($$query);
while ($$row = mysql_fetch_object($$result)) {
$tabs++;
$y++;
recursive($$row->ca_caid,$$row->ca_category,$tabs,$y);
$tabs--;
$y--;
$result = "result$y";
$row = "row$y";
}
}

?>

Trenton

-Original Message-
From: Bruno B B Magalhães [mailto:[EMAIL PROTECTED]
Sent: Tuesday, October 19, 2004 8:47 PM
To: [EMAIL PROTECTED]; php-db
Subject: [PHP] Reverse (or backward?) Infinity Loop

Hi guys,

I have a normal categories table:

catId
catParentId
catName
catStatus

But I want when a user enters on:

http://hostname/site/products/catId1/catId7/catId13/../../contentId.html

A listing should apear like that:

• Category 1
  • Category 7
   • Category 13
• Category 2
• Category 3
• Category 4
• Category 5


A reverse (or backward) loop! We need to get the last category and then
follow the ParentId until the 0 ParentId. Have anybody made this before
(I hope so)?

Many Thanks,
Bruno B B Magalhaes

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] A better way to do this in php???

2004-10-20 Thread trenton
Why not use the date function?

date("g:i a");

Trenton

> I need to find the exact time of day using "minutes since midnight".
>
> What is the easiest and/or better way to do this in php?
>
> This is how I'm doing it now.
>
> // $iMinutes is the total number of minutes since midnight/12am
> // 0 = midnight/12am
> // 1439 = 11:59pm
>
> $iMinutes = 1230;
>
> if ($iMinutes < 0 || $iMinutes > 1439) {
> $restime = "??:??";
> } else {
> $iHour = $iMinutes / 60;
> $iMins = ($iMinutes - (60*$iHour)) % 60;
>
> if ($iHour <= 12) {
> $restime .= $iHour . ":";
> } else {
> $restime .= $iHour-12 . ":";
> }
>
> if ($iMins < 10) {
> $restime .= "0" . $iMins;
> } else {
> $restime .= $iMins;
> }
> if ($iHour < 12) {
> $restime .= " a.m.";
> } else if ($iHour==12 && $iMins==0) {
> $restime .= " noon";
> } else {
> $restime .= " pm";
> }
> }
>
>
> Thanks, Brent
>
>
> 
> This message was sent using IMP, the Internet Messaging Program.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php