Итак, у меня есть таблица, по которой я хочу выбрать идентификатор и название ресторана и вставить его в новую таблицу для сделки, связанной с этим рестораном.
<?php
// First we start a session which allow for us to store information as SESSION variables.
session_start();
// "require" creates an error message and stops the script. "include" creates an error and continues the script.
require "config.php";
$sql = "SELECT * FROM Restaurants";
$result= mysqli_query($link, $sql) or die("Bad Query: $sql");
$row = mysqli_fetch_array($result);
if (isset($_GET['post'])) {
$Restaurant_ID = mysqli_real_escape_string($link, $_GET['Restaurant_ID']);
$Name = mysqli_real_escape_string($link, $_GET['Name']);
}
?>
<select name="Restaurant_ID">
<?php
foreach($result as $row)
{
$output .= '<option value ="'. $row['Restaurant_ID'] .'">'. $row['Name'] .'</option>';
}
echo $output;
?>
</select>
</div>
<select name="Name">
<?php
foreach($result1 as $row1)
{
$output .= '<option '. $row1['Name'] .'>'. $row1['Name'] .'</option>';
}
echo $output;
?>
</select>
когда он помещает их в таблицу, он присваивает $ Name & $ Restaurant_ID одинаковое имя и вставляет только $ Restaurant_ID в оба поля.
Сайт, чтобы увидеть, как он работает http://thefoodieapp.co.uk/thefoodieappv1/deal_form.php?signup=success
