Hi! Could we please enable some services and cookies to improve your experience and our website?
Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code
<?php
$sql = "SHOW TABLES FROM ". DBNAME;
$result = DB::$the->query($sql);
$results = $result->rowCount();
if($results > 0){
while ($row = $result->fetch(PDO::FETCH_NUM)) {// mysql_fetch_row($result);
//$table = isset($_GET['tnames']) ? txt($_GET['tnames']) : $row[0];
$table = $row[0];
//echo $table .'<br/>';
$nodata = 1;
$sql_search = "select * from `".$table."` where ";
$sql_search_fields = Array();
$sql2 = "SHOW COLUMNS FROM ".$table;
$rs2 = DB::$the->query($sql2);
$rss2 = $rs2->rowCount();
if($rss2 > 0){
while($r2 = $rs2->fetch(PDO::FETCH_BOTH)){//mysql_fetch_array($rs2);
$colum = $r2[0];
$sql_search_fields[] = "`". $colum ."` like('%".$psearch."%')";
//echo $colum .'<br/>';
}
}
$sql_search .= implode(" OR ", $sql_search_fields);
$rs3 = DB::$the->query($sql_search);
$totalLimitRs3 = $rs3->rowCount();
$vsego = $totalLimitRs3;
$total = intval(($vsego - 1) / 9) + 1;
if ($page > $total) $page = $total;
$start = $page * 9 - 9;
$act = '#';
//$act = '/?index=search&psearch='. $psearch .'&tnames='. $table;
if ($totalLimitRs3 > 0) {
$noData = 0;
if ($table == 'production' || $table == 'job' || $table == 'autoparts' || $table == 'technic') {
$searchResult = DB::$the->query($sql_search ." limit ". $start .", 9");
//echo $sql_search ." limit 5" .'<br/>';
if ($table == 'production') {
$tableTitle = 'Работа';
$tableUrl = 'job';
}
if ($table == 'job') {
$tableTitle = 'Вакансии';
$tableUrl = 'jobs';
}
if ($table == 'autoparts') {
$tableTitle = 'Автозапчасти';
$tableUrl = 'autoparts';
}
if ($table == 'technic') {
$tableTitle = 'Техника';
$tableUrl = 'technica';
}
$newsData = array();
while ($dataSearch = $searchResult->fetch(PDO::FETCH_ASSOC)) {
array_push($dataNews, $dataSearch);
if (isset($dataSearch["desc"])) {
$desc_autoparts = output($dataSearch["desc"]);
if (strlen($desc_autoparts) > 60) {
$desc_autoparts[] = mb_substr($desc_autoparts, 0, 60).'...';
$loading[] = mb_substr(strstr(output($dataSearch["loading"]), ','), 1, 20);
$unloading[] = mb_substr(strstr(output($dataSearch["unloading"]), ','), 1, 20);
$date[] = vtime($dataSearch["date"]);
}
}
}
}
}
}
}