Witam.

Mój problem nad którym głowie się od kilku dni:

Dwie tabele Klient i orderstatus. W tabeli orderstatus rekord company typu INT który odnosi sie do tabeli klient po jego ID.
W formularzu w którym wpisuje dane do tabeli orderstatus mam takie zapytanie które wyróżniłem poniżej jako fragment kodu.
Chciałbym w tym formularzu aby było widoczne że pobieram z tabeli KLIENT rekordy company, city , postcode na ekranie natomiast w kodzie podejrzewam że byc powinno pobrane jego ID z tabeli klient aby PHP wiedziało o jakiego klienta mi chodzi. Prosze mnie poprawić jeśli sie myle.
No i tutaj zaczynają sie schody ponieważ nie wiem jak wyświetlic na ekran podczas wypełniania formularza dane istotne dla uzytkownika czyli z tabeli KLIENT company, city, postcode a w kodzie przekazać jego ID do bazy oraz wyswietlić całość z abeli orderstatus na ekran wraz z tym ID z tabeli klient wraz z tymi trzema rekordami. Sorry za złe sformułowanie ale mam nadzieje że widomo o co biega i ktoś mi pomoże z tym , bede bardzo wdzięczny.

Poniżej zrzut z dwóch tabel i fragment kodu z formularza i kod którym wyświetlam cała tabele orderstatus na ekran.

Pozdrawiam

Tabela klient
  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` int(255) DEFAULT '0',
  10. `street_name` varchar(100) DEFAULT NULL,
  11. `street_number` smallint(30) DEFAULT '0',
  12. PRIMARY KEY (`id`),
  13. KEY `company` (`company`)
  14. ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=7 ;
  15.  
  16. --
  17. -- Zrzut danych tabeli `klient`
  18. --
  19.  
  20. INSERT INTO `klient` VALUES (1, 'Mediahuset', 'Vejle', 'Denmark', 9560, 'Mariagervej', 2);
  21. INSERT INTO `klient` VALUES (2, 'Nordsign', 'Hadsund', 'Denmark', 9560, 'Mariagervej', 5);
  22. INSERT INTO `klient` VALUES (6, 'Nordsign-PL', 'rogozno', 'Polska', 64610, 'Fabryczna', 7);


Tabela orderstatus
  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. `company` int(255) DEFAULT NULL,
  17. PRIMARY KEY (`id`),
  18. KEY `company` (`company`)
  19. ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=9 ;
  20.  
  21. --
  22. -- Zrzut danych tabeli `orderstatus`
  23. --
  24.  
  25. INSERT INTO `orderstatus` VALUES (8, '2009-07-29 00:00:00', 5901, 450, 120, 400, NULL, 'ups', 'jv22', '2009-08-12 00:00:00', 'proba dzialania', 0);


Fragment kodu formularza wraz z tym nieszczęsnym selectem:
  1. <tr>
  2. <td bgcolor="#FFFFFF" width="30%">Client</td>
  3. <td bgcolor="#FFFFFF">
  4. <?php
  5.  
  6. $result = mysql_query("SELECT company, postcode, city FROM klient");
  7. $link = "";
  8. while ($data = mysql_fetch_assoc($result))
  9. $link .= "<option value='".$data['company']."','".$data['postcode']."','".$data['city']."'>".$data['company'].",".$data['postcode'].",".$data['city']."</option>";
  10. echo "<select name='company' style='width:250px;'>$link></select>";
  11.  
  12. ?>
  13.  
  14.  
  15.  
  16.   </table>
  17.  
  18.  
  19.  
  20.  <input type = "submit" value = "Dodaj">
  21. </form>


No i całość strona główna z selectem z tabeli orderstatus, niestety przy tym kodzie co podałem rekord company ma wartośc 0 a powinien miec taka jaka wybrałem z selecta

  1. <html>
  2. <head>
  3. <meta http-equiv="Content-type" content="text/html; charset=utf-8"></head>
  4.  
  5.  
  6.  
  7.  
  8.  
  9. <?php
  10. (include "function.php");
  11. connect();
  12.  
  13.  
  14.  
  15. $query="SELECT * FROM orderstatus";
  16. $result=mysql_query($query);
  17.  
  18. $num=mysql_numrows($result);
  19.  
  20.  
  21. echo "<b><center>Struktura bazy danych</b><hr><br><br>";
  22.  echo '<a href="./formularz-order.php">Dodaj zlecenie</a> <br>';
  23. echo '<a href="./klient-add.html">Dodaj nowego klienta</a> <br><hr></center>';
  24. $i=0;
  25. while ($i < $num) {
  26.  
  27. $confirm=mysql_result($result,$i,"confirm");
  28. $ordernr=mysql_result($result,$i,"ordernr");
  29. $pieces=mysql_result($result,$i,"pieces");
  30. $width=mysql_result($result,$i,"width");
  31. $height=mysql_result($result,$i,"height");
  32. $quantity=((($width*$height)/10000)*$pieces);
  33. $sendby=mysql_result($result,$i,"sendby");
  34. $technology=mysql_result($result,$i,"technology");
  35. $dispatch=mysql_result($result,$i,"dispatch");
  36. $comment=mysql_result($result,$i,"comment");
  37. $company=mysql_result($result,$i,"company");
  38.  
  39. $i++;
  40. echo "<b>Delivery date: $confirm </b><br>Order number: $ordernr<br>Number of pieces: $pieces<br>Width: $width<br>Height: $height<br>square meters : $quantity<br>send by: $sendby<br>technology :$technology<br>Sent from us: $dispatch<br>comments: $comment<br> Company: $company<br>";
  41.  
  42. }
  43.  
  44.  
  45. ?>
  46. </html>