нужна фильтрация записям по городам.
<table width="90%" align="center" border="0" cellpadding="0" cellspacing="0">
<tr>
<td><strong>Выберите регион:</strong>
<select name="city">
<option></option>
<?php
$result = mysql_query("select city from city order by city",$db);
if (!$result)
{
echo "<p>Запрос из выборки базы данных не прошел. Напишите об этом администратору. <em><strong>Код ошибки:</strong></em></p>";
exit(mysql_error());
}
if (mysql_num_rows($result) > 0){
$myrow = mysql_fetch_array($result);
do
{
printf ("<option>%s</option>",$myrow["city"]);
}
while ($myrow = mysql_fetch_array($result));
}
else
{
echo "<p>Информация по запросу не может быть извлечина, в таблице нет записей!</p>";
exit();
}
?>
</select>
</td>
</tr>
</table>
<table width="90%" align="center" class="table_categories">
<?php
$where = array(
"",
);
# Если указан город
if (!empty($_POST['city'])) {
$city = mysql_real_escape_string($_POST['city']);
# Дополняем запрос
$where[] = "`city`='{$city}'";
}
$where = implode(' AND ', $where);
$result3 = mysql_query("select img, id, title, city, substring(`text` from 1 for 100), date, raiting, proverka from date where {$where} cat_id='$cat' and proverka = '1' order by date desc",$db);
if (!$result3)
{
echo "<p>Запрос из выборки базы данных не прошел. Напишите об этом администратору. <em><strong>Код ошибки:</strong></em></p>";
exit(mysql_error());
}
if (mysql_num_rows($result3) > 0){
$myrow5 = mysql_fetch_array($result3);
do
{
printf ("<tr>
<td width='30%%' rowspan='4'><div align='center'><img src='%s' width='100' height='100'></div></td>
<td colspan='2' valign='top'><strong>Наименование:</strong> <a href='view_post.php?id=%s'>%s</a></td>
</tr>
<tr>
<td colspan='2' valign='top'><strong>Город:</strong> %s</td>
</tr>
<tr>
<td colspan='2' valign='top'><div><strong>Краткое описание:</strong> %s</div></td>
</tr>
<tr>
<td width='30%%' valign='top'><strong>Дата публикования:</strong> %s</td>
<td width='30%%' valign='top'><strong>Рейтинг:</strong> %s</td>
</tr>",$myrow5["img"],$myrow5["id"],$myrow5["title"],$myrow5["city"],$myrow5["substring(`text` from 1 for 100)"],$myrow5["date"],$myrow5["raiting"]);
}
while ($myrow5 = mysql_fetch_array($result3));
}
else
{
echo "<div align='center'>Информация по запросу не может быть извлечина, в таблице нет записей!</div>";
//exit();
}
?>
</table>
если город не выбран то показывать все регионы, а если выбрать определенный регион - то показывать записи в этом регионе.