Uutiset:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu
Advertisement:

How to convert sqldata to html using php

Aloittaja fenris_w0lf, tammikuu 31, 2006, 08:20:15 IP

« edellinen - seuraava »

fenris_w0lf

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 [nofollow]

* 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!!!

fenris_w0lf

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.

fenris_w0lf

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

safetythird

Have a look at hxxp:us2.php.net/date [nonactive].

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!

fenris_w0lf

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!!



Advertisement: