Jump to content

Using PHP to grab info from IPB DB

  • Please log in to reply
9 replies to this topic

#1 Guest_ICE-Lark_*

  • Guests

Posted 07 October 2006 - 05:46 PM


I am webmaster of ICE-squad.com. We just purchased IPB 2.1.7. What I would like to do is use the forums database to create a squad members page.

Info I'd like to export to page:
name, joined, icq, email, age (calculated using bday_day, bday_month, bday_year), custom profile 1, custom profile 2

we have our squad members seperated in the forums two ways...first, the command of the squad are admins in the forum (group4) and the rest of the squad members are seperated into a ICE_MEMBERS group (group7)

presently, i have to write our members.htm page by hand, and its a real pain every time we add or remove a member from the squad. but if the list was exported from the forums DB, then i could do it real easily. it would be as simple as moving a member of the forums from the default MEMBERS group the the ICE_MEMBERS group.

does this make sense? 

anyway, i suck at PHP, I tried to write a script, but 6 hours of frustrations led to nothing happening. so i'm here..

#2 printf

  • Staff Alumni
  • Advanced Member
  • 889 posts

Posted 07 October 2006 - 06:33 PM

Ok, so your commanders are admins and squad members are in the ICE_MEMBERS group, so how does one distinguish what squad member belongs to what commanders group? explain that and I will give a query and a piece code that you can add to the admin CP so the cached serialized storage page can be updated every time a member is added or removed from ICE_MEMBERS group. You would use the cached serialized php page to build your members display page. Also when you answer my above question, please include your IPB version so I know what version you are working with!


#3 Guest_ICE-Lark_*

  • Guests

Posted 07 October 2006 - 09:06 PM

i, as a forum admin, assign members of the forum to groups...so i assigned our commanders to the forum admin group and i assigned our regular members to the ICE_MEMBERS group.

I think I'd like to write this myself, with your help of course. 
I have started a php page, please look it over

Obviously, you want to right-click and SAVE TARGET AS. 

I've added as many comments as I could.  Please look over it and make a few suggestions in these forums.  I'll edit the file myself.

#4 Guest_ICE-Lark_*

  • Guests

Posted 08 October 2006 - 04:33 PM


#5 trq

  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 08 October 2006 - 04:42 PM

Obviously, you want to right-click and SAVE TARGET AS.

Php does not work that way. We need to see your code.

#6 Guest_ICE-Lark_*

  • Guests

Posted 08 October 2006 - 05:16 PM

my bad
// Require
require "forums/conf_global.php"; //because this file will not be located in the forums directory.

// Connect To MySQL
mysql_connect($INFO['sql_host'], $INFO['sql_user'], $INFO['sql_pass']) or die(mysql_error());
mysql_select_db($INFO['sql_database']) or die(mysql_error());

//Get Info
$main = mysql_query("SELECT id, name, email, joined, bday_day, bday_month, bday_year FROM ibf_members WHERE mgroup=4 ORDER BY id");
$main = mysql_fetch_array($main); 
$id = $main['id'];
$name = $main['name'];
$email = $main['email'];
$join_date = $main['joined'];
$bday_day = $main['bday_day'];       //I'd like to take this info and
$bday_month = $main['bday_month'];   //calculate the age,
$bday_year = $main['bday_year'];     //but only display it as years.

$icq = mysql_query("SELECT icq_number FROM ibf_member_extra WHERE `id` = $id"); //can i grab only the admins icq?  seems like it should work. does this grab all admins or just the first?
$icq = mysql_fetch_object($icq);
$today = getdate();                     //Needed for a little arithmetic.
//Some fancy arithmetic for the age thingy.  I have no clue!
$extra_two = mysql_query("SELECT field_1, field_2, field_3, field_4 FROM ibf_pfields_content WHERE `member_id` = $id");
$extra_two = mysql_fetch_array($extra_two);
$stats = $extra_two['field_1'];
$character = $extra_two['field_2'];
$country = $extra_two['field_3'];
$state = $extra_two['field_4'];

//Some HTML for the formatting
print('<table cellspacing=0 cellpadding=0 border=1><tr>');

//Lets make the list

echo ("<td>NAME $name </td><td>JOIN $join_date</td><td>COUNTRY $country &nbsp; STATE $state </td><td>ICQ $icq </td><td>EMAIL $email </td><td>AGE $age </td><td>STATS $stats </td><td>CHARACTER $charactor </td>");

//So, can you make some minor suggestions for me?
//This is my first php script.  I have written a  
//hand-full of PERL scripts, so I thought I'd give
//this a shot.

//Finish the HTML table


#7 Guest_ICE-Lark_*

  • Guests

Posted 09 October 2006 - 12:28 PM

bump...can someone help

#8 Guest_ICE-Lark_*

  • Guests

Posted 10 October 2006 - 11:36 AM

bump, sigh :-[

#9 Guest_ICE-Lark_*

  • Guests

Posted 11 October 2006 - 11:28 AM

bump, is anybody even reading this?

#10 effigy

  • Staff Alumni
  • Advanced Member
  • 3,600 posts
  • LocationIL

Posted 12 October 2006 - 02:47 PM

For future reference, don't PM people asking them to read your post. And don't make whiny bumps either--it won't help. If anything, reclarify and try to be as verbose as possible.
Regexp | Unicode Article | Letter Database

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users