Автор: Пользователь скрыл имя, 23 Апреля 2014 в 09:02, курсовая работа
Главная цель данной работы является разработка Web-приложения зоопарка.
Приложение должно быть удобным для пользователя, включать в себя следующие возможности:
Просмотр данных
Удаление данных из таблиц
Добавление данных в таблицы
Создание запросов к таблицам базы данных
</div>
</div>
</div>
<div style="clear: both;"> </div>
</div>
<div id="logo1">
<!--Main Content Editable Beyond This Point -->
<?php
if (@ $_GET['table']==$table_name[0]
$T=0;
require "universal_module.php";
} else if (@ $_GET['table']==$table_name[1]
$T=1;
require "universal_module.php";
} else if (@ $_GET['table']==$table_name[2]
$T=2;
require "universal_module.php";
} else if (@ $_GET['table']==$table_name[3]
$T=3;
require "universal_module.php";
} else if (@ $_GET['table']==$table_name[4]
$T=4;
require "universal_module.php";
}else if (@ $_GET['table']==$table_name[5]
$T=5;
require "universal_module.php";
}
?>
</div>
<br><br><br><br><br><br><br><
<br><br><br><br><br><br>
</body>
</html>
titles.php
<?php
$table_name = array ("ANIMALS","STRANA","KORM","
$table_title = array ("Животные","Страна","
$table_cols_count = array (6,2,2,3,5,2);
$table0_columns = array ("ID_ANIMALS","ID_KORM","ID_
$table0_titles = array ("Номер
животного","Номер кормления","
$table1_columns = array ("ID_STRANA","NAME_S");
$table1_titles = array ("Номер страны","Название");
$table2_columns = array ("ID_KORM","NAME_K");
$table2_titles = array ("Номер кормления","Название");
$table3_columns = array ("ID_SERVICE","ID_SOTR","ID_
$table3_titles = array ("Номер
обслуживания","Номет
$table4_columns = array ("ID_SOTR","ID_POST","SURNAME"
$table4_titles = array ("Номер
сотрудника","Номер должности",
$table5_columns = array ("ID_POST","NAME");
$table5_titles = array ("Номер должности","Название");
$tables_columns = array ($table0_columns,
$table1_columns, $table2_columns, $table3_columns, $table4_columns,$table5_
$tables_titles = array ($table0_titles,
$table1_titles, $table2_titles, $table3_titles, $table4_titles,$table5_titles)
?>
universal_module.php
<?php
if (@ $_GET['action']=='showall') {
$connect = dbconnect($dbhost,$dbuser,$
echo '<table width="100%" border="2">
<tr height="32"><td
colspan="'.($table_cols_count[
<tr height="32"><td
colspan="'.($table_cols_count[
<form action="index.php" method="GET">
Поиск по:
<select name="filter_column">
<option disabled>Выберите поле</option>
';
for($i=0;$i<$table_cols_count[
if (@ $_GET['filter_column']==$
$selected="selected ";
} else {
$selected="";
}
echo '<option '.$selected.'value="'.$tables_
';
}
echo '</select>
значение:<input width="10" name="filter_value" value="'.@ $_GET['filter_value'].'">
<input type="hidden" name="table" value="'.$table_name[$T].'">
<input type="hidden" name="action" value="showall">
<input type="hidden"
name="orderby_column" value="'.(@ $_GET['orderby_column']!=""?@
$_GET['orderby_column']:$
<input type="hidden"
name="orderby_value" value="'.(@ $_GET['orderby_value']!=""?@
$_GET['orderby_value']:"asc").
<input type="submit" value="Поиск">
<a href="index.php?table='.$
</td></tr>
<tr height="32">';
if ((@ $_GET['filter_column']!="") && (@ $_GET['filter_value']!="")) {
$filter="WHERE ".@ $_GET['filter_column']." LIKE '%".@ $_GET['filter_value']."%'";
} else {
$filter="";
}
if ((@ $_GET['orderby_column']!="") && (@ $_GET['orderby_value']!="")) {
$orderby=@ $_GET['orderby_column']." ".@ $_GET['orderby_value'];
} else {
$orderby=$tables_columns[$T][
}
$query = 'SELECT * FROM '.$table_name[$T].' '.$filter.' ORDER BY '.$orderby.';';
$result = mysql_query($query);
for($i=0;$i<$table_cols_count[
if ((@ $_GET['filter_column']!="") && (@ $_GET['filter_value']!="")) {
$f_state="&filter_column=".@
$_GET['filter_column']."&
} else {
$f_state="";
}
$img1='<a href="index.php?table='.$
$img2='<a href="index.php?table='.$
if (@ $_GET['orderby_column']==$
if (@ $_GET['orderby_column']=="asc"
$img1="";
} else {
$img2="";
}
}
echo '<td align="center">'; echo $tables_titles[$T][$i]; echo $img1.$img2.'</td>';
}
echo '
<td colspan=3> </td>
</tr>';
while ($row = mysql_fetch_row($result)) {
echo '<tr height="32">';
for ($i=0;$i<$table_cols_count[$T]
echo '<td align="left">'; echo $row[$i]; echo'</td>
';
}
echo '<td><a href="index.php?table='.$
<td><a href="index.php?table='.$
<td><a href="index.php?table='.$
echo '</tr>';
}
echo '</table>';
mysql_free_result($result);
}
if (@ $_GET['action']=='showone') {
$connect = dbconnect($dbhost,$dbuser,$
$internal_id = @ $_GET[$tables_columns[$T][0]];
$query = 'SELECT * FROM '.$table_name[$T].'
WHERE '.$tables_columns[$T][0].'="'.
$result = mysql_query($query);
echo '<table width="70%" border="2" align="center">
';
while ($row = mysql_fetch_row($result)) {
for ($i=0;$i<$table_cols_count[$T]
echo '<tr height="32">
<td align="left">'; echo $tables_titles[$T][$i]; echo'</td>
<td align="left">'; echo $row[$i]; echo'</td>
</tr>
';
}
}
echo '</table>
<p align="center"><a
href="index.php?table='.$
<p align="center"><a
href="index.php?table='.$
@ mysql_free_result($result);
}
if (@ $_GET['action']=='addform') {
echo '<form action="index.php" method="GET">
<table width="70%" border="2" align="center">
';
echo '
<input type="hidden" name="table" value="'.$table_name[$T].'">
<input type="hidden" name="action" value="add">
';
for ($i=1;$i<$table_cols_count[$T]
echo '<tr height="32">
<td align="left">'; echo $tables_titles[$T][$i]; echo'</td>
<td align="left"><input
type="text" name="'.$tables_columns[$T][$
</tr>
';
}
echo '<tr height="32">
<td align="center"><a
href="index.php?table='.$
<td align="center"><input type="submit" value="Сохранить"/></td>
</tr>
</table>';
@mysql_free_result($result);
}
if (@ $_GET['action']=='add') {
$connect = dbconnect($dbhost,$dbuser,$
$query_columns = $tables_columns[$T][1];
$query_values = '"'.@ $_GET[$tables_columns[$T][1]].
for ($i=2;$i<$table_cols_count[$T]
$query_columns .= ','.$tables_columns[$T][$i];
$query_values .= ',"'.@
$_GET[$tables_columns[$T][$i]]
}
$query = 'INSERT INTO '.$table_name[$T].' ('.$query_columns.') VALUES ('.$query_values.');';
$result = mysql_query($query);
if ($result)
$result = "Запись успешно добавлена.";
else
$result = "Запись НЕ добавлена.";
echo '<table width="100%" border="2">
<tr height="32"><td
align="center"><b>'.$table_
<tr height="32"><td
align="center">'.$result.'</
</table>';
@ mysql_free_result($result);
}
if (@ $_GET['action']=='editform') {
$connect = dbconnect($dbhost,$dbuser,$
$internal_id = @ $_GET[$tables_columns[$T][0]];
$query = 'SELECT * FROM '.$table_name[$T].'
WHERE '.$tables_columns[$T][0].'="'.
$result = mysql_query($query);
echo '<form action="index.php" method="GET">
<table width="70%" border="2" align="center">
';
$row = mysql_fetch_row($result);
echo '<tr height="32">
<td align="left">'; echo $tables_titles[$T][0]; echo'</td>
<td align="left">'.$row[0].'<input
type="hidden" name="'.$tables_columns[$T][0]
<input type="hidden" name="table" value="'.$table_name[$T].'">
<input type="hidden" name="action" value="edit">
</tr>
';
for ($i=1;$i<$table_cols_count[$T]
echo '<tr height="32">
<td align="left">'; echo $tables_titles[$T][$i]; echo'</td>
<td align="left"><input
type="text" name="'.$tables_columns[$T][$
</tr>
';
}
echo '<tr height="32">
<td align="center"><a
href="index.php?table='.$
<td align="center"><input type="submit" value="Сохранить"/></td>
</tr>
</table>';
@ mysql_free_result($result);
}
if (@ $_GET['action']=='edit') {
$connect = dbconnect($dbhost,$dbuser,$
$query = 'UPDATE '.$table_name[$T].' SET ';
$query.= ' '.$tables_columns[$T][1].'="'.
for ($i=2;$i<$table_cols_count[$T]
$query.=', '.$tables_columns[$T][$i].'="'
}
$query.='WHERE '.$tables_columns[$T][0].'='.@
$_GET[$tables_columns[$T][0]].
$result = mysql_query($query);
if ($result)
$result = "Запись успешно изменена.";
else
$result = "Запись НЕ изменена.";
echo '<table width="100%" border="2">
<tr height="32"><td
align="center"><b>'.$table_
<tr height="32"><td
align="center">'.$result.'</
</table>';
@ mysql_free_result($result);
}
if (@ $_GET['action']=='deleteform') {
echo '<form action="index.php" method="GET">
<table width="70%" border="2" align="center">
<tr height="32">
<td align="left">'; echo $tables_titles[$T][0]; echo'</td>
<td align="left"><input
type="input" name="'.$tables_columns[$T][0]
<input type="hidden" name="table" value="'.$table_name[$T].'">
<input type="hidden" name="action" value="delete">
</tr>
<tr height="32">
<td align="center"><a
href="index.php?table='.$
<td align="center"><input type="submit" value="Удалить"/></td>
</tr>
</table>';
@ mysql_free_result($result);
}
if (@ $_GET['action']=='delete') {
$connect = dbconnect($dbhost,$dbuser,$
$query = 'DELETE FROM '.$table_name[$T].'
WHERE '.$tables_columns[$T][0].'='.@
$_GET[$tables_columns[$T][0]].
$result = mysql_query($query);
if ($result)
$result = "Запись успешно удалена.";
else
$result = "Запись НЕ удалена.";
echo '<table width="100%" border="2">
<tr height="32"><td
align="center"><b>'.$table_
<tr height="32"><td
align="center">'.$result.'</
</table>';
@ mysql_free_result($result);
}
?>
Курсовая работа выполнена мною самостоятельно. Все используемые источники имеют ссылки.
Пушкарева Яна Владимировна _______________ ________________