Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP][MySQL]lista rozwijana 2 tabele
walldeck
post
Post #1





Grupa: Zarejestrowani
Postów: 78
Pomógł: 0
Dołączył: 13.03.2006
Skąd: Rogoźno Wlkp.

Ostrzeżenie: (0%)
-----


Witam.

Mój problem:
Chciałbym z tabeli klient wyciagnąc do formularza za pomoca listy rozwijanej rekord COMPANY lecz za bardzo nie wiemjak to zjeść.
Wydziergałem coś takiego ale za bardzo to nie działa.

poniżej struktury dwóch tabel oraz kod z formularzem:

  1. Struktura tabeli dla 'klient'
  2. --
  3.  
  4. CREATE TABLE klient (
  5. id int(11) NOT NULL AUTO_INCREMENT,
  6. company varchar(255) DEFAULT NULL,
  7. city varchar(100) DEFAULT NULL,
  8. country varchar(100) DEFAULT NULL,
  9. postcode smallint(20) DEFAULT '0',
  10. street_name varchar(100) DEFAULT NULL,
  11. street_number smallint(30) DEFAULT '0',
  12. PRIMARY KEY (id)
  13. ) ENGINE=MyISAM DEFAULT CHARSET=latin1;


  1. Struktura tabeli dla 'orderstatus'
  2. --
  3.  
  4. CREATE TABLE orderstatus (
  5. id int(11) NOT NULL AUTO_INCREMENT,
  6. confirm datetime DEFAULT '0000-00-00 00:00:00',
  7. ordernr int(11) DEFAULT NULL,
  8. pieces int(11) DEFAULT NULL,
  9. width float DEFAULT NULL,
  10. height float DEFAULT NULL,
  11. quantity float DEFAULT NULL,
  12. sendby varchar(255) DEFAULT NULL,
  13. technology varchar(100) DEFAULT NULL,
  14. dispatch datetime DEFAULT '0000-00-00 00:00:00',
  15. `comment` varchar(255) DEFAULT NULL,
  16. client_id int(11) DEFAULT NULL,
  17. PRIMARY KEY (id),
  18. KEY client_id (client_id)
  19. ) ENGINE=MyISAM DEFAULT CHARSET=latin1;



Kod formularza:

  1. <html>
  2. <head>
  3. <meta http-equiv="Content-type" content="text/html; charset=utf-8"></head>
  4. <style type="text/css">
  5. TD{color:#353535;font-family:veranda}
  6. TH{color:#FFFFFF;font-family:veranda;background-color:#336699}
  7. </style>
  8. <?php
  9. (include "function.php");
  10. db::connect();
  11.  
  12. $osobysql = "SELECT company FROM klient";
  13. $results = mysql_query($osobysql)
  14. or die ("niepoprawne zapytanie: " .mysql_error());
  15. while ($row = mysql_fetch_array($results)) {
  16. $osobysql[$row['id']] = $row['company'];
  17. }
  18. ?>
  19.  
  20. <center>
  21. <br /> <center>Add new rekord: <br /><hr>
  22. <form action = "add_rekord.php" method = "post">
  23. <table border="0" cellpadding="0" cellspacing="5" wudth="100%" align="center">
  24. <tr>
  25. <td bgcolor="#FFFFFF">
  26.        Order number :
  27.    </td>
  28.    <td>
  29.   <input type = "text" name = "ordernr" maxlength="20" size = "10"><br />
  30.   </td>
  31.   </tr>
  32. <tr>
  33. <td bgcolor="#FFFFFF">
  34.        Confirm Date :
  35.    </td>
  36.    <td>  
  37.    <input type = "text" name = "confirm" maxlength="20" size = "10"><br />
  38.    </td>
  39.    </tr>
  40. <tr>
  41. <td bgcolor="#FFFFFF">
  42.        Number of pieces :
  43.    </td>
  44.    <td>    
  45.    <input type = "text" name = "pieces" maxlength="20" size = "10"><br />
  46.    </td>
  47.    </tr>
  48. <tr>
  49. <td bgcolor="#FFFFFF">
  50.        Width :
  51.    </td>
  52. <td bgcolor="#FFFFFF">  
  53.    <input type = "text" name = "width" maxlength="20" size = "10"><br />
  54.    </td>
  55.    </tr>
  56. <tr>
  57. <td bgcolor="#FFFFFF">
  58.        Height :
  59.    </td>
  60.    <td>  
  61.    <input type = "text" name = "height" maxlength="20" size = "10"><br />
  62.    </td>
  63.    </tr>
  64. <tr>
  65. <td bgcolor="#FFFFFF">
  66.        Send By :
  67.    </td>
  68.    <td>  
  69.    <input type = "text" name = "sendby" maxlength="20" size = "10"><br />
  70.   </td>
  71.    </tr>
  72.    
  73. <tr>
  74. <td bgcolor="#FFFFFF">
  75.        Print technology :
  76.    </td>
  77.    <td>  
  78.    <input type = "text" name = "technology" maxlength="20" size = "10"><br />
  79.   </td>
  80.    </tr>
  81. <tr>
  82. <td bgcolor="#FFFFFF">
  83.        Dispatch date :
  84.    </td>
  85.    <td>  
  86.    <input type = "text" name = "dispatch" maxlength="20" size = "10"><br />
  87.   </td>
  88.    </tr>
  89.    
  90. <tr>
  91. <td bgcolor="#FFFFFF">
  92.        Comment :
  93.    </td>
  94.    <td>  
  95.    <input type = "text" name = "comment" maxlength="20" size = "10"><br />
  96.   </td>
  97.    </tr>
  98. <tr>
  99. <td bgcolor="#FFFFFF" width="30%">Client</td>
  100. <td bgcolor="#FFFFFF">
  101. <select name="company">
  102. <option value="" selected>Select client</option>
  103. <?php
  104. foreach ($osobysql as $id => $company) {
  105. ?>
  106. <option value="<?php
  107. echo $id; ?>" ><?php
  108. echo $company; ?></option>
  109. <?php
  110. }
  111. ?>    
  112.    
  113.    
  114.    </table>
  115.  
  116.  
  117.  
  118.   <input type = "submit" value = "Dodaj">
  119. </form>
  120. </center>
  121.  
  122.  
  123. </html>


Dlaczego nie widzę w liście rozwijanej rekordów z tabeli klient?
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 26.08.2025 - 00:04