Jump to content

dtyson2000

Members
  • Posts

    93
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

dtyson2000's Achievements

Member

Member (2/5)

1

Reputation

  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!
  8. That's the ticket. I swear I tried something similar but messed something up. I think it was the [$i] in the echo. I think I recall doing it but just putting , which threw an error of course. Then I became so "cornfused" that I tried 17 different things before asking. Thank you so much for your time and for enlightening me!
  9. Hello. I have a simple SQL query that returns a list of names, this is good and all is right with the world. I would like to associate a number with each person, a RANDOM number that will change each time I call the page. Desired result: Number | Name 18 | Jeff 2 | Tammy 12 | Steve 10 | Phil 5 | Michelle etc. etc. Pool of numbers will be from 1 to 30. Sometimes the names pool will result in 18 rows or 27 rows or any number in between. I just need to assign a number from 1 to 30 to each name that is not the same each time. Here's my loop. while ($row= mysql_fetch_array($result)) { $lastname = $row["lastname"]; $firstname = $row["firstname"]; $numbers = range(1, 30); shuffle($numbers); foreach ($numbers as $number) { } echo "<tr> <td class='results'>$number</td> <td class='results'>$firstname $lastname</td> </tr>"; } Here's the problem I'm encountering: 1) If I leave the FOREACH inside the loop, I wind up with one or two repeated $number(s). 2) If I take the FOREACH outside the loop, I wind up with the first integer from the $numbers range repeated as many times as there are names I'm just not sure how to achieve a unique designation for each name. Could someone point me in the right direction? Thanks so much!
  10. Wow. This is exactly it. I didn't expect you to write the code entirely but thank you! I'll definitely look at it and learn from it! Thanks, again!
  11. Thanks for the direction! I've done just what you said and all dates have been moved to the pulldown; however, the loop runs through each "day producing line" and the dates wind up out of order: echo "<select>"; echo "<option>SELECT A DAY</option>"; for($i=1; $i<=4; $i++){ echo "<option>".date("Y-m-d", strtotime('+'.$i.' Monday'))."</option>"; echo "<option>".date("Y-m-d", strtotime('+'.$i.' Tuesday'))."</option>"; echo "<option>".date("Y-m-d", strtotime('+'.$i.' Thursday'))."</option>"; } echo "</select>"; Produces: 2013-02-11 2013-02-12 2013-02-07 2013-02-18 2013-02-19 2013-02-14 2013-02-25 2013-02-26 2013-02-21 2013-03-04 2013-03-05 2013-02-28 Any thoughts or further direction on how to get the dates into order?
  12. Hello... I'm trying to calculate the next four Mondays, Tuesdays and Thursdays and stick each result in a select statement. So far, the best I have gotten is each date for Monday in four separate pulldowns: for($i=1; $i<=4; $i++){ echo "<select><option>"; echo date("Y-m-d", strtotime('+'.$i.' Monday')).'<br>'; echo "</select>"; } I guess the question is twofold. How do I get all of the dates in one pulldown and should I do three separate FOR statements to do it? Thanks, in advance!
  13. Hello all. I have this query: SELECT userid, namelast, namefirst, userpaid (SELECT COUNT(*) FROM login WHERE YEARWEEK(logindate) = YEARWEEK(CURDATE()) AND login.luserid = users.userid) AS wklogins, (SELECT COUNT(*) FROM login WHERE YEAR(logindate) = YEAR(CURDATE()) AND MONTH(logindate) = MONTH(CURDATE()) AND login.luserid = users.userid) AS mologins FROM users LEFT OUTER JOIN login ON users.userid = login.luserid AND !(login.logindate < CURDATE()) LEFT OUTER JOIN payments ON users.userid = payments.puserid WHERE ((DATE(login.logindate) != CURDATE()) || login.luserid IS NULL) && (users.userpaid = 'T') ORDER BY users.namelast, users.namefirst For some reason, which I can't seem to find, the joins don't seem to be happening. I definitely know that I'm getting the desired results from the primary and subqueries but I am not seeing anything joined to the resulting dataset. Do you see something wrong with this query? If you do, can you point me in the direction I need to go to fixing it? Thank you, in advance, for your help!
  14. Thanks, devilsvein... The cron job makes perfect sense. Hadn't thought of that. Good call.
×
×
  • 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.