close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

ORDER BY problem

Thread began 5/26/2021 8:43 am by Jamie | Last modified 5/26/2021 9:31 am by Ray Borduin | 484 views | 3 replies |

Jamie

ORDER BY problem

Hey Ray

Have got this recordset

<?php
$WADAvehicle_inspections = new WA_MySQLi_RS("WADAvehicle_inspections",$DBConnection,20);
$WADAvehicle_inspections->setQuery("SELECT * FROM vehicle_inspections ORDER BY VehiclesDate DESC");
$WADAvehicle_inspections->execute();
?>
<?php } else { ?>
<?php
$WADAvehicle_inspections = new WA_MySQLi_RS("WADAvehicle_inspections",$DBConnection,1);
$WADAvehicle_inspections->setQuery("SELECT * FROM vehicle_inspections WHERE VehiclesInspector = ? ORDER BY VehiclesDate DESC");
$WADAvehicle_inspections->bindParam("s", "".($_SESSION['UserLastName']) ."", "-1"); //colname
$WADAvehicle_inspections->execute();
?>
<?php } ?>



and this in a repeat block

<div class="coffee-span-2 resultsWrapper leftColumn"> <?php if(WA_Auth_RulePasses("Administrator")){ ?><a class="link-text resultsLinks dates timesheet" href="vehicleinspections_update.php?VehiclesID=<?php echo($WADAvehicle_inspections->getColumnVal('VehiclesID')); ?>
<?php echo(isset($_GET["pageNum_WADAvehicle_inspections"])?"&pageNum_WADAvehicle_inspections=".intval($_GET["pageNum_WADAvehicle_inspections"]):""); ?>"><?php echo(($WADAvehicle_inspections->getColumnVal('VehiclesDate'))?date('d M y',strtotime($WADAvehicle_inspections->getColumnVal('VehiclesDate'))):''); ?></a>
<?php } else { ?>
<?php echo(($WADAvehicle_inspections->getColumnVal('VehiclesDate'))?date('d M y',strtotime($WADAvehicle_inspections->getColumnVal('VehiclesDate'))):''); ?>
<?php } ?> </div>



it should be filtering/ordering by the date but as you can see by this screenshot its not http://prntscr.com/13g113t

Many thnaks

Jamie

Sign in to reply to this post

Ray BorduinWebAssist

What is the column data type for the VehiclesDate column in the database?

Sign in to reply to this post
Did this help? Tips are appreciated...

Jamie

dang

varchar - is there anyway to change it to date without it setting all dates to 0?

Sign in to reply to this post

Ray BorduinWebAssist

You can probably create a second column "tempDate" and then run a query like:

UPDATE vehicle_inspections SET tempDate =VehiclesDate

If it doesn't copy that way, then as long as you have a standard date format you might be able to get it to work with str_to_date() like:

UPDATE vehicle_inspections SET tempDate = str_to_date(VehiclesDate, '%Y-%m-%d')

see: https://www.w3schools.com/mysql/func_mysql_str_to_date.asp

Then once you are sure the dates got copied to the new column properly, delete the old column and rename the new one.

Sign in to reply to this post
Did this help? Tips are appreciated...

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...