$random_ids = array(); $records = array(); $rows = 10; $self = $_SERVER["PHP_SELF"]; $total_random_ids = 0; $total_rows = 0; try { $db = new rdb("", "", "", true); } catch (Exception $e) { $messages = $e->getMessage(); if (empty($messages) === false) { die(sprintf(HTML_LAYOUT, $self, $messages)); } } try { $records = $db->read(SQL_SELECT_RECORDS_ALL); $total_rows = count($records); if ($total_rows > $rows) { $random_ids = random_records($records, $rows); $total_random_ids = count($random_ids); if ($total_random_ids > 0) { foreach ($random_ids as $index => $random_id) { $data = array(":" . KEY_RANDOM_ID => $random_id); $affected = $db->delete($data, SQL_DELETE_RECORD_BY_ID); } } } else { $total_random_ids = $total_rows; foreach ($records as $index => $record) { $data = array(":" . KEY_RANDOM_ID => $record[KEY_ID]); $affected = $db->delete($data, SQL_DELETE_RECORD_BY_ID);
$paginator = null; $records = array(); $row = 0; $rows_per_page = 10; $self = $_SERVER["PHP_SELF"]; $total_rows = 0; try { $db = new rdb("", "", "", true); } catch (Exception $e) { $messages = $e->getMessage(); if (empty($messages) === false) { die(sprintf(HTML_LAYOUT, $self, $messages)); } } try { $records = $db->read(SQL_SELECT_RECORDS_ALL); $total_rows = count($records); $paginator = new Pagination($page, $row, $rows_per_page, $total_rows, $self); $paginator->get_arguments(); $data = array(":" . KEY_BEGIN => $paginator->current_row, ":" . KEY_END => $paginator->rows_per_page); $records = $db->read(SQL_SELECT_RECORDS_PAGINATED, $data); $content = sprintf(HTML_PAGE_HEADER, $paginator->current_page, $paginator->last_page); $table_headers = sprintf(HTML_TABLE_TH_RIGHT, KEY_ID); $table_headers .= sprintf(HTML_TABLE_TH_RIGHT, KEY_NUMBER_DECIMAL); $table_headers .= sprintf(HTML_TABLE_TH_RIGHT, KEY_NUMBER_INTEGER); $table_headers .= sprintf(HTML_TABLE_TH, KEY_STRING_SIXTYFOUR); $table_headers = sprintf(HTML_TABLE_TR, $table_headers); $table_rows = ""; if (empty($records) === false) { foreach ($records as $index => $record) { $table_row = sprintf(HTML_TABLE_TD_RIGHT, $record[KEY_ID]);