Your mistakes are just "in the part that’s working".
The first problem (it may just be failure to ask the question) is that the TAG is missing select
with a name
involving your option group. If this is missing from your code you cannot do this:
if (isset($_POST['time1'])) {
$time1 = $_POST['time1'];
}
if (isset($_POST['time2'])) {
$time2 = $_POST['time2'];
}
To solve this problem, add the selects with the name time1
and time2
, as your need.
Ex:
<select name=time2">
<optgroup label="TIMES:">
(...)
</select>
The 2nd problem is in the query made. It is only returned time_nome
. Therefore, the value in selects are not filled.
To solve this problem you need to return the time id in select by changing the query and then using that id in the value
select. The column name used as id
was not indicated in the question, but supposing that it is id_time
your code should be:
$result_time = "SELECT id_time, time_nome FROM time GROUP BY time_nome";
And then:
<option value="<?php echo $rows_time['id_time']; ?>"><?php echo $rows_time['time_nome']; ?></option>
Dias, had the name, was just an error after inserting the question here. I made the changes in select and option as you mentioned above, but unfortunately still no data go. ):
– mat word
@matword then correct the question and check again that there is no other difference. There may be several mistakes, not sense the ones I pointed out to the ones.
– tvdias