Jump to content

Using PHP to grab info from IPB DB

Guest ICE-Lark

Recommended Posts

Guest ICE-Lark

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..
Link to comment
Share on other sites

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 [b]cached[/b] 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!

Link to comment
Share on other sites

Guest ICE-Lark
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.
Link to comment
Share on other sites

Guest ICE-Lark
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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.