Jump to content

[SOLVED] Need help with mysql/php


icez

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 />";
}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.