Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Aiheen aloitti: fenris_w0lf - tammikuu 31, 2006, 08:20:15 IP

Otsikko: How to convert sqldata to html using php
Kirjoitti: fenris_w0lf - tammikuu 31, 2006, 08:20:15 IP
I decided to try to code a custom Memberlist from scratch and use it as an php article, here's the code I have so far for the converting of sqldata to html:


echo'<tr><td>'. $myMember['memberName'] .'</td><td>'. $myMember['ICQ'] .'</td><td>'. $myMember['dateRegistered'] .'</td></tr>';


The headings of the table is:
Member - ICQ - Registered

This code above will generate rows with something like:

MemberA - 1234567 -1021075537
MemberB - 7654321 -1021075537

Whereas I'd like the code to actually generate html that will:

* for the column "ICQ" (smf_members.ICQ) show the "icq icon" and a <a href or something so it'll be like the one in the standard memberlist that goes: http://web.icq.com/whitepages/online?icq=xxxxxxx&img=5

* for the column "Registered" (smf_members.dateRegistered) I need to do some sort of convert to a more readable date-value, lets use YYYY-MM-DD as an example....or if you really want ..feel free to utilize the "smf_members.timeFormat" field :)

ANY help is really appreciated!!!
Otsikko: Re: How to convert sqldata to html using php
Kirjoitti: fenris_w0lf - helmikuu 01, 2006, 06:46:26 AP
Sorry,

I forgot to mention that I do have all the rest of the code fixed just fine. The sql, fetch etc etc.

Only thing I need help to is formatting the html for those two fields. ICQ and Registered.
Otsikko: Re: How to convert sqldata to html using php
Kirjoitti: fenris_w0lf - helmikuu 01, 2006, 12:18:23 IP
Finally got the ICQ one to work...most of the icq-icons are grey tho...for some reason...

<a href="http://web.icq.com/whitepages/about_me/1,,,00.html?Uin='. $myMember['ICQ'] .'" target="_blank"><img src="http://web.icq.com/whitepages/online?icq='. $myMember['ICQ'] .'&amp;img=5" alt="'. $myMember['ICQ'] .'" width="18" height="18" border="0" /></a>

I'm having difficulty displaying the date-field tho (Registered) using the members display-format....hmmm
Otsikko: Re: How to convert sqldata to html using php
Kirjoitti: safetythird - helmikuu 01, 2006, 01:42:13 IP
Have a look at http://us2.php.net/date (http://us2.php.net/date).

It looks like the number you are trying to convert is machine time, the number of seconds since 1/1/1970. You can also craft your sql query to return the date column in better format.

Cheers!
Otsikko: Re: How to convert sqldata to html using php
Kirjoitti: fenris_w0lf - helmikuu 01, 2006, 10:55:19 IP
Thanks safetythird, I missed your reply and ended up following a tip from Rasyr over at TP:

$myDateRegistered = strftime('%d %b %Y', $myMember['dateRegistered']);

Works very nicely!!