Click here to Skip to main content
15,441,757 members
Home / Discussions / Web Development
   

Web Development

 
PinnedHow to get an answer to your question Pin
Chris Maunder4-Sep-10 2:25
cofounderChris Maunder4-Sep-10 2:25 
PinnedHOW TO ANSWER A QUESTION PinPopular
Chris Maunder12-Jul-09 22:40
cofounderChris Maunder12-Jul-09 22:40 
QuestionHow to build course Content page in Html Css Pin
Member 1577435021-Sep-22 2:02
MemberMember 1577435021-Sep-22 2:02 
QuestionCoworking Pin
Member 1576609713-Sep-22 3:21
MemberMember 1576609713-Sep-22 3:21 
QuestionASP.NET Webform to go live Pin
Shao Voon Wong7-Sep-22 0:18
mvaShao Voon Wong7-Sep-22 0:18 
AnswerRe: ASP.NET Webform to go live Pin
Richard Deeming7-Sep-22 0:50
mveRichard Deeming7-Sep-22 0:50 
QuestionWeb Development Pin
William Worse3-Sep-22 1:52
MemberWilliam Worse3-Sep-22 1:52 
AnswerRe: Web Development Pin
Richard MacCutchan3-Sep-22 2:58
mveRichard MacCutchan3-Sep-22 2:58 
QuestionHTML6 as a "living document" will that work? Pin
Member 150787168-Aug-22 14:35
MemberMember 150787168-Aug-22 14:35 
QuestionFullscreen scrolling image and adding more images Pin
Member 157264913-Aug-22 6:33
MemberMember 157264913-Aug-22 6:33 
QuestionHow to get saved data from option select in PHP? Pin
imbruceter1-Aug-22 0:36
Memberimbruceter1-Aug-22 0:36 
I'm quite new to PHP. I have a selection dropdown, which sends the data to the phpmyadmin database.
This works fine, but I'd like it to be selected as default when I'm opening it again.

Here is how my code currently looks like:
PHP
<select name="category">
    <?php while ($category = mysqli_fetch_assoc($categories)) : ?>
    <option value="<?= $category['id'] ?>"><?= $category['title'] ?></option>
    <?php endwhile ?>
</select>


What I have tried:
PHP
<option value="<?= $category['id'] ?>"><?= $category['title'] ? "selected" : ""?></option>


I basically just inserted "selected" into it, but it's not the correct way, because every single option is shown as "selected".

Here is an image about the frontend:
https://i.imgur.com/I2cXYrN.png[^]

Does anyone know how to make it to work?
Thank you for being here! Smile | :)
AnswerRe: How to get saved data from option select in PHP? Pin
Richard MacCutchan1-Aug-22 1:03
mveRichard MacCutchan1-Aug-22 1:03 
GeneralRe: How to get saved data from option select in PHP? Pin
imbruceter1-Aug-22 1:27
Memberimbruceter1-Aug-22 1:27 
GeneralRe: How to get saved data from option select in PHP? Pin
Richard MacCutchan1-Aug-22 1:29
mveRichard MacCutchan1-Aug-22 1:29 
GeneralRe: How to get saved data from option select in PHP? Pin
imbruceter1-Aug-22 1:37
Memberimbruceter1-Aug-22 1:37 
AnswerRe: How to get saved data from option select in PHP? Pin
Sandrahdes1-Sep-22 21:06
MemberSandrahdes1-Sep-22 21:06 
QuestionASP.Net MVC : Send an array in POST Pin
hageshii26-Jul-22 3:39
Memberhageshii26-Jul-22 3:39 
QuestionSelf Signed Cert Questions Pin
Kevin Marois23-Jul-22 19:03
professionalKevin Marois23-Jul-22 19:03 
AnswerRe: Self Signed Cert Questions Pin
Richard Deeming24-Jul-22 21:30
mveRichard Deeming24-Jul-22 21:30 
GeneralRe: Self Signed Cert Questions Pin
Kevin Marois25-Jul-22 9:11
professionalKevin Marois25-Jul-22 9:11 
GeneralRe: Self Signed Cert Questions Pin
Richard Deeming25-Jul-22 21:17
mveRichard Deeming25-Jul-22 21:17 
GeneralRe: Self Signed Cert Questions Pin
Kevin Marois27-Jul-22 6:45
professionalKevin Marois27-Jul-22 6:45 
GeneralRe: Self Signed Cert Questions Pin
Richard Deeming27-Jul-22 22:01
mveRichard Deeming27-Jul-22 22:01 
GeneralRe: Self Signed Cert Questions Pin
Kevin Marois28-Jul-22 5:51
professionalKevin Marois28-Jul-22 5:51 
GeneralRe: Self Signed Cert Questions Pin
Richard Deeming28-Jul-22 6:46
mveRichard Deeming28-Jul-22 6:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.