-
Posts
24,566 -
Joined
-
Last visited
-
Days Won
822
Everything posted by Barand
-
Do you have error reporting turned on? Have you checked the values of mysqli_error? I cannot do it for you.
-
Similarly, the code you just posted, the input to simplexml_load_string() is $result->GetDailyListingSummaryResult->any That should be the XML.
-
First step to debugging is to have error_reporting switched on and also check for mysqli_error values after attempting queries. Where is $resultat defined? If it isn't it should be throwing an "undefined variable" error.
-
Your data shows team as character field, yet you create a table with team name as INT and goals as varchar(). As this table contains only one field for goals, and you say you want both a count and a total, which goes in the new table (count or total). And why are you doing this at all? You can get these by query any time, you should not store data derived from the data in databases.
-
That is NOT xml, it is a var dump output of some xml data that has been processed by simplexml.
-
Can you describe what is is you are trying to do so I can make some sense of your code.
-
Help to get Json data to a comma delimited file
Barand replied to techboy992's topic in PHP Coding Help
You might want to test that solution before you go any further -
Consider this scenario. You have the following statuses 1 - not started 2 - work in progress 3 - completed. So now, anything not completed has "status < 3" and all works well with your query. You boss now tells you they are introducing new status codes 4 - temporarily on hold. 5 - cancelled status < 3 no longer gives you all those that are not completed.
-
WTF ???
-
Make sure your bind_param() has the params in the same order as the placeholders in the query
-
Help to get Json data to a comma delimited file
Barand replied to techboy992's topic in PHP Coding Help
json_decode to put it in an array. loop through the array trim tabs and spaces from field values write to csv file $arr = json_decode(file_get_contents('result.txt'),1); // create array feom json data $arr = array_filter($arr); // remove empty records $fp = fopen('result.csv','w'); // open output file foreach ($arr as $record) { $rec = array_map('trim', $record); fputcsv($fp,$rec); } fclose($fp); Your currency values should not be stored in a DB with currency symbols and comma formatting so you have some extra work to do there. -
We will try to type slowly and loudly for you
-
Use a left join. If the is no matching se record then values from the se table will be null. Use explicit A JOIN B ON condition syntax and not the FROM A,B WHERE. You can use IFNULL() to check the status SELECT ua.id , ua.security_key , ua.creation , ua.last_login , ua.f_name , ua.l_name , ua.email , ua.title , ua.org_name , ua.org_size , ua.manage_num , ua.manage_direct_num , ua.phone , IFNULL(se.status, 'No match') as status FROM user_accts AS ua LEFT JOIN sessions AS se ON se.author_id = ua.id AND se.status < ? WHERE ( $search_filter >= ? AND $search_filter <= ? ) ORDER BY $search_filter DESC
-
Don't double post. Closing this topic.
-
To use SUM() then you do need to convert mysql> SELECT SEC_TO_TIME(SUM(TIMESTAMPDIFF(SECOND,t_in,t_out))) as total --> FROM temptimes; +----------+ | total | +----------+ | 21:30:00 | +----------+
-
Or, you could just use the TIMEDIFF() function instead of those conversions mysql> CREATE TEMPORARY TABLE temptimes (t_in DATETIME, t_out DATETIME); mysql> INSERT INTO temptimes VALUES -> ('2016-07-27 08:30:00', '2016-07-27 17:45:00'), -> ('2016-07-27 19:30:00', '2016-07-28 07:45:00'); mysql> SELECT t_in, t_out, TIMEDIFF(t_out, t_in) as hrs FROM temptimes; +---------------------+---------------------+----------+ | t_in | t_out | hrs | +---------------------+---------------------+----------+ | 2016-07-27 08:30:00 | 2016-07-27 17:45:00 | 09:15:00 | | 2016-07-27 19:30:00 | 2016-07-28 07:45:00 | 12:15:00 | +---------------------+---------------------+----------+
-
+--------------+ +----------------+ +--------------------+ | team | | member | | timeworked | +--------------+ +----------------+ +--------------------+ | team_id (PK) |---+ | member_id (PK) |---+ | timeworked_id (PK) | | teamname | +--<| team_id | +--<| member_id | +--------------+ +----------------+ | timein | | timeout | +--------------------+
-
in the file you posted earlier (Fill_Id.txt) you have this line $xml = simplexml_load_string($ParseData); So it looks as though $parseData is the XML. Do you have anything similar for this new bit of data?
-
long sigh... OK, post the XML.
-
If I remove the references to that method, this seems to work $data = array ( 0 => (array( 'DOCID' => '96651', 'DATERECD' => '2016-07-15T00:00:00-04:00', 'DOCKETID' => 'CP2015-102 ', )), 1 => (array( 'DOCID' => '96646', 'DATERECD' => '2016-07-15T00:00:00-04:00', 'DOCTITLE' => 'Order No. 3430 - Order Approving Modification One', 'DOCKETID' => 'CP2015-106 ', )), 2 => (array( 'DOCID' => '96645', 'DATERECD' => '2016-07-15T00:00:00-04:00', 'DOCKETID' => 'CP2015-114 ', )), 3 => (array( 'DOCID' => '96648', 'DATERECD' => '2016-07-15T00:00:00-04:00', 'DOCKETID' => 'CP2015-75 ', )), 4 => (array( 'DOCID' => '96649', 'DATERECD' => '2016-07-15T00:00:00-04:00', 'DOCKETID' => 'CP2015-76 ', )), 5 => (array( 'DOCID' => '96650', 'DATERECD' => '2016-07-15T00:00:00-04:00', 'DOCKETID' => 'CP2015-86 ', )), 6 => (array( 'DOCID' => '96652', 'DATERECD' => '2016-07-15T00:00:00-04:00', 'DOCKETID' => 'CP2015-93 ', )), 7 => (array( 'DOCID' => '96640', 'DATERECD' => '2016-07-15T00:00:00-04:00', 'DOCKETID' => 'CP2016-237 ', )), 8 => (array( 'DOCID' => '96641', 'DATERECD' => '2016-07-15T00:00:00-04:00', 'DOCKETID' => 'CP2016-238 ', )), 9 => (array( 'DOCID' => '96643', 'DATERECD' => '2016-07-15T00:00:00-04:00', 'DOCKETID' => 'CP2016-241 ', )), 10 => (array( 'DOCID' => '96653', 'DATERECD' => '2016-07-15T00:00:00-04:00', 'DOCKETID' => 'CP2016-242 ', )), 11 => (array( 'DOCID' => '96647', 'DATERECD' => '2016-07-15T00:00:00-04:00', 'DOCKETID' => 'CP2016-246 ', )), 12 => (array( 'DOCID' => '96644', 'DATERECD' => '2016-07-15T00:00:00-04:00', 'DOCKETID' => 'CP2016-3 ', )), 13 => (array( 'DOCID' => '96641', 'DATERECD' => '2016-07-15T00:00:00-04:00', 'DOCKETID' => 'MC2016-164 ', )), 14 => (array( 'DOCID' => '96643', 'DATERECD' => '2016-07-15T00:00:00-04:00', 'DOCKETID' => 'MC2016-167 ', )), ); usort($data, function($a,$b) { list($a1,$a2,$a3) = splitParts($a['DOCKETID']); list($b1,$b2,$b3) = splitParts($b['DOCKETID']); $x = strcmp($a1,$b1); if ($x == 0) { $y = $b2 - $a2; if ($y == 0) { return $b3 - $a3; } return $y; } return $x; }); function splitParts($s) { $k = strlen($s); $a = ['','','']; $i = 0; $p = 0; while ($i < $k) { $c = $s[$i++]; if (ctype_digit($c) && $p==0) $p = 1; if ($c=='-') { $c = $s[$i++]; ++$p; } $a[$p] .= $c; } return $a; } print_r ($data); giving Array ( [0] => Array ( [DOCID] => 96647 [DATERECD] => 2016-07-15T00:00:00-04:00 [DOCKETID] => CP2016-246 ) [1] => Array ( [DOCID] => 96653 [DATERECD] => 2016-07-15T00:00:00-04:00 [DOCKETID] => CP2016-242 ) [2] => Array ( [DOCID] => 96643 [DATERECD] => 2016-07-15T00:00:00-04:00 [DOCKETID] => CP2016-241 ) [3] => Array ( [DOCID] => 96641 [DATERECD] => 2016-07-15T00:00:00-04:00 [DOCKETID] => CP2016-238 ) [4] => Array ( [DOCID] => 96640 [DATERECD] => 2016-07-15T00:00:00-04:00 [DOCKETID] => CP2016-237 ) [5] => Array ( [DOCID] => 96644 [DATERECD] => 2016-07-15T00:00:00-04:00 [DOCKETID] => CP2016-3 ) [6] => Array ( [DOCID] => 96645 [DATERECD] => 2016-07-15T00:00:00-04:00 [DOCKETID] => CP2015-114 ) [7] => Array ( [DOCID] => 96646 [DATERECD] => 2016-07-15T00:00:00-04:00 [DOCTITLE] => Order No. 3430 - Order Approving Modification One [DOCKETID] => CP2015-106 ) [8] => Array ( [DOCID] => 96651 [DATERECD] => 2016-07-15T00:00:00-04:00 [DOCKETID] => CP2015-102 ) [9] => Array ( [DOCID] => 96652 [DATERECD] => 2016-07-15T00:00:00-04:00 [DOCKETID] => CP2015-93 ) [10] => Array ( [DOCID] => 96650 [DATERECD] => 2016-07-15T00:00:00-04:00 [DOCKETID] => CP2015-86 ) [11] => Array ( [DOCID] => 96649 [DATERECD] => 2016-07-15T00:00:00-04:00 [DOCKETID] => CP2015-76 ) [12] => Array ( [DOCID] => 96648 [DATERECD] => 2016-07-15T00:00:00-04:00 [DOCKETID] => CP2015-75 ) [13] => Array ( [DOCID] => 96643 [DATERECD] => 2016-07-15T00:00:00-04:00 [DOCKETID] => MC2016-167 ) [14] => Array ( [DOCID] => 96641 [DATERECD] => 2016-07-15T00:00:00-04:00 [DOCKETID] => MC2016-164 ) )
-
Yes, I saw the manual - no __set_state() in the list of methods If you re-arrange your array, so that the id to sort on is the key, then you could do the same user sort on that key.
-
Given that the structure of the new array is nothing like the structure of the original, it is hardly surprising that it doesn't work. The array also contains references to undocumented SimpleXMLElement::__set_state() method.
-
save wordpres information in new database (using wp shortcodes)
Barand replied to hm_ncsm's topic in PHP Coding Help
After the mysqli_query line, add if (!$res) echo $con->error; That should tell you why. -
IDs have to be unique within a document. If you have multiple objects, use classname instead.