Jump to content

joel24

Members
  • Posts

    760
  • Joined

  • Last visited

Everything posted by joel24

  1. you're not trying to fetch any posted records... if(isset($post_items[0])) { //should be $_POST['item_name'] since your script will be posting $_POST['item_name'] from your array if(isset($_POST['item_name'])) { //also try this so you get a grasp of what's being posted print_r($_POST);
  2. the easiest way is to loop through it in a while loop, though you can use mysql_result() to call one row... //from php.net $result = mysql_query('SELECT name FROM work.employee'); if (!$result) { die('Could not query:' . mysql_error()); } echo mysql_result($result, 2); // outputs third employee's name ## or you could do this instead $result = mysql_query('SELECT name, email FROM work.employee'); if (!$result) { die('Could not query:' . mysql_error()); } echo 'name: '.mysql_result($result, 2,'email'); // outputs third employee's email echo 'email: '.mysql_result($result, 2,'name'); // outputs third employee's name
  3. could you use a group by in your sql query to group it by weeks? SELECT SUM(cost) FROM table WHERE strtotime BETWEEN $first_date AND $last_date GROUP BY WEEK(from_unixtime(strtotime)) otherwise select it all into PHP and use PHP to iterate through each and have an array with totals, and add the cost to the corresponding array index... $query="SELECT cost, strtotime FORM table WHERE strtotime BETWEEN $first_date AND $last_date"; $weeks=array(); WHILE ($row=mysql_fetch_assoc($query)){ $currentWeek=date('W',$row['strtotime']); $weeks[$currentWeek]+=$row['cost']; } have a play around... should help with the groundwork?
  4. if it's working only sometimes, then there must be no blog entries for some... check to see if results returned with mysql_num_rows() $query = mysql_query("SELECT content FROM blog WHERE title = '".$title."' ORDER BY date DESC"); if (mysql_num_rows($query) { #now do the fetch while ($row = mysql_fetch_array($query)){ #etc etc }
  5. sorry, my bad #get unix timecode of dates (seconds past since 1st Jan 1970) - ensure they are either d-m-y or m/d/y $start=strtotime($_POST['startDate']); $end=strtotime($_POST['endDate']); #subtract start from end and divide by seconds in day to determine days... $days = ($end-$start) / (60*60*24); echo $days;
  6. you're not posting the duration across... you need to add the value to a form element using javascript or you can use PHP to determine the days between... You'll need to use a '-' as a seperator rather than '/' - this tells the strtotime() function that it will be a european date format (d-m-y) rather than american (m/d/y) #get unix timecode of dates (seconds past since 1st Jan 1970) - ensure they are either d-m-y or m/d/y $start=strtotime($_POST['startDate']); $end=strtotime($_POST['endDate']); #subtract start from end and divide by seconds in day to determine days... $days = $end-$start / (60*60*24); echo $days;
  7. try add this to your confirmation.php page and tell us what it prints print_r($_POST);
  8. it should be posting the dates to the confirmation.php file... does that file exist and is it located in the same directory? what code is in that file? if you want to post the difference you'll have to change <li style="list-style: none;" id="duration"></li> to <input type='text' name='duration' id='duration' /> also, you've got a superfluous " at the end of your <form> tag... <form name ="drop_list" method = "POST" action ="confirmation.php" "> //should be <form name ="drop_list" method = "POST" action ="confirmation.php">
  9. have a read of the documentation, i haven't used editablegrid before though the documentation states you can set the "modelChanged" function to update the database via AJAX. read here https://github.com/webismymind/editablegrid
  10. have a look at this function - just need to modify it to include hours/seconds... and to accept unix timestamps if you're using unix timestamps at all? - from_unixtime() http://forums.mysql.com/read.php?10,367815,367819#msg-367819 CREATE FUNCTION getDateDifferenceString(date1 DATE, date2 DATE) RETURNS VARCHAR(30) RETURN CONCAT( /* Years between */ @years := TIMESTAMPDIFF(YEAR, date1, date2), IF (@years = 1, ' year, ', ' years, '), /* Months between */ @months := TIMESTAMPDIFF(MONTH, DATE_ADD(date1, INTERVAL @years YEAR), date2), IF (@months = 1, ' month, ', ' months, '), /* Days between */ @days := TIMESTAMPDIFF(DAY, DATE_ADD(date1, INTERVAL @years * 12 + @months MONTH), date2), IF (@days = 1, ' day', ' days') ) ;
  11. use a multi-dimensional array... i.e. $menu[1]['name']='Finance'; $menu[1][x]='Item'; $sql=@mysql_query("SELECT * FROM tableName ORDER BY IFNULL(parent_id,0)"); $menu=array(); while ($row=mysql_fetch_assoc($sql)) { if (is_null($row['parent_id'])) { $menu[$row['id']]['name']=$row['menu_name']; } else { $menu[$row['parent_id'][]=$row['menu_name']; } foreach ($menu AS $m) { echo "<ul><li>{$m['name']}"; if (is_array($m) { echo "<ul>"; foreach ($m AS $m2) { echo "<li>$m2</li>"; } echo "</ul>"; } echo "</li></ul>"; } html may be wrong but you get the idea...
  12. try running print_r($_GET) and print_r($_SESSION) and see what variables are set are you starting the session properly/including the session() class you call?
  13. or even using a foreach $bcc=array; foreach ($_POST as $key=>$value) { if (strpos($key,'email')!==false && !empty($value)) { $bcc[]=$value; } } $bcc=implode(",",$bcc);
  14. if the insert always follows that formatting, $ret = $html->find('table[class=data] tr'); foreach($ret as $visitor){ $visitor = $visitor->find('td','1') . "<br>"; $replaceArray=array('<td colspan="1" rowspan="1" style="text-align: left;"><a style="border-bottom:1px dotted;" onclick="loadTeamSpotlight(jQuery(this));" rel="HEN" href="javascript:void(0);">','</a></td><br>'); $visitor=str_replace($replaceArray,'',$visitor); $insert="INSERT INTO $dbtable (visitor) VALUES ('$visitor')"; mysql_query($insert) OR die(mysql_error()); } ##TEST## $string='<td colspan="1" rowspan="1" style="text-align: left;"><a style="border-bottom:1px dotted;" onclick="loadTeamSpotlight(jQuery(this));" rel="HEN" href="javascript:void(0);">HENRY</a></td><br>'; $replaceArray=array('<td colspan="1" rowspan="1" style="text-align: left;"><a style="border-bottom:1px dotted;" onclick="loadTeamSpotlight(jQuery(this));" rel="HEN" href="javascript:void(0);">','</a></td><br>'); $string=str_replace($replaceArray,'',$string); echo $string;
  15. use strtotime('12am') to get the unix timestamp for midnight, then minus the current from that $midnight = strtotime('12am'); $current=time(); $count=$midnight-$current; //convert seconds to hours etc have a look at this function to convert seconds to hours http://www.laughing-buddha.net/php/lib/sec2hms/
  16. I'm currently writing a Java applet to access and scan wifi networks and I need to execute the netsh with the parameters "wlan show networks mode=bssid". The script is being run from a HTML page and so the Applet is limited to the sandbox environment. What would be the best way to grant permissions to execute said command? At the moment I'm getting warnings when compiling the class, sorry this is my first Java applet - feel free to point me toward any relevant tutorials? and the current code public static void testing() { AccessController.doPrivileged(new PrivilegedAction() { public Object run() { try { // Run "netsh" Windows command Process process = Runtime.getRuntime().exec("netsh.exe wlan show networks mode=bssid"); // Get input streams BufferedReader stdInput = new BufferedReader(new InputStreamReader(process.getInputStream())); BufferedReader stdError = new BufferedReader(new InputStreamReader(process.getErrorStream())); // Read command standard output String s; System.out.println("Networks Found: "); while ((s = stdInput.readLine()) != null) { System.out.println(s); } // Read command errors System.out.println("Errors: "); while ((s = stdError.readLine()) != null) { System.out.println(s); } } catch (Exception e) { e.printStackTrace(System.err); } } }); }
  17. what about PHP's filter_var function? I'm sure there are issues, feel free to inform me. function checkEmail($email) { return filter_var($email, FILTER_VALIDATE_EMAIL); }
  18. you'll need to group by year, month, day - otherwise you'll get logins from the 2nd Jan and 2nd Feb and 2nd March etc being counted as one... for those days with no logins I would just use PHP to determine if that date had no logins, display zero...
  19. why would you want to show those days if there is no data? and why isn't there any data?
  20. couldn't you group it by month and retrieve only the last 5 months...? SELECT COUNT(date_login) FROM users_logins WHERE login_date >= NOW() - INTERVAL 5 MONTH GROUP BY MONTH(date_login)
  21. post your entire code, this should be in the CSS help section...
  22. working fine in IE8 for me, test.css .txt { color: #f0f; } test.htm <html> <head> <link rel="stylesheet" type="text/css" href="test.css" /> </head> <body> test <form> <span class="txt"> Name <input /> </span> </form> </body> </html>
  23. what have you written in your css? .myclass input { #style the input elements }
×
×
  • 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.