Jump to content

PHP - MYSQL help. pull info from 2 tables


flemingmike

Recommended Posts

hi, i need help with a code.  i thought this would work:

 

$compare=mysql_query("SELECT ladderid,teamid FROM membersteam WHERE memberid='{$_COOKIE['user']}'");

 

and

 

$totalchall=mysql_query("SELECT COUNT(*) FROM challenges WHERE challgrid='$compare[id]' OR challgdid='$compare[id]'");
$totalchall=mysql_fetch_array($totalchall);
$totalchall="$totalchall[0]";

if($totalchall == 0){
$out[body].="<tr bgcolor='$config[altcolora]'>
<td width='100%' valign='center' align='center' colspan='5' background='$config[cellbg]'>No outstandings challenges.</td></tr>";
}else{
$challenges=mysql_query("SELECT challid,challgrid,challgdid,challgrname,challgdname,DATE_FORMAT(created,'%M %d at %l:%i %p') FROM challenges WHERE challgrid='$compare[id]' OR challgdid='$compare[id]' ORDER BY created DESC");
while(list($challid,$challgrid,$challgdid,$challgrname,$challgdname,$created)=mysql_fetch_row($challenges)){

Link to comment
https://forums.phpfreaks.com/topic/149759-php-mysql-help-pull-info-from-2-tables/
Share on other sites

maybe this makes more sence... ?

 

$totalchall=mysql_query("SELECT COUNT(*) FROM challenges WHERE challgrid,ladderid='$compare[teamid,ladderid]' OR challgdid,ladderid='$compare[teamid,ladderid]'");
$totalchall=mysql_fetch_array($totalchall);
$totalchall="$totalchall[0]";

if($totalchall == 0){
$out[body].="<tr bgcolor='$config[altcolora]'>
<td width='100%' valign='center' align='center' colspan='5' background='$config[cellbg]'>No outstandings challenges.</td></tr>";
}else{
$challenges=mysql_query("SELECT challid,ladderid,challgrid,challgdid,challgrname,challgdname,DATE_FORMAT(created,'%M %d at %l:%i %p') FROM challenges WHERE challgrid,ladderid='$compare[teamid,ladderid]' OR challgdid,ladderid='$compare[teamid,ladderid]' ORDER BY created DESC");
while(list($challid,$ladderid,$challgrid,$challgdid,$challgrname,$challgdname,$created)=mysql_fetch_row($challenges)){

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.