Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
I want to get a warning when a date is different like:
I have a while and wanted to when it reaches to a different date, it warns me
$hist=mysqli_query($db, "SELECT * from history");
while($his=mysqli_fetch_assoc($hist)){
If(certain_date != last_date){
echo certain_date;
}
}
Certain date and last date is the ones I wanna get
This is simply done like this
$hist=mysqli_query($db, "SELECT * from history");
$last_date = '';
while($his=mysqli_fetch_assoc($hist)){
If($his['ano'] != $last_date){
echo $his['ano'];
$last_date = $his['ano'];
}
}
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I had this code
$loop ="5";
$value = "1";
how to insert value to db like this 1:1:1:1:1 (where loop have 5)
thanks
string $val_for_Db = "";
for ($i=0;$i<$loop;$i++) {
$val_for_Db = $val_for_Db."".$value.":";
}
$val_for_Db = substr($val_for_Db ,-1);
Now insert $val_for_Db to database.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I have a field in the database of type POINT (phpMyAdmin). I use this column to save gps coordinates.
Now I want to extract the value of latitude and longitude from database.
Can I do that without having to add other fields?
$query="SELECT * FROM risk_disposal WHERE id=$id";
$result=mysqli_query($conn,$query);
while ($row2 = mysqli_fetch_array($result))
{echo "$row2['gps']";}
Database
Try it:
SELECT ST_X(point), ST_Y(point) FROM ...
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I am not able to convert this array which is defined by colon to display in table (as mentioned below). Can anyone please guide me.
$info='Title:Beckham,Age:43,Address:UK';
Must look like this table format:
<?php
$info='Title:Beckham,Age:43,Address:UK';
$info_array = explode(",",$info);
$table = "<table>";
foreach($info_array as $row){
$row_obj_array = explode(":",$row);
$table .= "<tr><td>$row_obj_array[0]</td><td>$row_obj_array[1]</td></tr>";
}
$table.="</table>";
echo $table;
?>
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I'm using DateTime::createFromFormat in PHP like this:
$month = DateTime::createFromFormat("Y-m-d", '2014-08-01');
But echo $month is showing up as 08. How can I display it as a 3 letter name, i.e.: Aug?
Use capital M instead of m .
$getMonth = DateTime::createFromFormat("Y-m-d", '2014-08-01');
If you already have the date variable created then you can use directly the below code
$month = $getMonth->format('M');
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
please take a look at mycode
$result = $db->query("SELECT u.*,age(u.created_on) older FROM users u")->fetchAll(PDO::FETCH_OBJ);
foreach ($result as $row) {
preg_match("#(.*?)([0-9]+)(\s)mons(.*?)#is", $row->older, $match);
if (isset($match[2]) && $match[2] == "3") {
echo "{$row->email} is 3 month older";
}
}
i know this can be done in one query only
you can post alternate solution to this or can improve my code.
i want to check here that i am doing it correct or not
if you want to get records older than three months you can write query like this :
select * from "table" WHERE dstart < current_date - INTERVAL '3 month'