Re: Quarter question..
| From: | David Robley | Date: | Mon, 04 Nov 2002 08:37:44 +0000 |
| Subject: | Re: Quarter question.. | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-22958@lists.php.net to get a copy of this message | ||
In article <200211011751.03080.James.Hatridge@epost.de>,
James.Hatridge@epost.de says...
> HI all,
>
> In the code below I'm trying to get the last column to show 1, 2, 3, or 4=
> =20
> according to which quarter of the year it is. But all it shows in that co=
> lumn=20
> is " Resource ID # X". The X starts with #3 and goes to 18. There are (at=
> the=20
> moment) 15 items in the table. Any ideas what's wrong?
>
> Thanks
>
> JIM
>
> #############################
> <?php
> echo "<table border=3D1> \n";
> $i=3D1;
> while ($myrow =3D mysql_fetch_array($result)) {
> if($i % 2) { //this means if there is a remainder
> echo "<TR bgcolor=3D\"yellow\">\n";
> } else { //if there isn't a remainder we will do the else
> echo "<TR bgcolor=3D\"white\">\n";
> }
> $qdate=3D$myrow["date"];
> $sql =3D "select quarter($qdate)" or die("not work #3");
> $yyy =3D mysql_query ($sql) or die("not work #4");
>
> printf("<td><a
> href=3D\"%s?id=3D%s&delete=3Dyes\">Delete</a></td>", $PHP_=
> SELF,=20
> $myrow["id"]);
> printf("<td><a
> href=3D\"%s?id=3D%s&submit=3Dyes\">Update</td><td>%s</td><=
> td> =20
> %s</td><td> %s</td></a></tr>",=20
> =09"update-inv.php", $myrow["id"], $myrow["name"],
> $myrow["details"], $yy=
> y);
You are echoing/printing $yyy here, which is the mysql result pointer; you
need to use mysql_fetch_array or similar to get the value of the quarter.
Hint - you might want to use an alias in the query where you select the
quarter.
> $i=3D$i+1;
> }
> echo "</table>\n";
> }
> ?>
> #############################
>
--
David Robley
Temporary Kiwi!
Quod subigo farinam