function view_companies($company_list) { if (@$_POST['but'] && $_COOKIE["editCompany"] == 2) { editCompany(); echo "Компания отредактирована!"; if ($_COOKIE["log"] != "") { echo "<form method=post action=http://localhost/companies/index.php> \n\t\t\t\t<input class=button type=submit value=ОК>"; } else { echo "<form method=post action=http://localhost/companies/index.php?page=companies> \n\t\t\t\t<input class=button type=submit value=ОК>"; } set_cookie("editCompany", "0"); } if ($_COOKIE["editCompany"] == 1) { $id = $_GET['id']; $result = mysqli_query(connect(), "SELECT * FROM companies WHERE id = '{$id}'"); while ($rslt = mysqli_fetch_row($result)) { $n = $rslt[1]; $a = $rslt[2]; $p = $rslt[3]; } close_bd(); echo "\n\t\t<h1>Редактировать компанию '{$n}'</h1>\n\t\t<form method=post>Наименование<br>\n\n\t\t<input class=input required name=newnameCompany value={$n}> \n\t\t<br><br>Адрес<br>\n\n\t\t<input class=input required name=newadress value={$a}> \n\t\t<br><br>Телефон<br>\n\n\t\t<input class=input required name=newphone value={$p}><br><br>\n\n\t\t<input class=button type=submit value=Редактировать name = but> \n\t\t</form></h1>"; set_cookie("editCompany", "2"); } if ($_COOKIE["editCompany"] == 0 || @(!$_POST['but']) && $_COOKIE["editCompany"] == 2) { echo "<h1>Компании\n\t\t<form method=post action=index.php?page=insertCompany> \n\t\t\n\t\t</form></h1>"; echo "<table border='1'>\n\t\t<tr>\n\t\t<th>id</th>\n\t\t<th>Наименование</th>\n\t\t<th>Адрес</th>\n\t\t<th>Телефон</th>\n\t\t<th>Просмотр товаров</th>\n\t\t</tr>"; foreach ($company_list as $row) { echo "<tr>"; echo "<td>" . $row['id'] . "</td>"; echo "<td>" . $row['name'] . "</td>"; echo "<td>" . $row['adress'] . "</td>"; echo "<td>" . $row['phone'] . "</td>\n\t\t <td><a name=\"view\" href=\"index.php?page=companies&action=view&id=" . $row["id"] . "\"><img src=\"list.ico\" style=\"width: 16px; height: 16px;\">Товары</a>\n\t\t </td>\n"; echo "</tr>"; } echo "</table>"; controller_pages('companies'); } }
$jsondata = array("status" => 0, "msg" => "Unauthorised Access. Invalid Signature"); publishOutput($jsondata); return; } if ($_SERVER['REQUEST_METHOD'] == "GET" && !empty($_GET['method'])) { $request_parts = explode('/', $_GET['method']); $method = $request_parts[1]; switch ($method) { case "addCompany": $jsondata = addCompany(); break; case "getCompany": $jsondata = getCompany(); break; case "editCompany": $jsondata = editCompany(); break; case "updateCompany": $jsondata = updateCompany(); break; case "deleteCompany": $jsondata = deleteCompany(); break; } publishOutput($jsondata); } else { $jsonoutput = array("status" => 0, "msg" => "Unauthorised Access!"); publishOutput($jsonoutput); } ///// All Calls //////////////////////////////////////////////////////////// function addCompany()