I have a random phrase on the page:
<?php //имя сервера $serverMySql = "localhost"; // логин $db_log = "*******"; // пароль $db_pass = "*****"; function db_connect($serverMySql, $db_log, $db_pass) //create connection { $r = mysql_connect($serverMySql, $db_log, $db_pass); return $r; } //база данных $database = "perecc"; //название таблицы в базе $table = "article"; //кол-во пользователей на странице $users_on_page = "100"; //подключаемся db_connect($serverMySql, $db_log, $db_pass); mysql_select_db($database); mysql_set_charset('utf8'); // страницы if (empty($_GET["p"])) { $_GET["p"] = "1"; } $p = $_GET["p"]; // защита от ввода $p = intval(isset($_GET['p'])?$_GET['p']:1); // формируем запрос $count = mysql_num_rows(mysql_query("SELECT `id` from `$table`")); // считаем страницы $total = ceil($count / $users_on_page); if ($p > $total) { $p = $total; } // формируем запрос $first = $p * $users_on_page - $users_on_page; $result = mysql_query("SELECT * FROM `$table` ORDER BY RAND() LIMIT $first, $users_on_page"); ?> <?php while ($data = mysql_fetch_array($result)) // цикл вывода { print "<tr>"; print "<td> </td>"; print "<td> </td>"; print "<td> </td>"; print "</tr>"; print "<tr>"; print "<td>$data[0]</td>"; print "<td>$data[2]</td>"; print "<td>$data[1]</td>"; print "</tr>"; } ?> </table>
How to make me display at the top of the same page 1 (one) random phrase from the DB Table "article" column "content" when reloading the page or clicking the name = "submit" button?
<p>Вот здесь Случайная фраза из БД!!!!!!!!!!!!!!!!!!!!!</p> <table border="0" width="90%" id="table1"> <tr> <td></td> <td><form action="http://.......reiting_list.php" method="get" name=""> <input align="center" type="image" src="/img/r.png" name="submit"></form></td> База данных Фразы: Таблица article {id} _ _{timestamp} {content} {author} {21}___{2012-10-20}_ {Сейчас котам...} {«Автор»}