Ell20 Posted August 6, 2008 Author Share Posted August 6, 2008 Before I make a mess of doing the other two colours, I tried your code, it dosent appear to do anything in terms of changing the colours? Quote Link to comment Share on other sites More sharing options...
DarkWater Posted August 6, 2008 Share Posted August 6, 2008 Sorry, fixed it. I messed up on a printf() parameter. xD Try it now. Quote Link to comment Share on other sites More sharing options...
Ell20 Posted August 6, 2008 Author Share Posted August 6, 2008 For some strange reason, it still dosent show up in purple. I viewed the page source and it says bgcolor="purple" on some of the TD's but it dosent show up on the screen!! Quote Link to comment Share on other sites More sharing options...
DarkWater Posted August 6, 2008 Share Posted August 6, 2008 Not sure if bgcolor is a valid td attribute, to be honest. How about: <?php echo '<tr>'; for ($row=1;$row<=80;$row++) { if (isset($_POST['submit'])) { //You don't want colors unless they actually submitted! if (in_array($row, $matched)) { $bgcolor = "purple"; } } else { $bgcolor = "white"; } printf('<td width="50" height="25" align="center" onMouseDown="changeto(event, \'%1$d\')" id="num%1$d" onMouseOver="this.style.cursor=\'pointer\'" style="background-color: %2$s;">%1$d</td>\n', $row, $bgcolor); if ($row % 8 == 0) { echo '</tr><tr>'; } } echo '</tr>'; ?> Used CSS background colors. Quote Link to comment Share on other sites More sharing options...
Ell20 Posted August 6, 2008 Author Share Posted August 6, 2008 Ok now we have colour, BUT its showing them all purple after the first one matches, so say number 10 matches, 10 - 80 are all purple! Quote Link to comment Share on other sites More sharing options...
DarkWater Posted August 6, 2008 Share Posted August 6, 2008 My bad, let me fix that. Should have realized. I'll just add the other two in for you because I feel like a nice person tonight. xD Here you go: <?php echo '<tr>'; for ($row=1;$row<=80;$row++) { if (isset($_POST['submit'])) { //You don't want colors unless they actually submitted! if (in_array($row, $matched)) { $bgcolor = "purple"; } elseif (in_array($row, $values)) { $bgcolor = "red"; } elseif (in_array($row, $nums)) { $bgcolor = "blue"; } else { $bgcolor = "white"; } } else { $bgcolor = "white"; } printf('<td width="50" height="25" align="center" onMouseDown="changeto(event, \'%1$d\')" id="num%1$d" onMouseOver="this.style.cursor=\'pointer\'" style="background-color: %2$s;">%1$d</td>\n', $row, $bgcolor); if ($row % 8 == 0) { echo '</tr><tr>'; } } echo '</tr>'; ?> Quote Link to comment Share on other sites More sharing options...
Ell20 Posted August 6, 2008 Author Share Posted August 6, 2008 Thanks so much for your help! I have one last issue and that is, is there anyway to use the same user values each time the submit button is pressed until the user leaves the page or presses the "reset" button?? Quote Link to comment Share on other sites More sharing options...
DarkWater Posted August 6, 2008 Share Posted August 6, 2008 What do you mean? EDIT: Gotta go, but I'll check on the topic tomorrow, sorry. >_< Quote Link to comment Share on other sites More sharing options...
Ell20 Posted August 6, 2008 Author Share Posted August 6, 2008 Dont worry I have worked it out, I used hidden variables to store them then if they just press submit again it submits the same values Appreciate all the help! Quote Link to comment Share on other sites More sharing options...
Ell20 Posted August 6, 2008 Author Share Posted August 6, 2008 Having tested it quiet a few times, every so often I get this error: Warning: Invalid argument supplied for foreach() in /home/streety/public_html/keno.php on line 43 Then the following printed lots of times: Warning: in_array() [function.in-array]: Wrong datatype for second argument in /home/streety/public_html/keno.php on line 91 Any ideas what might be causing this? Cheers Quote Link to comment Share on other sites More sharing options...
Ell20 Posted August 6, 2008 Author Share Posted August 6, 2008 Ok, I have managed to work out that this happens when there are no matches (purple). However I am unsure on how to stop this occuring? Cheers Quote Link to comment Share on other sites More sharing options...
DarkWater Posted August 6, 2008 Share Posted August 6, 2008 Ah yeah, should have checked that. Add: $matched = array(); Above the foreach ($values as $key=>$value) { line. Quote Link to comment Share on other sites More sharing options...
Ell20 Posted August 6, 2008 Author Share Posted August 6, 2008 Excellent, thats solved that! Thanks alot for your help! Couldnt of done it without your help, or would of taken me alot longer with much more code!! Cheers 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.