joebudden Posted January 29, 2007 Share Posted January 29, 2007 Hi guys I've followed the phpfreaks tutorial to do this but cant seem to get it working...Here is my code[code]<?php$sql = "select name,surname,ability,fitness,teamid from player,$tempgame where player.id = $tempgame.id and gameid = '$gameid' and teamid = '$teamid'"; $res = mysql_query($sql) or die (mysql_error());$id = "select id from $tempgame where teamid = '$teamid'"; $res2 = mysql_query($id) or die (mysql_error());$color1 = "#CCFFCC"; $color2 = "#BFD8BC"; $row_count = 0;?><table border="1" width="200px"><?phpwhile(($x = mysql_fetch_assoc($res2))&&($r = mysql_fetch_assoc($res))){ $row_color = ($row_count % 2) ? $color1 : $color2; echo '<tr bgcolor="$row_color"><td>'?><a href="javascript:openWindow('information.php?id=<?php echo $x['id'];?>', 500, 400, 200, 200)"><?phpecho $r['name'].' <b>'.$r['surname'].'</b>';?></a><?php$row_count++;}?>[/code]Any ideas ??? , thanks in advance Quote Link to comment Share on other sites More sharing options...
tippy_102 Posted January 29, 2007 Share Posted January 29, 2007 Are you using CSS? If so, it may be over-riding your TR. Quote Link to comment Share on other sites More sharing options...
joebudden Posted January 29, 2007 Author Share Posted January 29, 2007 yes i am using css, but have removed my link in the head and it still doesn't work... Quote Link to comment Share on other sites More sharing options...
joebudden Posted January 29, 2007 Author Share Posted January 29, 2007 can anyone help me with this ??? its so annoying because it should be soooo simplehere is my entire page.....[code]<?php//start the games sessionsession_start(); //connect to databaseinclude("connect.php");//var containing game id$gameid = $_SESSION["gameid"];$teamname = $_SESSION['teamname'];$teamid = $_SESSION['teamid'];$tempgame = 'GAME'.$gameid;//EXIT buttonif (isset($_POST['exit'])){ $exit = "delete from game where gameid = '$gameid'";mysql_query($exit) or die (mysql_error());} ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>PHP Football Manager</title><link rel=stylesheet href="style.css" type="text/css"><script type="text/JavaScript"><!--function MM_goToURL() { //v3.0 var i, args=MM_goToURL.arguments; document.MM_returnValue = false; for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");}//--></script><script language="javascript"><!--function openWindow(url,width,height,left,top) { window.open(url, "", "width="+width+",height="+height+",left="+left+",top="+top);}//--></script></head><body><table cellpadding="0" cellspacing="0"><tr><td><div class="title"></div></td></tr><tr><td><form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"><input type="submit" name="continue" value="Continue" onclick="MM_goToURL('parent','draw.php');return document.MM_returnValue"/><input type="submit" name="exit" value="Exit" onclick="MM_goToURL('parent','start.php');return document.MM_returnValue"/><?phpif(isset($_POST["exit"])){ $delsql5 = "drop table $tempgame where gameid = '$gameid'"; mysql_query($delsql5) or die (mysql_error()); //$delsql4 = "delete from $tempgame where gameid = '$gameid'"; //mysql_query($delsql4) or die (mysql_error()); $delsql2 = "delete from team where gameid = '$gameid'"; mysql_query($delsql2) or die (mysql_error()); $delsql3 = "delete from game where gameid = '$gameid'"; mysql_query($delsql3) or die (mysql_error());}?><br /></td></tr></table></body></html><?php$color1 = "red"; $color2 = "blue"; $r_count = 0;$sql = "select name,surname,ability,fitness,teamid from player,$tempgame where player.id = $tempgame.id and gameid = '$gameid' and teamid = '$teamid'"; $res = mysql_query($sql) or die (mysql_error());$id = "select id from $tempgame where teamid = '$teamid'"; $res2 = mysql_query($id) or die (mysql_error());?><table border="1" width="200px"><?phpwhile(($x = mysql_fetch_assoc($res2))&&($r = mysql_fetch_assoc($res))){ $row_color = ($r_count % 2) ? $color1 : $color2; echo '<tr bgcolor="$row_color"><td>'?><a href="javascript:openWindow('information.php?id=<?php echo $x['id'];?>', 500, 400, 200, 200)"><?phpecho $r['name'].' <b>'.$r['surname'].'</b>';?></a><?php$r_count++;}echo '</table>';?></form>[/code] Quote Link to comment Share on other sites More sharing options...
boo_lolly Posted January 29, 2007 Share Posted January 29, 2007 this is a pretty easy thing to do... you can also search the forums for 'zebra'[code]<?php $i = 0; echo"<table>\n"; while($row = mysql_fetch_array($query)){ if($i % 2 == 0){ $alt_color = "FFFFFF"; }else{ $alt_color = "DDDDDD"; } echo "<tr bgcolor=\"". $alt_color ."\"><td>cell1</td><td>cell2</td></tr>\n"; $i++; } echo "</table>\n";?>[/code]i [i]think[/i] your problem is with your strings... try[code]echo "<tr bgcolor=\"". $rowcolor ."\">;[/code]and check your source code as well to see what's being printed. Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted January 29, 2007 Share Posted January 29, 2007 your not actually closing the <tr> and <td> tags anywhere in the loop. should you be?try echoing out the row color to see if it is doing what it is supposed to be doing. Quote Link to comment Share on other sites More sharing options...
boo_lolly Posted January 29, 2007 Share Posted January 29, 2007 [quote author=ProjectFear link=topic=124595.msg516593#msg516593 date=1170113999]your not actually closing the <tr> and <td> tags anywhere in the loop. should you be?try echoing out the row color to see if it is doing what it is supposed to be doing.[/quote]no he isnt, i think he just wants one of us to surgically inject it into his existing code for him. Quote Link to comment Share on other sites More sharing options...
rantsh Posted January 29, 2007 Share Posted January 29, 2007 [quote author=ProjectFear link=topic=124595.msg516593#msg516593 date=1170113999]your not actually closing the <tr> and <td> tags anywhere in the loop. should you be?try echoing out the row color to see if it is doing what it is supposed to be doing.[/quote]Project fear is right, you're not closing those tags... so it may actually be rendering in some browsers, but it won't work properly until you do. Quote Link to comment Share on other sites More sharing options...
joebudden Posted January 29, 2007 Author Share Posted January 29, 2007 cheers boo lolly!!!i used this [code]echo "<tr bgcolor=\"". $row_color ."\"><td>";[/code]as opposed to this...[code]echo '<tr bgcolor="$row_color"><td>';[/code]and now its working..Just for future reference what does the \ do ??? Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted January 29, 2007 Share Posted January 29, 2007 well see how you open up your echo with ". if you were to use those again in the echo then php thinks your closing the line. So to stop that you can put a \ in front of the ". Or you could do it like this:[code]echo "<tr bgcolor='{$row_color}'><td>";[/code]but it all comes down to what you want to do. :) Quote Link to comment Share on other sites More sharing options...
saiko Posted January 30, 2007 Share Posted January 30, 2007 [quote author=ProjectFear link=topic=124595.msg516611#msg516611 date=1170114681]well see how you open up your echo with ". if you were to use those again in the echo then php thinks your closing the line. So to stop that you can put a \ in front of the ". Or you could do it like this:[code]echo "<tr bgcolor='{$row_color}'><td>";[/code]but it all comes down to what you want to do. :)[/quote]that is spot on PF :)...i tend to always use " " instead of using ' ' .. Quote Link to comment Share on other sites More sharing options...
boo_lolly Posted January 30, 2007 Share Posted January 30, 2007 [quote author=joebudden link=topic=124595.msg516602#msg516602 date=1170114394]cheers boo lolly!!!i used this [code]echo "<tr bgcolor=\"". $row_color ."\"><td>";[/code]as opposed to this...[code]echo '<tr bgcolor="$row_color"><td>';[/code]and now its working..Just for future reference what does the \ do ???[/quote]i'm mighty glad it worked for ya =). for further info check out the manual on [url=http://www.php.net/manual/en/language.types.string.php]strings[/url] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.