Jump to content

Recommended Posts

Hey, I'm using IPB forum and I added a field that I need to list in a blank page.

 

Because of some function or what ever in mysql, I need to get a list of member_id I want, and after with these id, I need to list the field_13... so if anyone can tell me what is wrong in my code please =D

 

<?php
// Secret Mysql Connect xD


$query = "SELECT member_id FROM ipb_members WHERE member_group_id=7 or member_group_id=4 or member_group_id=6";
$result = mysql_query($query) or die('Error : ' . mysql_error());
while(list($member_id) = mysql_fetch_array($result, MYSQL_NUM)){


$id = "member_id=$member_id or "; // there is an or at the end of my mysql request... maybe my problem
          
$query2 = "SELECT field_13 FROM ipb_pfields_content WHERE '$id'";
$result2 = mysql_query($query2) or die('Error : ' . mysql_error());
while(list($field_13) = mysql_fetch_array($result2, MYSQL_NUM))
{
echo "$field_13<br />";
}
}

?>

Link to comment
https://forums.phpfreaks.com/topic/173980-solved-need-help-with-mysqlphp/
Share on other sites

<?php
$query = "SELECT member_id FROM ipb_members WHERE member_group_id=7 or member_group_id=4 or member_group_id=6";
$result = mysql_query($query) or die('Error : ' . mysql_error());

$ids = array();
while(list($member_id) = mysql_fetch_array($result, MYSQL_NUM)){
$ids[] = "'{$member_id}'";
}
$id = implode(',',$ids);
$query2 = "SELECT field_13 FROM ipb_pfields_content WHERE member_id IN ({$id})";
$result2 = mysql_query($query2) or die('Error : ' . mysql_error());
while(list($field_13) = mysql_fetch_array($result2, MYSQL_NUM)) {
echo $field_13."<br />";
}
?>

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.

Guest
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.