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? Link to comment https://forums.phpfreaks.com/topic/118359-solved-cant-get-my-head-round-this/page/2/#findComment-609204 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. Link to comment https://forums.phpfreaks.com/topic/118359-solved-cant-get-my-head-round-this/page/2/#findComment-609208 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!! Link to comment https://forums.phpfreaks.com/topic/118359-solved-cant-get-my-head-round-this/page/2/#findComment-609214 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. Link to comment https://forums.phpfreaks.com/topic/118359-solved-cant-get-my-head-round-this/page/2/#findComment-609217 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! Link to comment https://forums.phpfreaks.com/topic/118359-solved-cant-get-my-head-round-this/page/2/#findComment-609220 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>'; ?> Link to comment https://forums.phpfreaks.com/topic/118359-solved-cant-get-my-head-round-this/page/2/#findComment-609225 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?? Link to comment https://forums.phpfreaks.com/topic/118359-solved-cant-get-my-head-round-this/page/2/#findComment-609228 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. >_< Link to comment https://forums.phpfreaks.com/topic/118359-solved-cant-get-my-head-round-this/page/2/#findComment-609231 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! Link to comment https://forums.phpfreaks.com/topic/118359-solved-cant-get-my-head-round-this/page/2/#findComment-609233 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 Link to comment https://forums.phpfreaks.com/topic/118359-solved-cant-get-my-head-round-this/page/2/#findComment-609240 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 Link to comment https://forums.phpfreaks.com/topic/118359-solved-cant-get-my-head-round-this/page/2/#findComment-609541 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. Link to comment https://forums.phpfreaks.com/topic/118359-solved-cant-get-my-head-round-this/page/2/#findComment-609739 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 Link to comment https://forums.phpfreaks.com/topic/118359-solved-cant-get-my-head-round-this/page/2/#findComment-609889 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.