На главную страницу       Оглавление


Приложение 3

Тексты программ

1) Файл Index.ntml

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>

<head>

<title>Untitled</title>

</head>

<body onload="location.href='index.php'">

</body>

</html>

2) Файл Index.php

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>

<head>

<title>Untitled</title>

</head>

<body>

<table border=1>

<?

include"connect.php";

echo"<tr><td>Название</td><td>Параметр</td><td>Цена</td><td><a href='edit.php?add=1'>Добавить</a></td></tr>";

$res=mysql_query("select * from denni");

$row=@mysql_num_rows($res);

for(;$row>0;$row--)

{

$str=mysql_fetch_array($res);

if($str["pr"]==0){$pr='O';}else{$pr='B';}

echo"<tr>";

echo"<td>".$str["name"]."</td>";

echo"<td><a href='matrix.php?pr=".$str["pr"]."'>".$pr."</a></td>";

echo"<td>".$str["price"]."</td>";

echo"<td><a href='edit.php?edit=".$str["id"]."'>Редактировать</a>|<a href='edit.php?del=".$str["id"]."'>Удалить</a></td>";

echo"</tr>";

}

?>

</table>

</body>

</html>

3) Файл Connect.php

<?

$connect=mysql_connect("localhost","root","");

mysql_select_db("dan",$connect);

?>

4) Файл Diagramma.php

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>

<head>

<title>Диаграмма</title>

</head>

<body>

<?

include"connect.php";

$res=mysql_query("select ball,id from denni where pr=".$pr." order by rang asc");

$mb=mysql_query("select max(ball) from denni where pr=".$pr);

$max=mysql_query("select max(price) from denni where pr=".$pr);

$row=@mysql_num_rows($res);

$maxball=mysql_fetch_array($mb);

$maxprice=mysql_fetch_array($max);

echo"<table height=200 border=0>";

echo"<tr><td valign=top width=50>".round($maxball[0])."</td><td bgcolor=black>&nbsp;</td>";

for($num=0;$row>$num;$num++)

{

$price=mysql_fetch_array($res);

$pc=($price["ball"]*100/$maxball[0])*2;

echo"<td valign=bottom>";

echo"<table valign=bottom height=".$pc." border=0><tr><td valign=top width=50 height=1>".$price["ball"]."</td></tr><tr><td bgcolor=Blue valign=top width=50><font color=white>".$price["id"]."</font></td></tr></table>";

echo"</td>";

}

echo"</tr>";

//echo"</table>";

$res=mysql_query("select price,id from denni where pr=".$pr." order by rang asc");

$max=mysql_query("select max(price) from denni where pr=".$pr);

$row=@mysql_num_rows($res);

//echo"<table height=200>";

echo"<tr><td valign=bottom width=50>".round($maxprice[0])."</td><td bgcolor=black>&nbsp;</td>";

for($num=0;$row>$num;$num++)

{

$price=mysql_fetch_array($res);

$pc=($price["price"]*100/$maxprice[0])*2;

echo"<td valign=top>";

echo"<table valign=bottom height=".$pc." border=0><tr><td valign=bottom width=50 bgcolor=blue><font color=white>".$price["id"]."</font></td></tr><tr><td valign=bottom width=50 height=1>".$price["price"]."</td></tr></table>";

echo"</td>";

}

echo"</tr>";

echo"</table>";

?>

</body>

</html>

5) Файл Damp

CREATE TABLE denni ( id int(11) NOT NULL auto_increment, name text,

pr tinyint(1), price int(11), n1 int(11), n2 int(11) NOT NULL,

n3 int(11) NOT NULL, ball double(16,4) DEFAULT '0.0000' NOT NULL,

rang int(11) NOT NULL, KEY id (id), UNIQUE id_2 (id));

6) Файл Edit.php

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>

<head>

<title>Редактирование</title>

</head>

<body>

<table border=1>

<?

include"connect.php";

if($add==1)

{

echo"<form method=get>";

echo"<tr><td>Название</td><td>Параметр</td><td>Цена</td></tr>";

echo"<tr>";

echo"<td><input type=text name=name></td>";

echo"<td><input type=Radio name=pr1>O&nbsp;<input type=Radio name=pr2>B</td>";

echo"<td><input type=text name=price></td>";

echo"<td><input type=hidden name=onadd value=1></td>";

echo"</tr>";

echo"<tr><td colspan=3 align=center><input type=submit value=Добавить></td></tr>";

echo"</form>";

}

if($onadd==1)

{

if($pr1==TRUE){$pr=0;}else{$pr=1;}

mysql_query("insert into denni (name,pr,price) values('".$name."',".$pr.",'".$price."')");

echo"<script language='JavaScript'>location.href='index.php'</script>";

}

if(!empty($edit))

{

$res=mysql_query("select * from denni where id=".$edit);

$str=mysql_fetch_array($res);

if($str["pr"]==0){$pr1="checked";$pr2='';}else{$pr1='';$pr2="checked";}

echo"<form method=get>";

echo"<tr><td>Название</td><td>Параметр</td><td>Цена</td></tr>";

echo"<tr>";

echo"<td><input type=text name=name value='".$str["name"]."'></td>";

echo"<td><input type=Radio name=pr1 ".$pr1." value=1>O&nbsp;<input type=Radio name=pr1 ".$pr2." value=2>B</td>";

echo"<td><input type=text name=price value='".$str["price"]."'></td>";

echo"<td><input type=hidden name=onedit value=".$edit."></td>";

echo"</tr>";

echo"<tr><td colspan=3 align=center><input type=submit value=Изменить></td></tr>";

echo"</form>";

}

if(!empty($onedit))

{

if($pr1==1){$pr=0;}else{$pr=1;}

mysql_query("update denni set name='".$name."', pr=".$pr.", price=".$price." where id=".$onedit);

echo"<script language='JavaScript'>location.href='index.php'</script>";

}

if(!empty($del))

{

mysql_query("delete from denni where id=".$del);

echo"<script language='JavaScript'>location.href='index.php'</script>";

}

?>

</table>

</body>

</html>

7) Файл Matrix.php

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>

<head>

<title>Матрица</title>

</head>

<body>

<table border=1>

<?

include"connect.php";

$res=mysql_query("select * from denni where pr=".$pr);

$row=@mysql_num_rows($res);

$cnt=$count+1;

echo "Эксперт Номер ".$cnt." из 3";

echo"<tr><td># функции</td><td>функция \ # функции</td>";

if($count>0&&$count<3)

{

for($num=0;$num<=$row;$num++)

{

$sum=0;

for($col=0;$col<$row;$col++)

{

$sum+=$q[$num][$col];

}

mysql_query("update denni set n".$count."=".$sum." where id=".$id[$num]);

}

}

if($count>=3)

{

$res=mysql_query("select id,n1,n1,n3 from denni");

$row=@mysql_num_rows($res);

for(;$row>0;$row--)

{

$n=mysql_fetch_array($res);

$ball=doubleval(($n["n1"]+$n["n2"]+$n["n3"])/3);

mysql_query("update denni set ball=".$ball." where id=".$n["id"]);

}

$res=mysql_query("select id from denni where pr=".$pr." order by ball desc");

$row=@mysql_num_rows($res);

for($num=1;$row+1>$num;$num++)

{

$rang=mysql_fetch_array($res);

mysql_query("update denni set rang=".$num." where id=".$rang["id"]);

}

echo"<script language=javascript>location.href='diagramma.php?pr=".$pr."'</script>";

}

for($num=0;$num<$row;$num++)

{

$nn=$num+1;

echo"<td align=center>".$nn."</td>";

}

//echo"<td>Сумма баллов</td></tr>";

echo"<form method=post>";

for($num=0;$row>$num;$num++)

{

echo"<tr>";

$str=mysql_fetch_array($res);

echo"<input type=hidden name=id[".$num."] value=".$str["id"].">";

echo"<td>".$str["id"]."</td>";

echo"<td>".$str["name"]."</td>";

for($col=0;$col<$row;$col++)

{

echo"<td><input type=number name=q[".$num."][".$col."] size=1></td>";

}

//echo"<td align=center><input type=number name=sum[".$num."] size=1 value=".$sum[$num]."></td>";

echo"</tr>";

}

echo"<input type=hidden name=pr value=".$pr.">";

$count++;

echo"<input type=hidden name=count value=".$count.">";

echo"<tr><td colspan=".$row."><input type=submit value=Отправить></td></tr>";

echo"</form>";

?>

</table>

</body>

</html>

 


На главную страницу       Оглавление




Hosted by uCoz