How to view query result on same page


I have a code snippet that load All data onto a page (car page)

function viewall_cars(){ /*Select All car details from DB */
global $wpdb;
$cars= $wpdb->get_results("SELECT * FROM fitad_cars");

echo "<div class='row'>";
foreach($cars as $item){
echo"<div class='column' style='background-color:#ccc;'>";
    echo "<p>".$item-> brand."--".$item-> model."--".$item-> productionyear."</p>";
    echo "<img src='".$item-> front."' style='width:100%;height:100px'>";
echo "</div><br>";

echo "";


After running a search query i want that search result load on to same (car) page by replacing first snippet([shortcode_allcars][/shortcode_allcars])

Savithru Jayaliya 2 months 0 Answers 10 views 0

Leave an answer