Jump to content

dtyson2000

Members
  • Posts

    93
  • Joined

  • Last visited

Everything posted by dtyson2000

  1. Ok. I need to wrap my head around this. Thank you very much for pointing me in the right direction. I really had no idea. I've always done it the way I've always done it. I guess it's time for a change - and to start reading! Thank you, again!
  2. Thank you for your response. In the last thread, I did exactly as it seemed I was being told. Removed the delimited list of values and threw them up in columns (as mentioned above) in an almost excel sort of format. Item 1, Item 2, Item 3, under which I simply added a value of T where applicable. Each ROW consists of an id, a name, a date, item 1, item 2, item 3... again with the last three having either a null value or a value of T (which, yes, I will change to a boolean type). I'm just not sure where I'm going wrong and REALLY want to be up to speed. Your response points me in a direction. But I'm just not sure how what I'm doing is not storing each piece of data in a row? id | name | date | item1 | item2 | item3 1 dave Y-m-d T NULL NULL 2 Ann Y-m-d NULL T NULL etc.
  3. Hello. Just a quick question about using a loop to create a string from post variables that will then be used in a query. I have several post variables submitted in a form, some of which contain a value of T. Others are not selected. In the database there are several columns which may contain values of T or may not. I would like to construct a query that searches for specific columns containing T and ignoring the rest. I'm using WHERE "T" IN(colnames). I need to get the column names into a comma separated string. Here's what I'm using: $postVal = array("1", "2", "3", "4", "5"); foreach ($postVal as $key=>$val){ $newVar = “col”.$val; if ($$newVar == "T") { *create/add to comma-separated string } else { *ignore } } I hope that seems clear enough. I'm just not sure if I'm on the right track or not. What do you think? Thank you, in advance!
  4. Well. Yes. I meant columns. Each column represents, say, an item. Each person can select one item or a combination of items but only one of each. Those items will not change. Is it bad form to make them columns in this way? ID |NAMELAST |NAMEFIRST |1 |2 |3 |4 |5 |A 1 |DOE |JOHN |1 | |1 |1 | | 2 |DOE |JANE | |1 |1 | | |1 3 |DOE |SALLY |1 |1 | | |1 | I know it's not php help so if it's more appropriate to have the discussion elsewhere, I'm good with that. Thanks for your insight!
  5. Advice taken. I switched it to columns. Makes more sense and a whole lot easier! Thanks!
  6. Yep. That was it. Thank you! I found the white-space and everything works as needed. I am interested in your comment on doing it as a separate row in the table for each checkbox. Is this a speed concern, just bad form, or something else?
  7. I have the following in a form that edits values already put into a dbase. $alev = array(1 => '1', 2 => '2', 3 => '3', 4 => '4', 5 => '5', 6 => 'AP'); $dblev = explode(',',$row['hw_lev']); foreach ($alev as $key => $lev){ if(in_array($lev,$dblev)){ echo "<input type='checkbox' name='ud_lev[]' value='$lev' checked> $lev"; } else { echo "<input type='checkbox' name='ud_lev[]' value='$lev'> $lev"; } When I attempt to edit the dbase values, the following occurs: When I select the "A" checkbox, it is input into the database and reflects in the results. When I attempt to edit this, the "A" box is checked and all is well. When I select anything else AND "A" ("1", "A"), it is input into the database and reflects in the results. When I attempt to edit this, the "1" box is checked but the "A" box is NOT checked. This is what I need. I feel like the problem is with the array? But it could be the loop.. Probably something totally staring me in the face. You know how it goes. I was wondering if you see a problem in the array or in the loop. Any thoughts would be appreciated!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.