objectdesc.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. include "auth.php";
  3. if (isset($_POST['machine'])) {
  4. $machineid = htmlentities(mysqli_real_escape_string($link, $_POST['machine']));
  5. $query = "SELECT * FROM object_detals WHERE id_name=$machineid";
  6. $result = mysqli_query($link, $query) or die("Ошибка " . mysqli_error($link));
  7. while ($res1 = mysqli_fetch_array($result)) {
  8. $query2 = "SELECT * FROM type_detals WHERE id=" . $res1['id_type'] . "";
  9. $result2 = mysqli_query($link, $query2) or die("Ошибка " . mysqli_error($link));
  10. while ($res2 = mysqli_fetch_array($result2)) {
  11. $query3 = "SELECT name FROM type_object WHERE id=" . $res2['id_type'] . "";
  12. $result3 = mysqli_query($link, $query3) or die("Ошибка " . mysqli_error($link));
  13. $res3 = mysqli_fetch_array($result3);
  14. $typeobject=$res3['name'];
  15. }
  16. }
  17. echo "<b> Тип: " .$typeobject."</b>";
  18. echo "<br>";
  19. echo "<br>";
  20. echo "
  21. <form action='?act=object' id='my_form2' method='POST'>
  22. <input type='hidden' name='id_name' value='$machineid'> ";
  23. $query = "SELECT * FROM object_detals WHERE id_name=$machineid";
  24. $result = mysqli_query($link, $query) or die("Ошибка " . mysqli_error($link));
  25. while ($res1 = mysqli_fetch_array($result))
  26. {
  27. $id_type=$res1['id_type'];
  28. $query2 = "SELECT * FROM object_detals WHERE id_type=$id_type";
  29. $result2 = mysqli_query($link, $query2) or die("Ошибка " . mysqli_error($link));
  30. while ($res2 = mysqli_fetch_array($result2)) {
  31. $type=$res2['type'];
  32. switch($type) {
  33. case 'typetext' :
  34. echo "[text] ";
  35. break;
  36. case 'typeint' :
  37. echo "[int] ";
  38. break;
  39. case 'typefloat' :
  40. echo "[float] ";
  41. break;
  42. case 'typebinary' :
  43. echo "[binary] ";
  44. break;
  45. }
  46. echo $res2['name_detals'] . " ";
  47. if($res1['link']!=null) {
  48. echo "<a href=" . $res1['link'] . ">" . $res2[$type] . "</a>";
  49. }
  50. else {
  51. echo "
  52. <input type='hidden' name='type".$id_type."' value='$type'>
  53. <input type='text' name='count".$id_type."' value ='".$res2[$type]."' > ";
  54. }
  55. }
  56. echo "<br>";
  57. }
  58. echo " <input id='save' type='submit' name='save' value='Сохранить'>
  59. </form>";
  60. }
  61. else
  62. echo "invalidate";