Подключение к БД - файл connect
<?php
/* Подключение к серверу MySQL */
$mysqli = new mysqli('127.0.0.1', 'root', '', 'yrok_bd');
if (mysqli_connect_errno()) {
printf("Подключение к серверу MySQL невозможно. Код ошибки: %s\n", mysqli_connect_error());
exit;
}
/* Посылаем запрос серверу */
if ($result = $mysqli->query('SELECT Name, Population FROM City ORDER BY Population DESC LIMIT 5')) {
print("Очень крупные города:\n");
/* Выбираем результаты запроса: */
while( $row = $result->fetch_assoc() ){
printf("%s (%s)\n", $row['Name'], $row['Population']);
}
/* Освобождаем память */
$result->close();
}
/* Закрываем соединение */
$mysqli->close();
?>
И сам код
$maxRows_Recordset1=$rru['ob_na_str'];
$pn = 0;
if (isset($_GET['pn']))
{
$pn = intval($_GET['pn']);
}
$uri=$_SERVER['REQUEST_URI'];
$uri=str_replace("&pn=".$pn, "", $uri);
$uri=str_replace("param_pn=".$pn, "", $uri);
$uri=str_replace("%5B", "[", $uri);
$uri=str_replace("%5D", "]", $uri);
if($id_firm)
$zmm='/_'.$id_firm.'/';
else
$zmm='/catalog/';
$uri2=explode("param_", $uri);
$startRow_Recordset1 = $pn * $maxRows_Recordset1;
$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query, $startRow_Recordset1, $maxRows_Recordset1);
$Recordset1 = mysqli_query($query_limit_Recordset1, $connect) or die(mysqli_error());
$row_Recordset1 = mysqli_fetch_array($Recordset1);
if($query_group==1)
{
$rm = mysqli_query($query_count);
if($rm)
{
$totalRows_Recordset1=0;
if($arr_catalog['catalog'])
{
$zamena = $zmm.$arr_catalog['url'].'_'.$arr_catalog['id_catalog'];
}
elseif (isset($_GET['id_catalog']))
{
$zamena = $zmm.'all_0';
}
else
{
$zamena = $zmm;
$zamena_2 = '/all_0/';
}
echo '<table width=100% cellpadding="2" cellspacing="2">';
$i=0;
while ($rrm = mysqli_fetch_array($rm))
{
if(!$i) echo '<tr valign=top>';
echo '<td width=33%>';
//$arrw[$rrm[1]]=$rrm[0];
if(!$zamena_2)
echo '<a href="'.(str_replace($zamena, $zmm.$arr_razdel_url[intval($id_catalog)][$rrm[1]].'_'.$rrm[1], $uri)).'">'.$arr_razdel[intval($id_catalog)][$rrm[1]].'</a><span style="color:#858585">, '.$rrm[0].'</span><br>';
else
echo '<a href="'.(str_replace($zamena, $zmm.$arr_razdel_url[intval($id_catalog)][$rrm[1]].'_'.$rrm[1].$zamena_2, $uri)).'">'.$arr_razdel[intval($id_catalog)][$rrm[1]].'</a><span style="color:#858585">, '.$rrm[0].'</span><br>';
$totalRows_Recordset1 = $totalRows_Recordset1+$rrm[0];
$i++;
if($i==3) $i=0;
}
echo '</table><p>';
}
}
elseif($query_group==2)
{
$rm = mysqli_query($query_count);
if($rm)
{
if($arr_catalog['stolb'])
$stolb=$arr_catalog['stolb']; else $stolb=5;
$stolb_sh=intval(100/$stolb);
$totalRows_Recordset1=0;
echo '<table width=100% cellpadding="2" cellspacing="2">';
$i=0;
while ($rrm = mysqli_fetch_array($rm))
{
if(!$i) echo '<tr valign=top>';
echo '<td width='.$stolb_sh.'%>';
if(!$uri2[1])
{
echo '<a href="'.$uri.'param_'.$field_param_se.'[1]='.$rrm[1].'">'.$arr_element[$field_element_num][$rrm[1]].'</a><span style="color:#858585">, '.$rrm[0].'</span><br>';
}
else
{
if($spsp)
echo '<a href="'.$uri.'&'.$field_param_se.'[2]='.$rrm[1].'">'.$arr_element_two[$field_element_num][$rrm[1]].'</a><span style="color:#858585">, '.$rrm[0].'</span><br>';
else
echo '<a href="'.$uri.'&'.$field_param_se.'[1]='.$rrm[1].'">'.$arr_element[$field_element_num][$rrm[1]].'</a><span style="color:#858585">, '.$rrm[0].'</span><br>';
}
$totalRows_Recordset1 = $totalRows_Recordset1+$rrm[0];
$i++;
if($i==$stolb) $i=0;
}
echo '</table><p>';
}
}
else
{
$all_Recordset1 = mysqli_query($query_count);
$arr_query_count = mysqli_fetch_array($all_Recordset1);
$totalRows_Recordset1 = $arr_query_count[0];
}
$totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;
echo ' Найдено записей: '.intval($totalRows_Recordset1);
if($totalRows_Recordset1)
{
echo '<br><br><TABLE width="100%" cellpadding="0" cellspacing="1" border="0">';
do
{
if (isset ($row_Recordset1['id']))
{
if($row_Recordset1['vip']) $vip_fon='bgcolor="#FFFFCA"'; else $vip_fon=''; /////////////////// VIP FON
echo '<tr data-href="'.$bp.'items/'.$row_Recordset1['zag_url'].'_'.$row_Recordset1['id'].'"><td '.$vip_fon.'><table width="100%" cellpadding="5" cellspacing="5" >';
echo '<tr valign=top height="100" >';
echo '<td width="50">';
if(date($date_format_site, strtotime($row_Recordset1['data'])) == date($date_format_site))
echo 'Сегодня';
elseif(date($date_format_site, (strtotime($row_Recordset1['data']) + 24*60*60)) == date($date_format_site))
echo 'Вчера';
else
echo dat_rus($row_Recordset1['data'], 1);
//echo date("d-m", strtotime($row_Recordset1['data']));
echo '<br><span style="color:#858585">'.date("H:i", strtotime($row_Recordset1['data'])).'</span>';
echo '<td align=center valign=top width="100">';
if($row_Recordset1['small'])
echo '<img class="imground" src="'.$bp.$row_Recordset1['small'].'" border=0>';
elseif ($row_Recordset1['video_host'] == 'youtu.be' || $row_Recordset1['video_host']=='youtube.com')
echo '<img class="imground" width=100 src="http://i.ytimg.com/vi/'.$row_Recordset1['video_item'].'/1.jpg" border=0>';
//else echo '<img class="imground" src="'.$bp.'icon/nophoto_small.png" border=0>';
echo '<td width="70%">';
$titt=explode("<hr>", $row_Recordset1['opis']);
if($titt[1])
$tit='title="'.obrez(str_replace("\n"," ", $titt[1]), 200).'"'; else $tit='';
echo '<a style="font-size:14px" '.$tit.' href="'.$bp.'items/'.$row_Recordset1['zag_url'].'_'.$row_Recordset1['id'].'" >'.$row_Recordset1['zag'].'</a>';
if($row_Recordset1['f_cena_'])
{
echo '<br>'._font($row_Recordset1['f_cena_'],1).' '.$rru['cena_valuta'];
if($row_Recordset1['suff'])
echo ' '.$row_Recordset1['suff'];
}
if($row_Recordset1['razdel'] && !$con_razdel)
echo '<br><span style="color:#858585">'.$row_Recordset1['razdel'].'</span>';
if($row_Recordset1['pols']==2)
echo '<br><span style="color:#858585">Друзья</span>';
if($row_Recordset1['id_gorod']==$id_region)
{
if($row_Recordset1['rayon'])
echo '<br><span style="color:#858585">'.$row_Recordset1['rayon'].'</span>';
}
elseif (!($arr_rayon && in_array($id_region, $arr_rayon)) && $row_Recordset1['gorod'])
echo '<br><span style="color:#858585">'.$row_Recordset1['gorod'].'</span>';
echo '<td>';
echo '</table>';
}
} while ($row_Recordset1 = mysqli_fetch_array($Recordset1));
echo '</table>';
}
mysqli_free_result($Recordset1);
$uris=explode("param_",$uri);
if($uris[1]) //есть параметы кроме pn
{
$dop2="&pn=";
$map1="&map=1";
$map2="&map=2";
}
else
{
$dop2="param_pn=";
$map1="param_map=1";
$map2="param_map=2";
}
pages(15, $totalPages_Recordset1, $pn, $uri, $dop2);
?>