-
Posts
24,609 -
Joined
-
Last visited
-
Days Won
832
Everything posted by Barand
-
How to get form nested in while loop to work?
Barand replied to innovatio's topic in PHP Coding Help
My suggestion also included putting the hidden field, containing the id, inside the form. -
Datetime functions differ greatly between sqlsrv and mysql. I'd start by looking there. Check sqlsrv_error array after calling the query
-
Good evening - Money waiting for support on updating a function please
Barand replied to sorn53's topic in PHP Coding Help
You don't even need to write a script - a single update query will do it. Add a new DATETIME column (eg 'newdate') to the table to store the new date first. UPDATE dbb SET newdate = STR_TO_DATE(expiredate, '%m-%d-%Y-%H:%i') -
Getting mysql data to work with array script.
Barand replied to xwishmasterx's topic in PHP Coding Help
try $conn = new mysqli(HOST,USERNAME,PASSWORD,'test'); $data = array(); $sql = "SELECT date, a, b FROM mytable"; $res = $conn->query($sql); while (list($date, $a, $b) = $res->fetch_row()) { $data['A'][] = array($date, $a); $data['B'][] = array($date, $b); } -
How to get form nested in while loop to work?
Barand replied to innovatio's topic in PHP Coding Help
You have two <form> tags, one at the start of the loop and another just before the submit buttom. Suggest you put the hidden id field after the second and remove the first. -
<?php $db = new mysqli(HOST,USERNAME,PASSWORD,'test'); $newarray = [11=>[],12=>[],1=>[],2=>[],3=>[],4=>[],5=>[],6=>[],7=>[],8=>[],9=>[],10=>[]]; $data = []; $trows = ''; /********************************************************** * store data in array by course ***********************************************************/ $sql = "SELECT c.cid , c.courseName , e.startDate , MONTH(e.startDate) as month FROM course c LEFT JOIN eventtbl e USING (cid) ORDER BY cid,startDate"; $res = $db->query($sql); while (list($cid, $cn, $sd, $m) = $res->fetch_row()) { if (!isset($data[$cid])) { $data[$cid]['name'] = $cn; $data[$cid]['events'] = $newarray; } if ($sd) $data[$cid]['events'][$m][] = date('j/m/Y', strtotime($sd)); } /********************************************************** * create table from array data ***********************************************************/ foreach ($data as $cid=>$cdata) { $trows .= "<tr><td>$cid</td><td class='cn'>{$cdata['name']}</td>"; foreach ($cdata['events'] as $dates) { $trows .= "<td class='dt'>" . join('<br>', $dates) . "</td>"; } $trows .= "</tr>\n"; } ?> <html> <head> <title>Example</title> </head> <style type='text/css'> table { border-collapse: collapse; } tr { vertical-align: top; } td, th { font-family: sans-serif; font-size: 9pt; padding: 3px; } td.cn { width: 120px; } td.dt { width: 70px; text-align: right; } </style> <body> <table border='1'> <tr> <th rowspan='2'>Course</th> <th rowspan='2'>Course Name</th> <th colspan='3'>Q1</th> <th colspan='3'>Q2</th> <th colspan='3'>Q3</th> <th colspan='3'>Q4</th> </tr> <tr> <th>November</th><th>December</th><th>January</th> <th>February</th><th>March</th><th>April</th> <th>May</th><th>June</th><th>July</th> <th>August</th><th>September</th><th>October</th> </tr> <?=$trows?> </table> </body> </html>
-
Good evening - Money waiting for support on updating a function please
Barand replied to sorn53's topic in PHP Coding Help
As I told you, that format doesn't work, echo date('Y-m-d H:i:s', strtotime("06-09-2015-12:00")) //---> 2015-09-06 13:00:00 which is why I suggested DateTime::createFromFormat('m-d-Y-H:i', $expiredate); -
Good evening - Money waiting for support on updating a function please
Barand replied to sorn53's topic in PHP Coding Help
You should always store datetimes in a DB as type DATETIME, format YYYY-MM-DD HH:MM:SS. Other formats are largely useless. For now, if you are stuck with that "-" you can $expiredate = "06-09-2015-12:00"; $dtobj = DateTime::createFromFormat('m-d-Y-H:i', $expiredate); $expiretime = $dtobj->getTimestamp(); -
Good evening - Money waiting for support on updating a function please
Barand replied to sorn53's topic in PHP Coding Help
why the weird datetime format? If that is m-d-y format then just losing the "-" between date and time will work without the preg_replace()s $expiredate = "06-09-2015 12:00"; $expiretime = strtotime($expiredate); -
You think? How much testing did you do? mysqli_num_rows() returns a number (which may be 0) and not a boolean true/false result mysqli_error() tales the $conn object as its parameter, not the result object. getting no records returned is not an error, so there would be no message to echo in that event. You need to take a look in the manual more often.
-
There may be confusion here between basename() and dirname() $dir = " /home/public_html/folder_here/another_folder"; echo basename($dir).'<br>'; //--> another_folder echo dirname($dir).'<br>'; //--> /home/public_html/folder_here
-
There is no universal "correct" way. It all depends on your specific needs.
-
What file? There is no mention of files in your code. By "previous" do you mean the folder that the file was in before being moved to its current location?
-
SELECT GROUP_CONCAT(NULLIF(Other_type, 'All_other') as projtype2, ...
-
try <table border="1"> <tr><th>Rate</th><th>Annual Interest</th><th>Monthly Interest</th></tr> <?php $amount = 50000; for ($i=1; $i<=10; $i++) { $rate = $i/100; $annual = '$' . number_format($amount * $rate, 2); $month = '$' . number_format($amount * $rate / 12, 2); echo "<tr><td>{$i}%</td><td>$annual</td><td>$month</td></tr>"; } ?> </table>
-
There is a solution to similar problem here http://forums.phpfreaks.com/topic/298003-data-display-in-wrong-column/?do=findComment&comment=1520058
-
Json_encode format problem with Google Charts
Barand replied to bambinou1980's topic in PHP Coding Help
I gave you the code for using your query with Google charts two days ago http://forums.phpfreaks.com/topic/297975-php-encode-to-json-help-with-morrisjs-please/?do=findComment&comment=1520002 -
$loadSession will contain either a valid result object or, if the query failed, the boolean value "false" Your query failed - check the value given by $con->error
-
You probably get 0000-00-00 because 3/15/2014 is m/d/y and you are trying to convert from d/m/y, so getting invalid dates. Also, you left the "/"s out of your formatting string
-
You store data for efficiency, not for their appearance to the user. You are confusing relational database tables with spreadsheets. You have your code in between the db and the user, so you can present it any way you want, totally independent of the way it is stored. Use relational joins to get data from several tables with a single query.