jazzman1
Staff Alumni-
Posts
2,713 -
Joined
-
Last visited
-
Days Won
12
Everything posted by jazzman1
-
Php array grouping by date and missing other data.
jazzman1 replied to ztimer's topic in PHP Coding Help
It's a ugly but should work function call_back_func($value,&$key) { echo "The key $key has the value:"; foreach ($value as $k => $v) { echo $k; foreach ($v as $t) { echo $t."<br />"; } } } array_walk($data,"call_back_func"); -
Php array grouping by date and missing other data.
jazzman1 replied to ztimer's topic in PHP Coding Help
But where is the value of $array['id'] I'm missing something -
Php array grouping by date and missing other data.
jazzman1 replied to ztimer's topic in PHP Coding Help
Because I don't have your data can you give the output of: while($array = mysql_fetch_array($result)){ $data[$array['date']][$array['id']] = array($array['type'], $array['form_id'], $array['reserv'], $array['user_id']); } function call_back_func($value,$key) { echo "The key $key has the value:"; foreach ($value as $v) { echo '<pre>'.print_r($v,true).'</pre>'; } } array_walk($data,"call_back_func"); -
Php array grouping by date and missing other data.
jazzman1 replied to ztimer's topic in PHP Coding Help
There are tons of examples how to make a recursive function in php, here it is. So for you if you want to find all data recursively to 2014-04-02 you can try, while($array = mysql_fetch_array($result)){ $data[$array['date']][$array['id']] = array($array['type'], $array['form_id'], $array['reserv'], $array['user_id']); } function find_in_arr($key, $arr) { foreach ($arr as $k => $v) { if ($k == $key) { return $v; } if (is_array($v)) { foreach ($v as $_k => $_v) { if ($_k == $key) { return $_v; } } } } return false; } var_dump( find_in_arr('2014-04-02', $data) ); -
Php array grouping by date and missing other data.
jazzman1 replied to ztimer's topic in PHP Coding Help
You need to use recursive function instead of bunch of nested loops. -
Php array grouping by date and missing other data.
jazzman1 replied to ztimer's topic in PHP Coding Help
After the while construct add the following and post the output: while($array = mysql_fetch_array($result)){ $data[$array['date']][$array['id']] = array($array['type'],$array['form_id'],$array['reserv'],so forth...) } // here echo '<pre>'.print_r($data, true).'</pre>'; -
Php array grouping by date and missing other data.
jazzman1 replied to ztimer's topic in PHP Coding Help
Add type, form_id, reserv, code, title and so on in an array then loop the data. Try, while($array = mysql_fetch_array($result)){ $data[$array['date']][$array['id']] = array($array['type'],$array['form_id'],$array['reserv'],so forth...) } -
When you send the query above and fetch the data from db server, do print_r() to see how the structure of data is represented. Yes,your application language is php, but could be perl, python,bash and so on...
-
Why don't you use the php date/time function to convert the server and client time format to UnixTime Stamp (Integer Format), then do some calculation with those integers and return the result back to your clients to human readable date/time format.
-
I completely forgot that it has a 1024 character limit by default
-
Do a "view source" in the browser.
-
Yes, that's correct. When the data has been pulled down from DB you need to use an application language technique to display the content in an order you want, or you could use a mysql group_concate function to concatenate all comments to each group of blog and again you need to use the application language technique. "SELECT a.blog_id, a.dateposted, a.content, a.title, a.published, b.login, b.img, c.username, GROUP_CONCAT(c.comment) FROM blog a JOIN user b ON a.user_id = b.user_id RIGHT JOIN blog_comments c ON a.blog_id = c.blog_id WHERE a.published = 1 GROUP BY a.dateposted DESC LIMIT 5 "
-
You need to wrap $firstname and $lastname in your query in single quotes. Try, $stmt = $conn->prepare("SELECT id FROM dbname WHERE FName = '$firstname' AND LName = '$lastname'");
-
Well, thanks for the quote Barry. I found the same in the mysql documentation, and I'd suggest @OP to read up on it. So, obviously, there is nothing wrong in Jacques's script to call execute statement in a loop as I thought and stay corrected on it. I become confused by the fact that all versions of Firebird DB ( before 2.5, not sure for older version of mysql ), every execute statement occurred in a loop was prepared, executed and released upon every iteration, however, you are here to learn something new everyday
-
Yes, I still stay behind that statement, but need to check how mysql treats execute statement in a loop. But what I've seen this morning than, most of the new versions of databases to improve the performance just prepared the query only once when execute statement occurred in a loop.
-
I just said how database prepared, executed and destroyd the sql statements. What demonstration you need to see? About performance of looping execute statement and not looping?
-
I'm glad you've met me @Jacques So, I'm sure you know what a driver is, right? The PDO driver allows us to deal with databases like mysql, firebird and so forth using their resources and all functions you've been mentioned above are actualy database functions or sql statements . So, from here I'm thinking that all prepared, parameterized queries and execute statements are being occured inside DB server, but the server side application just cache their values/status. The easiest way to see what happens is to create a stored procedure to see how the statement would be prepared, executed and released in the loop.
-
No. When you called the execute statement more than once a new sql prepared statement is required to be prepared, then executed and released at the end. Anyways.....I also stoped the discussion here.
-
Is it a dedicated or shared hosting environment? If the server is dedicated you need hire someone to do this job for you, if not, you need to contact to your hosting provider to ask them why your version of php doesn't have a ftp library included in that version of php.
-
Problem displaying this folder name from my server
jazzman1 replied to JustinStone's topic in PHP Coding Help
Have you ever heard about properly naming file and directory names under Unix/Linux or some other operating systems? Why are you using a dollar sign as a part of directory name? -
What OS/Linux distro the server running? What permissions do you have to that server?
-
No, I have to disagre, so if execute statement occurred in a loop, the SQL statement would be prepared, executed and released upon every iteration, the statement only prepared once, will give us a huge performance benefit.
-
Do yours clients have specific/unique identifier in database something like - user_id ?
-
You could compile your php version with "Enable PHP Support" including the following option to ./configure --enable-ftp. If you're using some RPM distro with yum (require yum 3.2.22 or newer.) you would check whether the packet is available in your repositories, it should be inside the php-common packet. yum provides "php-ftp" BTW: Are you using English writing posts?
-
@Jacques, revisiting this thread you're looping php query function multiple times , that's wrong. You need to call a query function once making sql multiple data of rows at a time or just muptiple inserts as Barand (master) means