XAMPP - Apache, MariaDB, PHP.
: http://www.apachefriends.org.
XAMPP (. 1), Apache MySQL. , Apache MySQL Start
. 1
MySQL PHP
Admin. MySQL Admin phpMyAdmin http://localhost/phpmyadmin/ ( 1.1.)
. 1.1
Ļ - sim, utf8_bin (. 1.2)
. 1.2
. : - tovar, : - 5 (. 1.3)
. 1.3
, . : id, naim, kol, dv, img (. . 1.4):
. 1.4
. , , , . :
INT int Java.
TINYNT , , 1 10, .
DATETIME , .
VARCHAR .
A_I AUTO_INCREMENT id (. . 1.5):
. 1.5
PHP tovar. SQL INSERT. : (. 1.6)
INSERT INTO tovar (naim,kol,img) VALUES (1,117,"img/1.png")
. 1.6
:
1
naim | kol | img |
img/2.png | ||
img/3.png | ||
img/4.png | ||
img/5.png | ||
img/6.png | ||
img/7.png | ||
img/8.png | ||
img/9.png | ||
img/10.png |
razmetka c 2 id - int, A_I html - text.
INSERT INTO razmetka:
2
id | html |
<div class="left_b"> <h1></h1> <img src="img/r1.png" border="0" width="50%" height="25%" /> </div> | |
<div class="left_b"> <h1></h1> <img src="img/r2.png" border="0" width="50%" height="25%" /> </div> | |
<div class="left_b"> <h1></h1> <img src="img/r3.png" border="0" width="50%" height="25%" /> </div> | |
<div class="left_b"> <h1></h1> <img src="img/r4.png" border="0" width="50%" height="25%" /> </div> | |
<div id="right_b"> <h1> <br/> !</h1> <br/> <object width="200" height="200" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"> <param name="movie" value="img/3dClock.swf" /> <param name="quality" value="high" /> <param name="scale" value="noborder" /> <param name="3dClock" value="t" /> <param name="wmode" value="opaque" /> <param name="src" value="img/3dClock.swf" /> <!--[if!ie]>--><object width="250" height="250" type="application/x-shockwave-flash" data="img/3dClock.swf"><!--<![endif]--> <param name="quality" value="high" /> <param name="scale" value="noborder" /> <param name="salign" value="t" /> <param name="wmode" value="opaque" /> <param name="src" value="img/3dClock.swf" /> <p>Flash ! !!!!!</p> <!--[if!ie]>--></object><!--<![endif]--> </object> </div> | |
<h1 class="h1_opisan"> !</h1> <br/> <div class="div_opisan"> , , 6 . ! </div> <div class="div_opisan"> " " . . - , "" ! </div> <div class="div_opisan"> " " , . - . </div> <div class="div_opisan"> ! !: 6 . ! </div> <br/> | |
<h1 class="h1_opisan"> </h1> <br/> <div class="div_opisan"> +7 (495) 000-00-00<br/> +7 (499) 000-00-00<br/> <br/> : , , 7<br/> <br/> E-mail: [email protected]<br/> <br/> </div> | |
<h1 class="h1_opisan"> </h1> <br> <div class="div_opisan"> <br/> </div> | |
<div id="zakaz"> <form action="index.php?id=2" target="_self" method="post"> <table border="0" cellpadding="0" width="50%"> <tr> <th></th> <th></th> <th>,</th> </tr> | |
<tr><td>-----</td><td>-----</td><td>-----</td></tr> <tr><td>(*)</td><td><input type="text" name="user_name" maxlength="15"/></td><td></td></tr> <tr><td>(*):</td><td><input type="text" name="user_tel" maxlength="20"/></td><td></td></tr> <tr><td></td><td><input type="submit" id="btn" name="btn" value=" "/></td><td></td></tr> </table> </form> </div> </div> <br/> |
|
|
|
|
opisan c 3 id - int, A_I, naim - varchar txt - text.
INSERT INTO opisan:
3
Id | Naim | Txt |
, , ! . , - . | ||
, - . | ||
, , - . | ||
, , | ||
- , , , . "", . , . | ||
! ! - , . | ||
, ? "", , . | ||
- "", . | ||
" , . ", - . . | ||
, 100% . , , - . |
|
|
PHP Eclipse for PHP. : http://www.eclipse.org/ ( ).
Eclipse for PHP .
Eclipse for PHP.
PHP , File-New-PHP Project (. 1.7).
. 1.7
Project name simp Finish (. 1.8).
. 1.8
simp, New - PHP File. (. 1.9).
. 1.9
File name: index.php Finish (. 1.10).
. 1.10
doc img.
simp lib.php simp.css tovar.php
1.11
1.11
: lib.php, :
<?php
//
@ error_reporting (E_STRICT);
define ("ServerName", "localhost");
define ("UserLogin", "root");
define ("UserPassword", "");
define ("DbName", "sim");
makeOpisan():
//
function makeOpisan () {
// MySQL
$db = mysqli_connect (ServerName, UserLogin, UserPassword) or die ("cannot connect");
//
if ($db) {
//
if (mysqli_select_db ($db, DbName) or die ("cannot select DB")) {
// UTF-8
mysqli_query ($db, "SET names 'utf8'");
$rez = mysqli_query ($db, "SELECT * FROM opisan");
$out_page = "";
//
for ($i = 0; $i < 10; $i ++) {
//
$row = mysqli_fetch_row ($rez);
//
$naim = $row [1];
//
$txt = $row [2];
//
$out_page.= "<h1 class='h1_opisan'>{$naim}</h1>". "<div class = 'div_opisan'>{$txt}</div><br/>";
}
//
echo $out_page;
}
// MySQL
mysqli_close ($db);
}
}
getIdMenu() :
//
function getIdMenu () {
//
$tmp = 0;
// GET-
if ($_GET) {
// : id GET-
if ($_GET ["id"]) {
// : id
$tmp = $_GET ["id"];
}
// [1..3],
// $tmp
if (! (($tmp >= 1) && ($tmp <= 3)))
$tmp = 0;
}
//
return $tmp;
}
getHTML() HTML- -:
// HTML- -
function getHTML ($nom) {
//
$html = "";
// MySQL
$db = mysqli_connect (ServerName, UserLogin, UserPassword) or die ("cannot connect");
//
|
|
if ($db) {
//
if (mysqli_select_db ($db, DbName) or die ("cannot select DB")) {
// UTF-8
mysqli_query ($db, "SET names 'utf8'");
//
$rez = mysqli_query ($db, "SELECT * FROM razmetka WHERE (id={ $nom })");
//
$kol_str = mysqli_num_rows ($rez);
//
if ($kol_str == 1) {
//
$row = mysqli_fetch_row ($rez);
// : html
$html = $row [1];
}
}
// MySQL
mysqli_close ($db);
}
// HTML
echo $html;
}
getHTML() :
//
function testPost () {
//
if ($_POST ["btn"]) {
//
$rez = "";
//
if (trim ($_POST ["user_name"]) == "")
$rez = " !";
//
else if (trim ($_POST ["user_tel"]) == "")
$rez = " !";
else {
//
$info = "Name: ". trim ($_POST ["user_name"]). " Tel: ". trim ($_POST ["user_tel"]);
//
$file_name = "". rand (1000000, 9999999). ".txt";
//
$rez = " !";
//
$f = fopen ("./doc/". $file_name, "w");
//
if ($f) {
//
fwrite ($f, $info);
//
fclose ($f);
}
}
// -
echo "<h1 class='h1_opisan' style='font-size: 35px;'>{$rez}</h1>";
}
}
makeTabl() :
//
function makeTabl () {
// MySQL
$db = mysqli_connect (ServerName, UserLogin, UserPassword);
//
if ($db) {
//
if (mysqli_select_db ($db, DbName) {
// UTF-8
mysqli_query ($db, "SET names 'utf8'");
//
$sql1="SELECT img, naim, SUM(kol) FROM tovar GROUP BY naim ASC";
//
$rez1 = mysqli_query ($db, $sql1);
//
$sql2 = "SELECT naim FROM opisan";
//
$rez2 = mysqli_query ($db, $sql2);
//
$sql3 = "SELECT img FROM tovar";
//
$rez3 = mysqli_query ($db, $sql3);
// -
$out_page = "";
//
for ($i=0;$i<10;$i++) {
//
$row1= mysqli_fetch_array ($rez1);
//
$row2= mysqli_fetch_array ($rez2);
//
$row3= mysqli_fetch_array ($rez3);
//
$kol=$row1[2];
//
$naim=$row2[0];
//
$img=$row3[0];
// ,
//
$out_page.="<tr><td><img src= $img></td><td>{$naim}</td><td>{$kol}</td></tr>";
}
//
echo $out_page;
}
// MySQL
mysqli_close ($db);
}
}
?>
lib.php index.php:
index.php lib.php require_once ' ';
<?php
require_once 'lib.php';
?>
require_once 'lib.php'; index.php :
<html>
<head>
<title> </title>
<meta http-equiv= "Content-Type" content= "text/html" charset= "utf-8" />
<!-- -->
<link rel= "shortcut icon" href= "img/icon.png" type= "image/x-icon" >
<!-- -->
<meta name= "robots" comtent= "all" />
|
|
<link href= "simp.css" rel= "styLesheet" type= "text/css" />
<!-- -->
<meta name= "description" content= "Project Simpson and Company" />
<!-- -->
<meta name= "keywords" content= ",,, " />
<script type= "text/javascript" src= "puh.js" ></script>
</head>
index.php :
<body onload="func()">
<div id= "top" >
<a href= "index.php" target= "_self" >
<img src= "img/shapka.png" border= "0" id= "img_logo" />
</a>
</div>
<div id= "menu" >
<ul>
<li><a class= "buttons" href= 'index.php' target= "_self" ></a></li>
<li><a class= "buttons" href= 'index.php?id=1' target= "_self" ></a></li>
<li><a class= "buttons" href= 'index.php?id=2' target= "_self" ></a></li>
<li><a class= "buttons" href= 'index.php?id=3' target= "_self" ></a></li>
</ul>
</div>
<div id= "sheet" align= "center" >
<?php
//
getHTML (getIdMenu () + 1)?>
</div>
<div id= "main" >
<div id = "cen" >
<?php
//
$id_menu = getIdMenu ();
if ($id_menu == 1) { // : 1 -
//
makeOpisan ();
} else if ($id_menu == 0) { // : 0 -
//
getHTML (6);
} else if ($id_menu == 3) { // : 3 -
//
getHTML (7);
} else if ($id_menu == 2) { // : 2 -
//
getHTML (8);
// POST-
testPost ();
//
getHTML (9);
//
makeTabl ();
//
getHTML (10);
}
?>
</div>
</div>
<div id= "sidebar" align = "center" >
<?php
//
getHTML (5);
?>
</div>
<div id= "footer" >
</div>
</body>
</html>
php . tovar.php :
<?php
$db = mysqli_connect ("localhost", "root", "");
//
function javaKol () {
// ,
$otvet = "";
global $db;
//
$sql = "SELECT naim, SUM(kol) FROM tovar GROUP BY naim ASC";
// :
$rez = mysqli_query ($db,$sql);
//
for ($i = 0; $i < 10; $i ++) {
//echo $otvet."\n";
//
$row = mysqli_fetch_row ($rez);
//
$kol = $row [1];
//
$otvet.= $kol;
// (~)
if ($i!= 9)
$otvet.= "~";
}
//
echo $otvet;
}
tovar.php getQuery():
//
function getQuery () {
global $db;
//
$date_time = date ('Y-m-d [H:i:s]');
// 10
for ($i = 1; $i <= 10; $i ++) {
//
$tmp = "tov". $i;
// -
if ($_GET [$tmp]) {
// -
$kol = $_GET [$tmp];
//
$q = "INSERT INTO tovar (naim, kol, dv)". "VALUES ({$i},{$kol}, '{$date_time}')";
//
mysqli_query ($db,$q);
}
}
}
tovar.php runMySQL():
//
function runMySQL () {
global $db;
//
if ($db) {
//
if (mysqli_select_db ($db, "sim")or die ("cannot select DB")) {
//
mysqli_query ($db, "SET names");
//
getQuery ();
//
javaKol ();
}
//
mysqli_close ($db);
}
}
// -
if ($_GET) {
// -
//
$flag = false;
//, 10
for ($i = 1; $i <= 10; $i ++) {
//
$tmp = "tov". $i;
// -
if ($_GET [$tmp]) {
//
$flag = true;
//
break;
}
}
// -
if ($flag) {
runMySQL ();
}
}
?>
img , -.
simp.css :
css : http://htmlbook.ru/css
@CHARSET "UTF-8";
/* */
body, table, tr, td, div, ul, li, img, a, h1, th, input, from {
padding: 0px;
vertical-align: top;
margin: 0px;
background-color: #FFE4C4;
}
/*/ */
#img_logo {
height: 13%;
width: 100%;
background-size: 100% 100%;
background-position: 70% 70%;
background-repeat: no-repeat;
}
/* */
#menu {
height: 5%;
width: 100%;
text-shadow: 2px 4px 3px rgba(0,0,0,0.3);
background-repeat: repeat;
background-attachment: scroll;
background-position: top left;
background-size: cover;
font-size: 15%px;
}
/* */
a .buttons {
display: inline-block;
text-decoration: none;
padding: 0.5em;
outline: none;
border-radius: 5%;
}
/* */
a .buttons:hover {
background-image:
radial-gradient(1% 45% at 0% 50%, rgba(0,0,0,.6), transparent),
radial-gradient(1% 45% at 100% 50%, rgba(0,0,0,.6), transparent);
}
/* */
a .buttons:active {
background-image:
radial-gradient(45% 45% at 50% 100%, rgba(255,255,255,.9), rgba(255,255,255,0)),
linear-gradient(rgba(255,255,255,.4), rgba(255,255,255,.3));
box-shadow:
inset rgba(162,95,42,.4) 0% 0% 0% 1%,
inset rgba(255,255,255,.9) 0% 0% 1% 3%;
}
/* */
#menu ul {
list-style: none;
}
/* */
#menu li {
float: left;
padding-top: 0%;
padding-left: 17%;
}
/* */
#sheet {
height: 69%;
width: 20%;
background-color: #FFE4C4;
float: left;
}
/* */
#main {
height: auto;
width: 60%;
background-color: #FFE4C4;
float: left;
padding: 0% 0%;
}
#cen {
width: 60%;
height: auto;
padding: 0% 25%;
}
#sidebar {
height: 69%;
width: 20%;
background-color: #FFE4C4;
background-repeat: repeat;
background-attachment: fixed;
background-position: top left;
float: right;
}
/*/ */
#footer {
height: 13%;
width: 100%;
background-image: url('img/podval.png');
background-size: 100% 100%;
background-position: 70% 70%;
background-repeat: no-repeat;
clear: both;
}
/* */
.div_opisan {
text-decoration: none;
font-size: 100%;
font-family: verdana, arial, serif;
font-style: normal;
font-weight: normal;
line-height: auto;
color: black;
width: 100%;
white-space: normal;
text-align: justify;
}
/* */
.h1_opisan {
width: 100%;
text-align: center;
text-decoration: none;
font-size: 100%;
font-family: verdana, arial, serif;
font-style: italic;
text-shadow: 2px 4px 3px rgba(0,0,0,0.3);
}
/* */
.left_b h1 {
color: rgba(0,0,0,0.6);
text-shadow: 2px 8px 6px rgba(0,0,0,0.2),
0px -5px 35px rgba(255,255,255,0.3);
}
/* */
.left_b h1 :HOVER {
background-color: #666666;
-webkit-background-clip: text;
-moz-background-clip: text;
background-clip: text;
color: transparent;
text-shadow: rgba(255,255,255,0.5) 0px 3px 3px;
}
#right_b {
padding-top: 0%;
padding-bottom: 5%;
width: 100%;
}
/* */
#right_b h1 {
color: rgba(0,0,0,0.6);
text-shadow: 2px 8px 6px rgba(0,0,0,0.2),
0px -5px 35px rgba(255,255,255,0.3);
}
/* */
#right_b h1 :HOVER {
background-color: #666666;
-webkit-background-clip: text;
-moz-background-clip: text;
background-clip: text;
color: transparent;
text-shadow: rgba(255,255,255,0.5) 0px 3px 3px;
}
/* */
#zakaz td, #zakaz th, #zakaz input
{text-shadow: 2px 4px 3px rgba(0,0,0,0.3);
white-space: nowrap;
text-decoration: none;
font-size: 100%;
font-family: Verdana, sans-serif;
font-style: normal;
line-height: 100%;
color: black;
}
/* */
#zakaz th
{
text-shadow: 2px 4px 3px rgba(0,0,0,0.3);
color: #000000;
}
/* */
#zakaz td, zakaz th
{
width: 100%;
vertical-align: middle;
text-align: center;
border: black 1% solid;
background-color: #FFE4C0
}
/* */
#zakaz input
{
text-shadow: 2px 4px 3px rgba(0,0,0,0.3);
width: 100%;
height: 135%;
background-color: #FFE4C0;
padding: 3%;
color: black;
}
Java
Java Eclipse Java, . Eclipse Java, JDK Java. : http://www.eclipse.org/ ( ).
Eclipse for JavaSE .
: File - New - Java Project (. . 1.12):
1.12
: simp Finish (. 1.13):
1.13
, , : File - New - Other (. . 1.14):
1.14
.
: WindowsBuilder - Swing Designer - JFrame (. . 1.15):
1.15
Next prog (. . 1.16):
1.16
Finish - . , .
. JPanel , (. . 1.17):
1.17
Layout : Absolute layout (. . 1.18):
1.18
: (. . 1.19):
1.19
: JTable (). (. .1.20):
1.20
, (. . 1.21):
1.21
, (. . 1.22):
1.22
, () . .
!
model . , . . . . : Insert Columns.
: Insert Rows.
.
. 1 10, . .
.
:
Title - ;
editable - / ;
resizable - / .
: , , , . editable, ( ). resizable; (. . 1.23):
1.23
: Pref.Width.
, , , , Surround with, JScrollPane.
JScrollPane . , . .
(. . 1.24):
1.24
, , .
, - , ! Variable tableTovar ( , ).
. JButton , . - , - , - 17, buttonOK (. . 1.25):
1.25
( ) , . (.. 1.26):
1.26
, , Source :
1.27
makeGet() 1.28:
1.28
(.. 1.29):
1.29
, 10, 5 (.. 1.30):
1.30
: http://localhost/simp/index.php, 1.31 -:
1.31
1.32