Jump to content

Barand

Moderators
  • Posts

    24,563
  • Joined

  • Last visited

  • Days Won

    822

Everything posted by Barand

  1. Start 6 months from current date then every 6 months. Spring if in first half of the year, Fall otherwise $today = '2014-07-01'; // used to set todays date for testing $dt1 = new DateTime($today); $dt1->add(new DateInterval('P6M')); $dt2 = clone $dt1; $dt2->add(new DateInterval('P5Y')); $dp = new DatePeriod($dt1, new DateInterval('P6M'), $dt2); // dates every 6 months for 5 years foreach ($dp as $d) { echo $d->format("Y "); if (1 <= $d->format('n') && $d->format('n') <= 6) { echo "Spring<br>"; } else { echo "Fall<br>"; } }
  2. Use the DATE() function which returns just the date portion of a datetime field eg WHERE DATE(mydatefield) = '2014-09-18'
  3. I usually produce my own "hand-rolled" charts. As production of a chart usually requires data from a DB server I produce them server-side using PHP, either as an image or using vector graphics. Producing them on the server with PHP does not preclude interaction with the user. If I require an interactive chart then I use SVG which allows me to assign mouse events to the various graphic elements (eg rectangles, circles). Of course you can make an image interactive with an image map but SVG makes it a lot easier.
  4. Add a submit button to you form. When user clicks it, it will post the selected project_name to hourssubmit.php where you can access it with $_POST['project_name']
  5. When you specify users for a MySql database you can also specify the domains from which they are allowed to access the server (or specify "%" as wildcard meaning anywhere). It sounds as though that IP is not valid for that username. You need to change the user access credentials to allow that IP address, or get an admin to do it.
  6. Your sin is not showing us what the function does and how it is being called.
  7. Delete lines 2 and 3. Just fetch and output with the while() loop. $results = mysqli_query($con, "SELECT * FROM Entries ORDER BY PID DESC LIMIT 0,8"); while ($rowFp = mysqli_fetch_array($results)) { echo "<br /><br />" . $rowFp['Title'] . "<br />" . $rowFp['remoteTime'] . "<br /><br />" . $rowFp['PID']; }
  8. Mouse clicks are handled by the browser on the client after PHP has finished executing on the server so you cannot call a PHP function directly in response to a mouse event. If you don't want to go to another page then you need to use AJAX. You should Google AJAX to find out more but, basically, you use a javascript function to send a request message to a PHP script the server in response to the click. The script executes and sends data back to the calling function which then displays it on the page.
  9. @ginerjm That's weird while() syntax you're using there
  10. I think you need to quote the keys and string values in your json array Try 'items' => '{"id":123,"species":"stud","at":"keepsake"}',
  11. Better to use a foreach() loop $db = new mysqli(HOST,USERNAME,PASSWORD,DATABASE); $sql = "INSERT INTO tbl_lg_rider_order (`name`,`card_id`,`homeaway`,`riderorder`) VALUES (?,?,?,?)"; $stmt = $db->prepare($sql); $stmt->bind_param('siss', $name,$card_id,$ha,$rideorder); foreach ($home_rider as $k => $name) { $ha = 'h'; $rideorder = $order[$k]; $stmt->execute(); } foreach ($away_rider as $k => $name) { $ha = 'a'; $rideorder = $awayorder[$k]; $stmt->execute(); }
  12. your for() syntax is wrong http://uk1.php.net/manual/en/control-structures.for.php
  13. Does it work if you assign xmlhttp.responseText instead?
  14. Writing the output to a .html file then opening that file in Word should work
  15. Or store the results in an array and use array_chunk() with a chunk size of 4 EG $sql = "SELECT user_id, username FROM user ORDER BY username"; $res = $db->query($sql); $rows = $res->fetch_all(); $chunks = array_chunk($rows, 4); foreach ($chunks as $chunk) { echo "<table border='1' cellpadding='3'> <tr><th>Id</th><th>Name</th></tr>\n"; foreach ($chunk as $row) { list($id, $name) = $row; echo "<tr><td>$id</td><td>$name</td></tr>\n"; } echo "</table><br><br>\n"; }
  16. Using the MOD() function on a numeric value eg "id" or TO_SECONDS(rec_date) should allow you to select approximately every Nth record ... WHERE MOD(id,20) = 0. mysql> SELECT * FROM test; 182685 rows in set (0.15 sec) mysql> SELECT * FROM test WHERE MOD(id,10)=0; 18268 rows in set (0.08 sec) Alternatively check why it takes a long time. 2048 recs is not a large dataset If you are doing lots of AJAX calls you will be incurring the overhead of connecting to the DB each time. Is it possible to accomplish the task in a single call?
  17. As well as the table structure the query syntax used can also affect performance and, for all we know, you could be running multiple queries inside loops. You have given us absolutely no information for us to help you.
  18. Barand

    list users

    mysqli_connnect() should only have 2 n's
  19. try $data = array(); foreach ($parse->division as $div) { $key = (string)$div['id']; $val = (string)$div; $data[$key] = $val; }
  20. Does this help? $points=array(); $arr = array_map('trim', explode("\n", $file)); foreach ($arr as $line) { list($n, $p) = sscanf($line, '%s %d'); if ($p) $points[$n] = $p; } arsort($points); echo '<pre>',print_r($points, true),'</pre>';
  21. Possibly. From the information that you have given us I am sure any of the psychics on the forum could help.
  22. When you create the selection dropdown for music styles, use SELECT ms.idstyle , style , id_user FROM music_styles ms LEFT JOIN user_styles us ON ms.id_style = us.id_style AND us.id_user = $user Those styles with a user id should be marked as "selected"
  23. you need to add parentheses echo (new DateTime('2014-09-13'))->format('d/m/Y'); //---> 13/09-2014
  24. Barand

    list users

    You can use something like this to loop through as many colours as want in the rows. Put the colours in an array and use $i++%$n as the index to select the row colour from the array (where $i is row counter and $n is the number of colours in the array) $sql = "SELECT username FROM user"; $res = $db->query($sql); $output = ''; $i = 0; // array of colour values $colours = array ('#80FFFF', '#50CFCF', '#209F9F'); $n = count($colours); while ($row = $res->fetch_assoc()) { $output .= "<tr><td style='background-color:{$colours[$i++%$n]}'>{$row['username']}</td></tr>\n"; } echo "<table style='border-collapse: collapse; width:150px' border='1' cellpadding='5'> $output </table>"; This example gives:
  25. Barand

    wdcalendar

    ... and not even a question.
×
×
  • 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.