All welcome. There is a form of adding "uslugi" and in it the field "idOpis" and now when I add to the table "uslugi" a number is selected from the field "idOpis", and how do I get to choose not a number, but a letter designation corresponding to this Id in another the table with which it is associated? Those. in this case, the data was taken from the note field of the "opisanie" table
form code now:
$connection=mysql_connect("localhost","reklama","reklama") ; $db=mysql_select_db(reklama); mysql_set_charset("utf8"); if (!$connection || !$db) { exit(mysql_error());} include_once("db1.php"); function names() { $query="SELECT `idOpis` FROM `uslugi`ORDER BY `uslugi`.`idOpis` ASC"; $query_res=mysql_query($query); $names = array(); while($row = mysql_fetch_assoc($query_res)) { $names[] = $row; } return $names; } $names = names(); echo "<select name='idOpis'>"; foreach($names as $item) { echo "<option value=' ".$item['idOpis']." '>".$item['idOpis']." </option>"; } echo "</select><br/><br/>"; ?> Цена:<br/> <input type="text" name="cena" /><br/><br/> <input type="submit" name="add" value="Добавить" /> </form> <?php include_once("db1.php"); if (isset($_POST['add'])) { $naimenUslugi=strip_tags(trim($_POST['naimenUslugi'])) ; $idOpis = $_POST['idOpis']; $cena = $_POST['cena']; $result = mysql_query(" INSERT INTO uslugi (naimenUslugi,idOpis,cena) VALUES ('{$naimenUslugi}', '{$idOpis}', '{$cena}') "); if($result==TRUE){ echo 'Новость успешно добавлена'; } else echo mysqli_connect_error() . 'Ошибка БД. Обратитесь к администратору' ; mysql_close(); } ?> </body> </html> 