-
Posts
24,563 -
Joined
-
Last visited
-
Days Won
822
Everything posted by Barand
-
I have just replied to a post in the forum. After posting my reply appears before the post that I replied to. ??? http://forums.phpfreaks.com/topic/290248-compound-tax-in-php/?do=findComment&comment=1487038 Edit: However, on revisiting the thread the order is now correct ??? ???
-
http://lmgtfy.com/?q=php+barcode+scanner+integration
-
I find floating divs easiest $datefrom = new DateTime('2014-07-01'); $dateto = new DateTime(); // today $dp = new DatePeriod($datefrom, new DateInterval('P1D'), $dateto); $i = 0; foreach ($dp as $date) { echo "<div style='width:120px; float:left'> <input type='checkbox' name='date[]' value='{$date->format('Y-m-d')}' /> {$date->format('d-m-Y')} </div>"; if (++$i%3 == 0) echo "<div style='clear:both'></div>"; } OUTPUTS
-
Date, between date column and date column -3 days
Barand replied to lasha's topic in PHP Coding Help
try WHERE STR_TO_DATE(start_date, '%m/%d/%Y') BETWEEN CURDATE() AND CURDATE() + INTERVAL 3 DAY -
Each pair of values is compared during the sort and passed to your function as $a and $b. Those return values indicate whether $a should sort above (-1) or below (+1) $b, or should be considered equal (0). (It doesn't have to be 1 and -1, any negative and positive numbers will have the same effect.)
-
Date, between date column and date column -3 days
Barand replied to lasha's topic in PHP Coding Help
Is that the date format that you are storing in your database? If so, date arithmetic, functions and comparisons will not work. You need to convert them to yyyy-mm-dd format, column type DATE, or convert them in every record with STR_TO_DATE() when ever you run your query - which isn't very efficient. -
WIndows has a Task Scheduler http://msdn.microsoft.com/en-gb/library/windows/desktop/aa383614%28v=vs.85%29.aspx
-
Date, between date column and date column -3 days
Barand replied to lasha's topic in PHP Coding Help
So if today is the 5th you want to show records with a start_date between 6th and 8th ? If so ... WHERE start_date BETWEEN CURDATE() + INTERVAL 1 DAY AND CURDATE() + INTERVAL 3 DAY -
Date, between date column and date column -3 days
Barand replied to lasha's topic in PHP Coding Help
You are comparing the start date with itself so you will always get a match. Explain precisely what you are trying to achieve, preferably with example data and what output you expect. -
storing some values from a php-array into mysaql-db fails
Barand replied to Maze's topic in PHP Coding Help
It tells you that you have a syntax error in your query $sql = "REPLACE INTO pois ('id','lat','lon') VALUES\n" . join(",\n", $poisdata); Column names should not be in quotes. -
You are using an aggregation function (viz SUM) without a GROUP BY clause. This will give you a single row with the SUM for the whole table with arbitrary values in the other columns.
-
storing some values from a php-array into mysaql-db fails
Barand replied to Maze's topic in PHP Coding Help
Sorry Ch0cu3r but that's bullshit. Boolean expressions are perfectly acceptable EG Price list mysql> SELECT name, price FROM products -> ORDER BY name; +-----------+--------+ | name | price | +-----------+--------+ | product a | 1.50 | | product b | 2.00 | | product c | 50.99 | | product d | 10.25 | | product e | 100.00 | | product f | 8.00 | | product g | 2.29 | | product h | 0.49 | +-----------+--------+ Price list with more expensive items first. mysql> SELECT name, price FROM products -> ORDER BY price > 50 DESC, name ; +-----------+--------+ | name | price | +-----------+--------+ | product c | 50.99 | | product e | 100.00 | | product a | 1.50 | | product b | 2.00 | | product d | 10.25 | | product f | 8.00 | | product g | 2.29 | | product h | 0.49 | +-----------+--------+ -
I'm such a noob, but I have a question about my code
Barand replied to kathmeejee's topic in PHP Coding Help
Is your file type ".php" or ".html"? The <h1> tags need to be inside the quotes echo "<h1>my First PHP script</h1>"; or outside the php/echo <h1> <?php echo "my First PHP script"; ?> </h1> -
How to make this database relation system
Barand replied to entheologist's topic in Application Design
The way you have described it suggests a simple hierarchy +------------+ | plant | +------------+ | +-----+ (contains) | +------------+ | chemical | +------------+ | +-----+ (used in) | +------------+ | product | +------------+ | +-----+ (treatment for) | +------------+ | illness | +------------+ However, before we can give definite advice on how the db relationships should be set up there are many questions to be asked about the actual relationships between these four entities. For example Can an illness to be treated by more than product? Can a product treat more than one illness? Can a product contain more than one chemical? Are any chemicals used in more than one product? Do any chemicals come from more than one plant? Do any plants produce more than one chemical? etc The answers to questions like these may well lead to a far more complex network of relationships -
Try it and see.
-
Instead of recursively querying the database use a single query and store in an array. Then do a recursive print of the array $sql = "SELECT id, name, parent FROM folder"; $res = $db->query($sql); $data = array(); // // Store data in array indexed by parent // while (list($id, $name, $parent) = $res->fetch_row()) { $data[$parent][$id] = $name; } // // Recursive function to print the tree // function printFolders(&$data, $parent, $level=0) { $indent = str_repeat('— ', $level); foreach ($data[$parent] as $id => $name) { echo "$indent $name<br>"; if (isset($data[$id])) { // any children? printFolders($data, $id, $level+1); // call function to print child data } } } printFolders($data, 0); Outputs -> Admin — Config — Login — Display — — Default — — — IMG Blog — Lib — — JS — — CSS — — HTML Shop Forum Sandbox
-
From the information you have given us I can tell you that you need a SELECT ... query.
-
If we tell him enough times it might sink in
-
On which field? You could use uasort() with a custom sort function, but the best way to do is when you you get the data from the database in the first place (if that is where the array came from originally)
-
Now try it as I suggested, concatenating the values then outputting the marquee after the while loop
-
Or make the "time" field type TIMESTAMP then it will auto update without you having to insert anything
-
Yes, I know. I am suggesting you create it using CDATA. The above is an example of what it will look like, in an effort to assist you, and also to demonstrate that it can hold special characters.
-
Build your query query as a separate string prior to execution. Then you can echo it to see how it looks.
-
In a similar vein, the owner of the Pig and Whistle, having had his pub sign newly painted, complained to the signwriter, "There's to much space between Pig and and and and and Whistle
-
My favourite example of this is: Time flies like an arrow Fruit flies like a banana