Jump to content

xander85

Members
  • Posts

    71
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

xander85's Achievements

Member

Member (2/5)

0

Reputation

  1. I tried the following, but it's not working. I think I'm close though: for(i=1; i<=30; i+=2) { $("#time1000" + i ", #time1000" + i+1 ").timePicker(); }
  2. The logic is the following: 1,2 3,4 5,6 etc...
  3. The "datepicker()" function is used to make two drop-down menus into a menus that allow you to select times. I just need to repeat each line for the amount of "date picker's" I have setup. I just need to repeat the following line: $("#timeX, #timeX+1").timePicker() X amount of times. Just not sure how the for loop syntax works exactly for javascript.
  4. Hi, I'm pretty new to Javascript (have a bit of PHP experience) and have a quick loop question. I have the following code: jQuery(function() { $("#time10001, #time10002").timePicker(); $("#time10003, #time10004").timePicker(); $("#time10005, #time10006").timePicker(); $("#time10007, #time10008").timePicker(); $("#time10009, #time10010").timePicker(); $("#time10011, #time10012").timePicker(); $("#time10013, #time10014").timePicker(); $("#time10015, #time10016").timePicker(); }); Is it possible to do this with a loop? I'd like to be able to change the amount of "timepicker's" dynamically? Thanks!
  5. Sorry. I need the sequence to be the following: First iteration: value = 1 value = 2 value = 1 second iteration: value = 3 value = 4 value = 2 third iteration: value = 5 value = 6 value = 3 Thanks!
  6. Hi All, I'm jumping back into PHP and I have a basic loop question that I'm struggling with. I'm using a "date picker" code to select times during the day and then using a javascript to calculate the total hours for the day. However, I'm struggling with the loop to print out the fields. I need a loop that will print the following: first iteration: value = 1 value = 2 value = 0 second iteration: value = 2 value = 3 value = 1 The code I'm using is the following: for ($id = 1; $id <=45 ; $id++) { ?> <?php if($id % 2) { ?> <div id="labor_template_day_100"> <input type="text" name="time1000<?php echo $id; ?>""/> <input type="text" name="time1000<?php echo $id+1; ?>" /> <?php } ?> <input type="hidden" id="emp<?php echo $id-1; ?>hours" value="0"/> <?php if($id % 2) { ?> </div> <?php } } This prints: first iteration: value = 1 value = 2 value = 0 Inserts just a hidden form field, then: value = 1 value = 2 value = 2 See below: <div id="labor_template_day_100"> <input type="text" name="time10001" id="time10001" size="7" value="06:00 AM" onChange="CalcHrs('time10001', 'time10002', '0');"/> <input type="text" name="time10002" id="time10002" size="7" value="06:00 AM" onChange="CalcHrs('time10001', 'time10002', '0');" /> <input type="hidden" id="emp0hours" value="0"/> </div> <input type="hidden" id="emp1hours" value="0"/> <div id="labor_template_day_100"> <input type="text" name="time10003" id="time10003" size="7" value="06:00 AM" onChange="CalcHrs('time10003', 'time10004', '2');"/> <input type="text" name="time10004" id="time10004" size="7" value="06:00 AM" onChange="CalcHrs('time10003', 'time10004', '2');" /> <input type="hidden" id="emp2hours" value="0"/> </div> <input type="hidden" id="emp3hours" value="0"/> I have a feeling this is something basic I need to change.
  7. OK quick follow up statement: I tried this query: SELECT CASE dow when "1" then "Entered" END from daily where storeid = '7' and wedate = '2010-04-20' and it returns: CASE dow when "1" then "Entered" END NULL NULL NULL NULL NULL Entered NULL However, if I run the following: SELECT * FROM `daily` WHERE `storeid` =7 AND `wedate` = '2010-04-20' AND `dow` = '1' It only returns 1 row. Why does my case statement return 7 rows? The column "dow" is an enum with values 0, 1, 2, 3, 4, 5, 6, 7. Do I need to add something else to the CASE statement so force it to only check where "dow" = 1? Thanks!
  8. I wasn't aware of the CASE statement and it looks to be a perfect solution. Thanks!
  9. Hi All, I'm fairly new to MySQL and just want to make sure I wrote some good code for an important part of my project before it is released to dozens of users and I don't want it to be a performance bottleneck. Here is what I'm trying to do: -Alert users on login of data that has not been submitted (application requires daily entries for each user) I'm trying to figure out what the best way to write this: 1) Is it possible to run a query that tells me which columns in a table are empty? (i.e. entries for, say, Mon, Wed, Thur, Fri are empty) 2) Should I create a table for each user that tracks this on a weekly or bi-weekly basis? 3) Or should I just run a query on the table that needs to be updated each time the user logs in? I'm trying to figure out the best way to alert a user when data needs to be entered, but I don't want run excess queries. Right now the only way I know how to check if columns are empty in X rows is to run a query on each row and use mysql_num_rows? (So this could be potentially 6 queries on login for each user) Thanks!
  10. My response from the server is in XML format, not just HTML. I tried using that but it returns "undefined".
  11. Hi, I'm using a simple Ajax script that grabs some MySQL data, create an XML tag, and displays in a <span> tag. This works fine. However, when I try to pass html code it doesn't work. So I tried the <![CDATA[ tag and when I look at the raw XML output it looks fine: <LaborValue> <type>addons</type> <addons>Add-ons WTD: $600 </addons> <variance>(33.3% <img src='images/up-arrow.png'>)</variance> </LaborValue> However, the image doesn't actual show up on my page. Anything after the <![CDATA[ tag actually shows up. Do I need to send the HTML in a different way to actually display the image? The following is the ajax code that actual displays the xml on the page: document.getElementById("lcvalue_addons").innerHTML=xmlDoc.getElementsByTagName("addons")[0].childNodes[0].nodeValue + xmlDoc.getElementsByTagName("variance")[0].childNodes[0].nodeValue; Thanks!
  12. Hi All, I posted this in the MySQL help as well, but looking for a possible PHP solution, if it is better. I have some PHP/MySQL experience, but I've been out of the "game" for a few years and I'm a bit rusty. I'm using the latest version of MySQL, but still not sure if I want I'm trying to do is possible OR i can do these efficiently with PHP: I want to select and sum all rows for my "actual_sales" column for the last week and month in one query. Is this possible? I'm currently using the following code to select the last week (ignore the date shift, my program starts it's week on Wed): SELECT storeid AS store, (SELECT storenum FROM store WHERE storeid=store) AS storenum, (SELECT name FROM store WHERE storeid=store) AS name, wedate, SUM(actual_sales) AS sales, cust_count FROM `daily` WHERE wedate > '2010-03-09' AND wedate <= '2010-03-16' GROUP BY storeid, wedate ORDER BY sales DESC And the following to return the last month: SELECT storeid AS store, (SELECT storenum FROM store WHERE storeid=store) AS storenum, (SELECT name FROM store WHERE storeid=store) AS name, wedate, SUM(actual_sales) AS sales, cust_count FROM `daily` WHERE month(wedate) = (MONTH(CURDATE()) - 1) GROUP BY storeid ORDER BY sales DESC These both work fine and return the sum of the "actual_sales" column for each "storeid", but I want to know if it's possible to put these two queries together? I want to be able to display the last week's sales for each store (sorted by highest sum), then compare to the last month's sales for the same store, regardless of it being sorted (because one store could have had higher sales the previous month). Thanks!
  13. Hi All, I have some MySQL experience, but I've been out of the "game" for a few years and I'm a bit rusty. I'm using the latest version of MySQL, but still not sure if I want I'm trying to do is possible: I want to select and sum all rows for my "actual_sales" column for the last week and month in one query. Is this possible? I'm currently using the following code to select the last week (ignore the date shift, my program starts it's week on Wed): SELECT storeid AS store, (SELECT storenum FROM store WHERE storeid=store) AS storenum, (SELECT name FROM store WHERE storeid=store) AS name, wedate, SUM(actual_sales) AS sales, cust_count FROM `daily` WHERE wedate > '2010-03-09' AND wedate <= '2010-03-16' GROUP BY storeid, wedate ORDER BY sales DESC And the following to return the last month: SELECT storeid AS store, (SELECT storenum FROM store WHERE storeid=store) AS storenum, (SELECT name FROM store WHERE storeid=store) AS name, wedate, SUM(actual_sales) AS sales, cust_count FROM `daily` WHERE month(wedate) = (MONTH(CURDATE()) - 1) GROUP BY storeid ORDER BY sales DESC These both work fine and return the sum of the "actual_sales" column for each "storeid", but I want to know if it's possible to put these two queries together? I want to be able to display the last week's sales for each store (sorted by highest sum), then compare to the last month's sales for the same store, regardless of it being sorted (because one store could have had higher sales the previous month). Thanks!
×
×
  • 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.