Re: date from mysql
| From: | David Robley | Date: | Fri, 30 Aug 2002 04:42:03 +0000 |
| Subject: | Re: date from mysql | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-114591@lists.php.net to get a copy of this message | ||
In article <01ae01c24f4f$51dc7bd0$b500000a@web18>, webby@rori.org says...
> i want Y (year format) printed on my php script (looping), i already tried
> it but i got same Year format (ex 1978) in all row in my table
>
> my loop script is:
>
>
> $query = ("select * from table");
> $result = mysql_query($query);
> while ($row = mysql_fetch_row($result))
> $number = mysql_numrows($result);
>
>
> $i = 0;
> while ($i < $number):
> $date = mysql_result($result, $i,$date");
>
> if ($i%2 == 0){
>
> echo "<b>$date</b>";
> if ($i%2 == 0){
> echo "$date";
> }
> $i++;
> ENDWHILE;
If the date is stored in one of MySql's date type fields, you could use
the mysql DATE_FORMAT function to format your date.
I think the logic of your looping above is a bit suspect??
--
David Robley
Temporary Kiwi!
Quod subigo farinam