-
Posts
24,608 -
Joined
-
Last visited
-
Days Won
831
Everything posted by Barand
-
(PHP) Need to change currency function to percentual (%) (at one line)
Barand replied to Netchain's topic in PHP Coding Help
percent = (amount_changed / yesterdays_closing_price) * 100 -
$price = 278.53; $cents = $price * 100; $end_result = $cents ; // without the (int) gives 27853
-
foreach ($data as $k => $v) { if (is_object($v)) { foreach ($v as $k1 => $v1) { echo "$k1 : $v1 <br>"; } } }
-
That "array" is an object. (if it came from json data, decode it as an array instead of an object) $a = json_decode(json_encode($data), true); // convert the object to an array foreach ($a as $k => $v) { if (is_array($v)) { echo $v['orders.orderid'] . '<br>'; } }
-
Getting the error Undefined index but the column exists
Barand replied to makamo66's topic in PHP Coding Help
So you are one of those people who likes to waste people's time by posting simultaneously on multiple forums? That will be remembered. -
Getting the error Undefined index but the column exists
Barand replied to makamo66's topic in PHP Coding Help
Your error is because you have no parameter placeholders in the query that you are preparing. (See the examples) Dates stored in that format are as much use as a chocolate teapot. You cannot do correct comparisons and therefore you can't sort them. You can't use the dozens of date/time functions without reformatting Store data for functionality, not prettiness. You can format it for human consumption on output, I've told you the correct format to use. -
Isn't that just another category (I.E. Free)?
-
Other than filtering by category, how is this different from your last topic?
-
Getting the error Undefined index but the column exists
Barand replied to makamo66's topic in PHP Coding Help
I see no problem with this (eg if date comes from a date picker) as the date finally used is not that originally input... $date = (new DateTime($_POST['date']))->format('Y-m-d'); $res = $pdo->query("SELECT whatever FROM tablename WHERE thedate > '$date' "); -
Getting the error Undefined index but the column exists
Barand replied to makamo66's topic in PHP Coding Help
String literals in a query require single quotes otherwise they are treated as column names. Identifiers which contain spaces, or are reserved words, require backticks. SELECT `group` , fname as `first name` FROM user WHERE lname = 'jones' ; -
Getting the error Undefined index but the column exists
Barand replied to makamo66's topic in PHP Coding Help
DATETIME columns require Y-m-d H:i:s format. (eg 2019-10-23 14:52:38 ) Have you checked the column exists, say, with "DESCRIBE comment_table" or "SHOW CREATE TABLE comment_table"? @gw1500se the quotes are correct mysqli_query($connection, "INSERT INTO comment_table (name, date_col) VALUES ('$name', '$date_col')"); ^ ^ -
Perhaps exec * 100 / total
-
As an easier alternative to SELECT TIME_FORMAT(IF(logged=0, time, logged), '%T') as time Then you will just need SELECT TIME_FORMAT(logged, '%T') as time
-
This will copy the current date and time values into the timestamp column UPDATE tblTraffic SET logged = CONCAT(date, ' ', time);
-
All existing records will have the timestamp auto updated to the time the column was added. When new records are added that timestamp column will be the time added. You could set that column to zero date (for currently existing records) so only new records get a time stamp. UPDATE tblTraffic SET logged = 0; Then you will know which time to use - the timestamp if non-zero or the time column if timestamp is zero. SELECT TIME_FORMAT(IF(logged=0, time, logged), '%T') as time EDIT: Alternatively, copy the date and time columns' values into the timestamp column
-
Try this... Add a TIMESTAMP type column to your table `logged` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, then use the time portion of this column in your query instead of your current time column. (You don't need to change the INSERT query as it will update itself automatically) $sql = mysqli_query($conn, "SELECT ip , page , CASE WHEN referrer = '' THEN 'N/A' ELSE referrer END as referrer , DATE_FORMAT(date, '%m/%d/%y') as date , TIME_FORMAT(logged, '%T') as time FROM tblTraffic ORDER BY date DESC, time DESC");
-
I do but we cannot see what you can see. I am not clairvoyant nor am I standing behind you looking over your shoulder at your screen. I don't know your table structure. I cannot see your data. So sometimes there is a need to ask questions in order to give that help.
-
There will be - you could have had one hours ago but it took you 12 hours and 6 posts to answer that simple question.
-
At last! An answer.
-
The only reference I found was $time = date('h:i:a') in this thread Are you still storing your times as "08:15:pm" despite being told not to?
-
It should function as posted (at least, it does for me). You should have a "census.csv" file that resembles this... "Hamilton, Oh",3,30000 "Hamilton, Oh",1,25000 "Butler, Oh",1,22000 "Butler, Oh",1,44000 "Clermont, Oh",1,65000 "Clermont, Oh",1,15000 "Clermont, Oh",2,11000 "Warren, Oh",3,20000 "Warren, Oh",1,100000 "Campbell, Ky",2,50000 "Kenton, Ky",8,20000 "Kenton, Ky",4,15000 "Kenton, Ky",4,18000 "Warren, Oh",1,70000 "Warren, Oh",2,100000 ...which gets processed and output by lines 51 -75 (Output table is stored in "$analysis" variable and output in the HTML section - 5 lines from the end)
-
… And, for the benefit of those of us who can't see the report, how is that?
-
How is the time stored in your table?
-
Are you sure you know the name of the file? (Use the code <> button in the toolbar when posting code) EDIT: Stop using "@" to suppress errors - you want to know when things have gone wrong