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:
Struktura tabeli dla 'klient' -- CREATE TABLE klient ( id int(11) NOT NULL AUTO_INCREMENT, company varchar(255) DEFAULT NULL, city varchar(100) DEFAULT NULL, country varchar(100) DEFAULT NULL, postcode smallint(20) DEFAULT '0', street_name varchar(100) DEFAULT NULL, street_number smallint(30) DEFAULT '0', PRIMARY KEY (id) ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
Struktura tabeli dla 'orderstatus' -- CREATE TABLE orderstatus ( id int(11) NOT NULL AUTO_INCREMENT, confirm datetime DEFAULT '0000-00-00 00:00:00', ordernr int(11) DEFAULT NULL, pieces int(11) DEFAULT NULL, width float DEFAULT NULL, height float DEFAULT NULL, quantity float DEFAULT NULL, sendby varchar(255) DEFAULT NULL, technology varchar(100) DEFAULT NULL, dispatch datetime DEFAULT '0000-00-00 00:00:00', `comment` varchar(255) DEFAULT NULL, client_id int(11) DEFAULT NULL, PRIMARY KEY (id), KEY client_id (client_id) ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
Kod formularza:
<html> <head> <meta http-equiv="Content-type" content="text/html; charset=utf-8"></head> <style type="text/css"> TD{color:#353535;font-family:veranda} TH{color:#FFFFFF;font-family:veranda;background-color:#336699} </style> <?php (include "function.php"); db::connect(); $osobysql = "SELECT company FROM klient"; $osobysql[$row['id']] = $row['company']; } ?> <center> <br /> <center>Add new rekord: <br /><hr> <form action = "add_rekord.php" method = "post"> <table border="0" cellpadding="0" cellspacing="5" wudth="100%" align="center"> <tr> <td bgcolor="#FFFFFF"> Order number : </td> <td> <input type = "text" name = "ordernr" maxlength="20" size = "10"><br /> </td> </tr> <tr> <td bgcolor="#FFFFFF"> Confirm Date : </td> <td> <input type = "text" name = "confirm" maxlength="20" size = "10"><br /> </td> </tr> <tr> <td bgcolor="#FFFFFF"> Number of pieces : </td> <td> <input type = "text" name = "pieces" maxlength="20" size = "10"><br /> </td> </tr> <tr> <td bgcolor="#FFFFFF"> Width : </td> <td bgcolor="#FFFFFF"> <input type = "text" name = "width" maxlength="20" size = "10"><br /> </td> </tr> <tr> <td bgcolor="#FFFFFF"> Height : </td> <td> <input type = "text" name = "height" maxlength="20" size = "10"><br /> </td> </tr> <tr> <td bgcolor="#FFFFFF"> Send By : </td> <td> <input type = "text" name = "sendby" maxlength="20" size = "10"><br /> </td> </tr> <tr> <td bgcolor="#FFFFFF"> Print technology : </td> <td> <input type = "text" name = "technology" maxlength="20" size = "10"><br /> </td> </tr> <tr> <td bgcolor="#FFFFFF"> Dispatch date : </td> <td> <input type = "text" name = "dispatch" maxlength="20" size = "10"><br /> </td> </tr> <tr> <td bgcolor="#FFFFFF"> Comment : </td> <td> <input type = "text" name = "comment" maxlength="20" size = "10"><br /> </td> </tr> <tr> <td bgcolor="#FFFFFF" width="30%">Client</td> <td bgcolor="#FFFFFF"> <select name="company"> <option value="" selected>Select client</option> <?php foreach ($osobysql as $id => $company) { ?> <option value="<?php <?php } ?> </table> <input type = "submit" value = "Dodaj"> </form> </center> </html>
Dlaczego nie widzę w liście rozwijanej rekordów z tabeli klient?