PDA

View Full Version : Getting burnt....need help, please.


Dark_Wizard
06-02-2003, 01:19 PM
I need another pair of eyes to help me with this query, first I will list the schema of both tables,

membergames:
membergamesid
userid
gameid

games:
gameid
gamename

here is the query I'm trying to create which is listing all the available games in the games table and then using a makeyesnocode to give the option to select the game and also provide for the one the user has already selected, it's not working right (see screenshot). Here is the query I'm using:


maketableheader("Member Games");
$usergames=$DB_site->query_first("SELECT * FROM vwar_membergames WHERE userid=$userid");
$membergames=$DB_site->query("SELECT gameid,gamename FROM vwar_games ORDER BY gamename ASC");
while ($membergame=$DB_site->fetch_array($membergames)) {
$varname="$usergames[gameid]";
makeyesnocode($membergame[gamename],$usergames[gameid],$usergames[$varname]);
}


Thanks....

Neo
06-02-2003, 04:38 PM
How high does gameid numerical wise?

Dark_Wizard
06-02-2003, 06:52 PM
Today at 01:38 PM Neo said this in Post #2 (https://vborg.vbsupport.ru/showthread.php?postid=403439#post403439)
How high does gameid numerical wise?


it is set to smallint (5) and right now my highest game is gameid=20

There is nothing here that will affect my results...

Dark_Wizard
06-03-2003, 10:13 AM
Hmmm...have I stumped the anyone here?

Boofo
06-03-2003, 11:11 AM
You're pulling each part of this out of 2 different queries:

$usergames[gameid]

Can you do that?

Dark_Wizard
06-04-2003, 11:36 AM
Yesterday at 08:11 AM Boofo said this in Post #5 (https://vborg.vbsupport.ru/showthread.php?postid=403820#post403820)
You're pulling each part of this out of 2 different queries:

$usergames[gameid]

Can you do that?

Well I redid the whole thing and now it works except my alt rows look horrilbe...here is what I now have:

maketableheader("Member Games");
$result=$DB_site->query("SELECT * FROM vwar_games ORDER BY gamename ASC");
while($game=$DB_site->fetch_array($result))
{
$result2=$DB_site->query_first("SELECT COUNT(membergamesid) FROM vwar_membergames
WHERE userid='$userid' AND gameid='".$game["gameid"]."'");
echo "<tr class='".getrowbg()."'><td>".
makeyesnocode("$game[gamename]","$game[gameid]","$result2[0]")."</td></tr>\n";
}


Any ideas?

Dark_Wizard
06-04-2003, 11:50 AM
Ok...figured it out...here is the new code:

maketableheader("Member Games");
$result=$DB_site->query("SELECT * FROM vwar_games ORDER BY gamename ASC");
echo "<tr class='".getrowbg()."'>";
while($game=$DB_site->fetch_array($result))
{
$result2=$DB_site->query_first("SELECT COUNT(membergamesid) FROM vwar_membergames
WHERE userid='$userid' AND gameid='".$game["gameid"]."'");
echo "<td>".
makeyesnocode("$game[gamename]","$game[gameid]","$result2[0]")."</td>";
echo "</tr>\n";
}
doformfooter("Modify Profile","");
}