Created
December 7, 2015 18:57
-
-
Save VictorFursa/77ac45102ed20bcd32a6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| include_once("connectDatabases.php"); | |
| ?> | |
| <!DOCTYPE> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <title>Добовление товаров</title> | |
| </head> | |
| <body> | |
| <h1 align="center">Работа с Mysql <br> (")(o_O)(")</h1> | |
| <hr> | |
| <form method="POST" action="Appliances.php"> | |
| <select name="appliances"> | |
| <?php | |
| $result = mysql_query("SELECT * FROM appliances"); | |
| while ($res = mysql_fetch_array($result)){ | |
| echo "<option "." value='".$res['id']."'>".$res['categoria']."</option>"; | |
| }?> | |
| </select> | |
| <em>Добавить товар в категорию:<input type="text" name="product"> <br><br> | |
| <input type="submit" value="Просмотреть" name="submit"> | |
| <input type="submit" value="Добавить" name="add"> | |
| </form> | |
| <br> | |
| <?php | |
| if (isset ($_POST['submit'])) { | |
| if (isset($_POST['appliances'])) { | |
| $query = mysql_query("SELECT * FROM appliances JOIN product ON product.appliances_id = appliances.id"); | |
| while ($row = mysql_fetch_array($query)) { | |
| if ($row['appliances_id'] == $_POST['appliances']) { | |
| echo $row['product_name']."<br>"; | |
| } | |
| } | |
| } | |
| } | |
| if(isset($_POST['add'])) { | |
| if (isset($_POST['product'])) { | |
| $product = $_POST['product']; | |
| if (isset($_POST['appliances'])) { | |
| $id = $_POST['appliances']; | |
| mysql_query("INSERT INTO product(appliances_id,product_name) VALUES('$id','$product') "); | |
| echo " в категорию успешнно добавлен товар: <b>$product"; | |
| } | |
| } | |
| } | |
| ?> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment