I would like to have the german date format. In my table in phpmyadmin I have got the format type "DATE" and I am struggling in my query now.
$sql = "SELECT *
FROM workeroffers
WHERE 0=0"
.( $w_destrict ? " AND w_destrict LIKE '$w_destrict'":"" )
.( $w_select ? " AND w_select LIKE '$w_select'":"" )
.( $w_mjobs > "" ? " AND ( ".ltrim( $w_mjobs," OR" )." )":"" )
.( $w_mdestrict > "" ? " AND ( ".ltrim( $w_mdestrict," OR" )." )":"" )
." ORDER BY DATE_FORMAT( w_date, '%d.%m.%Y') AS w_date ASC;";
Something went wrong in this query and I am getting no result. Any idears? Sorry, first time that I am doing it.
Here it is working, but in the wrong date format:
$sql = "SELECT *
FROM joboffers
WHERE 0=0"
.( $j_destrict ? " AND j_destrict LIKE '".$j_destrict."'":"" )
.( $j_select ? " AND j_select LIKE '".$j_select."'":"" )
.( $j_mjobs > "" ? " AND ( ".ltrim( $j_mjobs," OR" )." )":"" )
.( $j_mdestrict > "" ? " AND ( ".ltrim( $j_mdestrict," OR" )." )":"" )
." ORDER BY j_date ASC;";
It is a diffrent table. Above it was just a try. I tought, it could go in the right direction.
Here is my code for the result:
<div class="table_padding">
<table class="responsive">
<tr>
<th>Jobart</th>
<th>Stadteil</th>
<th>Berufsfeld</th>
<th class="table_titel">Title</th>
<th>Vergütung</th>
<th>Gesucht ab(Datum)</th>
<th>Weitere Informationen</th>
</tr>
<?php
foreach ( $inseration as $value ) {
?>
<tr>
<td><?= $value['w_select'] ?></td>
<td><?= $value['w_destrict'] ?></td>
<td><?= $value['w_cat'] ?></td>
<td class="table_titel"><?= $value['w_title'] ?></td>
<td><?= $value['w_cash'] ?></td>
<td><?= $value['w_date'] ?></td>
<td><a href="index.php?site=Jobsuche_Inserat&w_id=
<?php
echo $value['w_id'];
if( $w_select ){
echo '&w_select=' . $value['w_select'];
}
if( $w_destrict ){ echo '&w_destrict=' . $value['w_destrict'];
}
if( $w_mjobs > "" ){
echo '&matches_job=' . implode(',', $_REQUEST['matches_job']);
}
if( $w_mdestrict > "" ){
echo '&matches_destrict=' . implode( ',', $_REQUEST['matches_destrict'] );
}
?>
">Weiter</a></td>
</tr>
<?php
}
?>
</table>
Maby I tought wrong, I just want to have the output in the german date format!!
Edit: OK cool, it is working with the correct date, but it is not ordered by date now. What did I wrong?
$sql = "SELECT DATE_FORMAT(w_date, '%d.%m.%Y') AS w_date, w_id, w_userid, w_select, w_cat, w_destrict, w_cash, w_title, w_desc, w_pic, w_email, w_phone, w_fax
FROM workeroffers
WHERE 0=0"
.( $w_destrict ? " AND w_destrict LIKE '$w_destrict'":"" )
.( $w_select ? " AND w_select LIKE '$w_select'":"" )
.( $w_mjobs > "" ? " AND ( ".ltrim( $w_mjobs," OR" )." )":"" )
.( $w_mdestrict > "" ? " AND ( ".ltrim( $w_mdestrict," OR" )." )":"" )
." ORDER BY w_date ASC;";
尝试使用日期格式中的破折号替换句点,如下所示:
." ORDER BY DATE_FORMAT( w_date, '%d-%m-%Y') AS w_date ASC;";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.