sillysillysilly Posted July 22, 2009 Share Posted July 22, 2009 Sorry to bother you guys so late at nigth but I have a problem (besides women, drinking, global warming and women) I have a script where I want to pass data to an array; later I will check to see if some of the data is in the database based on a date in a form using check boxes. Basicly I am creating a series of checkboxes based on a datename. I can create them once, but later when I call that same variable array there is nothing there. Here is a snippet of my code. while ($i <15){ $inputmorning= array( $i => "Morning <input type='checkbox' name='$orderdate morning' value='' /> "); echo $inputmorning[$i]; $inputafternoon= array($i => "<input type='checkbox' name='$orderdate afternoon' value=''/> "); echo $inputafternoon[$i]; $inputafterevening= array($i => "<input type='checkbox' name='$orderdate evening' value=''/> "); $i++; } Later I try to recall all of those same check boxes with. $i=0; while ($i<14){ $date = mktime(0,0,0,date("m"),date("d")+$i,date("Y")); $orderdate = date("Y/m/d", $date); echo "<tr><td>".$orderdate . "</td><td>$inputmorning[$i]</td><td>$inputafternoon[$i]</td><td>$inputevening[$i]</td></tr>"; //echo "<tr><td>".$orderdate . "</td><td>test $i</td><td>test $i</td><td>test $i</td></tr>"; $i++; } the date shows up, but no check boxes. Any ideas. (on the script - I'm not sure anyone can help us on the global warming or women) Quote Link to comment Share on other sites More sharing options...
Bendude14 Posted July 22, 2009 Share Posted July 22, 2009 have you checked the HTML source code to see whats appearing? you might need to use htmlentities when printing the data back to the page. As for Global warming - Who cares lol? as for Women the secret is to keep swapping the old out with the new, example if($women['days']) < 7) { keepDating(); } else { findNewWomen("blonde", "bigtits"); } Ben Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted July 22, 2009 Share Posted July 22, 2009 Let's change how you create the arrays: <?php $inputmorning = array(); $inputevening = array(); $inputafterevening = array(); for ($i=0;$i<15;$i++) { $inputmorning[$i] = "Morning <input type='checkbox' name='$orderdate morning' value='' /> "; $inputafternoon[$i] = "<input type='checkbox' name='$orderdate afternoon' value=''/> "; $inputevening[$i] = "<input type='checkbox' name='$orderdate evening' value=''/> "; } echo '<pre>' . print_r($inputmorning,true) . "\n" . print_r($inputafternoon,true) . "\n" . print_r($inputevening,true) . '</pre>'; //debug ?> rest of code redone: <?php for ($i = 0;$i<14;$i++) { $orderdate = date("Y/m/d",strtotime("+ $i days")); echo '<tr><td>' . $orderdate . '</td><td>' . $inputmorning[$i] . '</td><td>' . $inputafternoon[$i] . '</td><td>' . $inputevening[$i] . "</td></tr>\n"; } ?> Now I will ask you what you're trying to accomplish, since it looks like you've overthought it. Ken Quote Link to comment Share on other sites More sharing options...
sillysillysilly Posted July 22, 2009 Author Share Posted July 22, 2009 ben, Now that is really funny. I would put 'days' at closer to 40. My wife would get so mad at me for that especially since she is about to download brian 1.1 in a few months!! Ken Thanks I have not tried it yet, I had tried a version of just setting the $inputmorning = array(); first but did not work. What I am trying to do is to set up a series of checkboxes that will display in a table somewhat like a calander, then ask the database if any dates on orders matches those dates in the checkboxes. Based on true or false I will make them checked. (the customer can add more days if they wish or delete days). This is a stop gap measure until I can figure out a piece of javascript that I found that has sticky days. Here is what I want it to look like now. Date Morning Afternoon Evening 2009 july 21 X 2009 july 22 X X 2009 july 23 X X X 2009 july 24 X X Quote Link to comment Share on other sites More sharing options...
sillysillysilly Posted July 22, 2009 Author Share Posted July 22, 2009 Ken The first part really did the trick, I can't figure out what I was doing wrong with my first attempt, you are obviously way better at this than I am.... Want a quick coding job/? I edited the first half to show what you helped with there and all the boxes showed up, even without editing the bottom section. Now my next task is to convert this into checked boxes where corresponding dates exist in the database. I really do appreciate your help. 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.