duplicate values in a selectbox html/php [duplicate]












-3















This question is an exact duplicate of:




  • How to echo PHP and HTML in if statement

    1 answer




I have an update page with a select box which is filled by PHP...how can I hide the duplicate values?



this is my code;



Corrective action:



<label id="required">*</label><br>
<select name="correctiemaatregelen" class="form-control" id="correctiemaatregelen" style="width: 300px" required>
<?php while ($row27 = mysqli_fetch_assoc($result27)):; ?>
<option selected value="<?php echo $row27['correctie_maatregelen'];?>"><?php echo $row27['correctie_maatregelen'];?></option>
<?php endwhile;?>
<?php while ($row28 = mysqli_fetch_assoc($result28)):; ?>
<option selected value="<?php echo $row28['correctie_maatregelen_select'];?>"><?php echo $row28['correctie_maatregelen_select'];?></option>
<?php endwhile;?>
</select>


Selectbox



Sorry if my English is horrible










share|improve this question















marked as duplicate by Funk Forty Niner php
Users with the  php badge can single-handedly close php questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 19 '18 at 13:48


This question was marked as an exact duplicate of an existing question.











  • 2




    Remove the semi-colons in the loops; they end the statements. You should be getting errors here for the endwhile's.
    – Funk Forty Niner
    Nov 19 '18 at 13:43








  • 2




    This also appears to be a repost of this question.
    – Funk Forty Niner
    Nov 19 '18 at 13:46










  • You have too many unclosed questions, IMHO.
    – Funk Forty Niner
    Nov 19 '18 at 13:46
















-3















This question is an exact duplicate of:




  • How to echo PHP and HTML in if statement

    1 answer




I have an update page with a select box which is filled by PHP...how can I hide the duplicate values?



this is my code;



Corrective action:



<label id="required">*</label><br>
<select name="correctiemaatregelen" class="form-control" id="correctiemaatregelen" style="width: 300px" required>
<?php while ($row27 = mysqli_fetch_assoc($result27)):; ?>
<option selected value="<?php echo $row27['correctie_maatregelen'];?>"><?php echo $row27['correctie_maatregelen'];?></option>
<?php endwhile;?>
<?php while ($row28 = mysqli_fetch_assoc($result28)):; ?>
<option selected value="<?php echo $row28['correctie_maatregelen_select'];?>"><?php echo $row28['correctie_maatregelen_select'];?></option>
<?php endwhile;?>
</select>


Selectbox



Sorry if my English is horrible










share|improve this question















marked as duplicate by Funk Forty Niner php
Users with the  php badge can single-handedly close php questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 19 '18 at 13:48


This question was marked as an exact duplicate of an existing question.











  • 2




    Remove the semi-colons in the loops; they end the statements. You should be getting errors here for the endwhile's.
    – Funk Forty Niner
    Nov 19 '18 at 13:43








  • 2




    This also appears to be a repost of this question.
    – Funk Forty Niner
    Nov 19 '18 at 13:46










  • You have too many unclosed questions, IMHO.
    – Funk Forty Niner
    Nov 19 '18 at 13:46














-3












-3








-3








This question is an exact duplicate of:




  • How to echo PHP and HTML in if statement

    1 answer




I have an update page with a select box which is filled by PHP...how can I hide the duplicate values?



this is my code;



Corrective action:



<label id="required">*</label><br>
<select name="correctiemaatregelen" class="form-control" id="correctiemaatregelen" style="width: 300px" required>
<?php while ($row27 = mysqli_fetch_assoc($result27)):; ?>
<option selected value="<?php echo $row27['correctie_maatregelen'];?>"><?php echo $row27['correctie_maatregelen'];?></option>
<?php endwhile;?>
<?php while ($row28 = mysqli_fetch_assoc($result28)):; ?>
<option selected value="<?php echo $row28['correctie_maatregelen_select'];?>"><?php echo $row28['correctie_maatregelen_select'];?></option>
<?php endwhile;?>
</select>


Selectbox



Sorry if my English is horrible










share|improve this question
















This question is an exact duplicate of:




  • How to echo PHP and HTML in if statement

    1 answer




I have an update page with a select box which is filled by PHP...how can I hide the duplicate values?



this is my code;



Corrective action:



<label id="required">*</label><br>
<select name="correctiemaatregelen" class="form-control" id="correctiemaatregelen" style="width: 300px" required>
<?php while ($row27 = mysqli_fetch_assoc($result27)):; ?>
<option selected value="<?php echo $row27['correctie_maatregelen'];?>"><?php echo $row27['correctie_maatregelen'];?></option>
<?php endwhile;?>
<?php while ($row28 = mysqli_fetch_assoc($result28)):; ?>
<option selected value="<?php echo $row28['correctie_maatregelen_select'];?>"><?php echo $row28['correctie_maatregelen_select'];?></option>
<?php endwhile;?>
</select>


Selectbox



Sorry if my English is horrible





This question is an exact duplicate of:




  • How to echo PHP and HTML in if statement

    1 answer








php






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 19 '18 at 13:43









Akshãy Paghdar

2,93521429




2,93521429










asked Nov 19 '18 at 13:37









Rob

32




32




marked as duplicate by Funk Forty Niner php
Users with the  php badge can single-handedly close php questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 19 '18 at 13:48


This question was marked as an exact duplicate of an existing question.






marked as duplicate by Funk Forty Niner php
Users with the  php badge can single-handedly close php questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 19 '18 at 13:48


This question was marked as an exact duplicate of an existing question.










  • 2




    Remove the semi-colons in the loops; they end the statements. You should be getting errors here for the endwhile's.
    – Funk Forty Niner
    Nov 19 '18 at 13:43








  • 2




    This also appears to be a repost of this question.
    – Funk Forty Niner
    Nov 19 '18 at 13:46










  • You have too many unclosed questions, IMHO.
    – Funk Forty Niner
    Nov 19 '18 at 13:46














  • 2




    Remove the semi-colons in the loops; they end the statements. You should be getting errors here for the endwhile's.
    – Funk Forty Niner
    Nov 19 '18 at 13:43








  • 2




    This also appears to be a repost of this question.
    – Funk Forty Niner
    Nov 19 '18 at 13:46










  • You have too many unclosed questions, IMHO.
    – Funk Forty Niner
    Nov 19 '18 at 13:46








2




2




Remove the semi-colons in the loops; they end the statements. You should be getting errors here for the endwhile's.
– Funk Forty Niner
Nov 19 '18 at 13:43






Remove the semi-colons in the loops; they end the statements. You should be getting errors here for the endwhile's.
– Funk Forty Niner
Nov 19 '18 at 13:43






2




2




This also appears to be a repost of this question.
– Funk Forty Niner
Nov 19 '18 at 13:46




This also appears to be a repost of this question.
– Funk Forty Niner
Nov 19 '18 at 13:46












You have too many unclosed questions, IMHO.
– Funk Forty Niner
Nov 19 '18 at 13:46




You have too many unclosed questions, IMHO.
– Funk Forty Niner
Nov 19 '18 at 13:46












1 Answer
1






active

oldest

votes


















1














You can try this php snippet:-



$options = array();
while ($row27 = mysqli_fetch_assoc($result27)){
$options = $row27['correctie_maatregelen'];
}
while ($row28 = mysqli_fetch_assoc($result28)){
$options = $row28['correctie_maatregelen_select'];
}
$options = array_unique($options);


And for the rendering options, you can use foreach loop.



<label id="required">*</label><br>
<select name="correctiemaatregelen" class="form-control" id="correctiemaatregelen" style="width: 300px" required>
<?php foreach($options as $color): ?>
<option selected value="<?php echo $color;?>"><?php echo $color;?></option>
<?php endforeach;?>
</select>





share|improve this answer























  • why don't you explain why their code failed?
    – Funk Forty Niner
    Nov 19 '18 at 13:48










  • also, the foreach won't work. You did the same error they did in the while loops.
    – Funk Forty Niner
    Nov 19 '18 at 13:49










  • Answer Edited..
    – Akshãy Paghdar
    Nov 19 '18 at 13:51


















1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














You can try this php snippet:-



$options = array();
while ($row27 = mysqli_fetch_assoc($result27)){
$options = $row27['correctie_maatregelen'];
}
while ($row28 = mysqli_fetch_assoc($result28)){
$options = $row28['correctie_maatregelen_select'];
}
$options = array_unique($options);


And for the rendering options, you can use foreach loop.



<label id="required">*</label><br>
<select name="correctiemaatregelen" class="form-control" id="correctiemaatregelen" style="width: 300px" required>
<?php foreach($options as $color): ?>
<option selected value="<?php echo $color;?>"><?php echo $color;?></option>
<?php endforeach;?>
</select>





share|improve this answer























  • why don't you explain why their code failed?
    – Funk Forty Niner
    Nov 19 '18 at 13:48










  • also, the foreach won't work. You did the same error they did in the while loops.
    – Funk Forty Niner
    Nov 19 '18 at 13:49










  • Answer Edited..
    – Akshãy Paghdar
    Nov 19 '18 at 13:51
















1














You can try this php snippet:-



$options = array();
while ($row27 = mysqli_fetch_assoc($result27)){
$options = $row27['correctie_maatregelen'];
}
while ($row28 = mysqli_fetch_assoc($result28)){
$options = $row28['correctie_maatregelen_select'];
}
$options = array_unique($options);


And for the rendering options, you can use foreach loop.



<label id="required">*</label><br>
<select name="correctiemaatregelen" class="form-control" id="correctiemaatregelen" style="width: 300px" required>
<?php foreach($options as $color): ?>
<option selected value="<?php echo $color;?>"><?php echo $color;?></option>
<?php endforeach;?>
</select>





share|improve this answer























  • why don't you explain why their code failed?
    – Funk Forty Niner
    Nov 19 '18 at 13:48










  • also, the foreach won't work. You did the same error they did in the while loops.
    – Funk Forty Niner
    Nov 19 '18 at 13:49










  • Answer Edited..
    – Akshãy Paghdar
    Nov 19 '18 at 13:51














1












1








1






You can try this php snippet:-



$options = array();
while ($row27 = mysqli_fetch_assoc($result27)){
$options = $row27['correctie_maatregelen'];
}
while ($row28 = mysqli_fetch_assoc($result28)){
$options = $row28['correctie_maatregelen_select'];
}
$options = array_unique($options);


And for the rendering options, you can use foreach loop.



<label id="required">*</label><br>
<select name="correctiemaatregelen" class="form-control" id="correctiemaatregelen" style="width: 300px" required>
<?php foreach($options as $color): ?>
<option selected value="<?php echo $color;?>"><?php echo $color;?></option>
<?php endforeach;?>
</select>





share|improve this answer














You can try this php snippet:-



$options = array();
while ($row27 = mysqli_fetch_assoc($result27)){
$options = $row27['correctie_maatregelen'];
}
while ($row28 = mysqli_fetch_assoc($result28)){
$options = $row28['correctie_maatregelen_select'];
}
$options = array_unique($options);


And for the rendering options, you can use foreach loop.



<label id="required">*</label><br>
<select name="correctiemaatregelen" class="form-control" id="correctiemaatregelen" style="width: 300px" required>
<?php foreach($options as $color): ?>
<option selected value="<?php echo $color;?>"><?php echo $color;?></option>
<?php endforeach;?>
</select>






share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 19 '18 at 13:51

























answered Nov 19 '18 at 13:48









Akshãy Paghdar

2,93521429




2,93521429












  • why don't you explain why their code failed?
    – Funk Forty Niner
    Nov 19 '18 at 13:48










  • also, the foreach won't work. You did the same error they did in the while loops.
    – Funk Forty Niner
    Nov 19 '18 at 13:49










  • Answer Edited..
    – Akshãy Paghdar
    Nov 19 '18 at 13:51


















  • why don't you explain why their code failed?
    – Funk Forty Niner
    Nov 19 '18 at 13:48










  • also, the foreach won't work. You did the same error they did in the while loops.
    – Funk Forty Niner
    Nov 19 '18 at 13:49










  • Answer Edited..
    – Akshãy Paghdar
    Nov 19 '18 at 13:51
















why don't you explain why their code failed?
– Funk Forty Niner
Nov 19 '18 at 13:48




why don't you explain why their code failed?
– Funk Forty Niner
Nov 19 '18 at 13:48












also, the foreach won't work. You did the same error they did in the while loops.
– Funk Forty Niner
Nov 19 '18 at 13:49




also, the foreach won't work. You did the same error they did in the while loops.
– Funk Forty Niner
Nov 19 '18 at 13:49












Answer Edited..
– Akshãy Paghdar
Nov 19 '18 at 13:51




Answer Edited..
– Akshãy Paghdar
Nov 19 '18 at 13:51



Popular posts from this blog

MongoDB - Not Authorized To Execute Command

Npm cannot find a required file even through it is in the searched directory

in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith