Log in

View Full Version : PHP syntax problem


Adrian Schneider
01-30-2005, 05:18 PM
Could someone help me get this to work? (an onClick popup to processes something) It works for me in template, but since its inside of php tags I just get errors :( ).

/////////////////////////////////////////////////////////
// List Games ///////////////////////////////////////////
/////////////////////////////////////////////////////////
if ($_REQUEST['do'] == 'listgames')
{
$playerlist=mysql_query("SELECT * FROM game WHERE winner='$requested' OR loser='$requested' ORDER BY gameid DESC");
while($playerlist1=mysql_fetch_array($playerlist))
{
$listwinner=$playerlist1['winner'];
$listloser=$playerlist1['loser'];
$listwinnerrating=$playerlist1['winnerrating'];
$listloserrating=$playerlist1['loserrating'];
$playerlistbit .= "<tr><td>$listwinner</td><td>$listwinnerrating</td><td>$listloser</td><td>$listloserrating</td><if condition=$bbuserinfo['usergroupid'] == 6><td><a onClick=window.open('league_removegame.php?g=$list gameid&wr=$listwinnerrating&lr=$listloserrating','displayWindow','toolbar=no,s crollbars=no,width=1,height=1')/;><img src=http://www.starcraftdream.com/forums/images/league/removegame.gif></td></if></tr>";
}
eval('print_output("' . fetch_template('league_listgames') . '");');
}

miz
01-30-2005, 05:31 PM
where $requested get set ? via form,http or what ?

i think its should be $_REQUEST['requested']

also use $DB_site functions

about

$playerlistbit .= "<tr><td>$listwinner</td><td>$listwinnerrating</td><td>$listloser</td><td>$listloserrating</td><if condition=$bbuserinfo['usergroupid'] == 6><td><a onClick=window.open('league_removegame.php?g=$list gameid&wr=$listwinnerrating&lr=$listloserrating','displayWindow','toolbar=no,s crollbars=no,width=1,height=1' )/;><img src=http://www.starcraftdream.com/forums/images/league/removegame.gif></td></if></tr>";



i think you will might want to create new template with this line and then just do


eval('$playerlistbit .= "' . fetch_template('playerlistbit_template') . '";');


will be better for sure

Adrian Schneider
01-30-2005, 05:37 PM
It gets requested earlier in the page. Okay thanks, I wasn't sure how to use the .= thing incombination with templates. Your mighty helpful today. :)

miz
01-30-2005, 06:20 PM
heh np ;)
allways glad to help out

Added :

hm dont forget to replace the functions to work with $DB_site;

Adrian Schneider
01-30-2005, 07:19 PM
Will do. I have heard this from a lot of people now, what is the difference/benefit of doing it that way versus the traditional non vb way?

miz
01-30-2005, 07:56 PM
Will do. I have heard this from a lot of peoplenow, what is the difference/benefit of doing it that way versus thetraditional non vb way?

Simply put, db_mysql saves you a lot of work and time. If you use thenative functions you will be witting a lot of error checking code forthings db_mysql can handle on the fly. If you use db_mysql you spendmore time witting clean SQL, instead of witting php code to handleerrors when that SQL may fail (and it will).

All is not lost, you didn't learn the native php functions for nothing.db_mysql is built upon these functions, so just think of db_mysql as acleaner, faster, more efficient way of talking with mysql.

read this thread

https://vborg.vbsupport.ru/showthread.php?t=75207

it might help you abit.