<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Laurens van Oorschot</title>
    <description>The latest articles on DEV Community by Laurens van Oorschot (@laurensvo92).</description>
    <link>https://dev.to/laurensvo92</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F392339%2F5decec98-0e21-4c39-84b7-1b3c1b690146.jpeg</url>
      <title>DEV Community: Laurens van Oorschot</title>
      <link>https://dev.to/laurensvo92</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/laurensvo92"/>
    <language>en</language>
    <item>
      <title>How do I get the selected value of the second dropdown from the first dropdown via MY-SQL? </title>
      <dc:creator>Laurens van Oorschot</dc:creator>
      <pubDate>Thu, 21 May 2020 21:36:11 +0000</pubDate>
      <link>https://dev.to/laurensvo92/how-do-i-get-the-selected-value-of-the-second-dropdown-from-the-first-dropdown-via-my-sql-a3d</link>
      <guid>https://dev.to/laurensvo92/how-do-i-get-the-selected-value-of-the-second-dropdown-from-the-first-dropdown-via-my-sql-a3d</guid>
      <description>&lt;p&gt;I am building an editor for a blog. Each post will be categorised. I am trying to get all the posts, with the category that they have been assigned to be displayed as dropdown menu. So, when the user clicks on a post title from the first dropdown menu, then the second category dropbox will have the selected category associated with it, and display all the other categories in the same dropbox. So. user can change the category of article. I am struggling with it and don't know what I am doing wrong. Can anyone help?&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;                if(isset($_POST['Ga'])) {
                      $db = new mysqli("160.153.129.204", "laurensvo92", "90F0411553l", "lvo92");//set your database handler
  $query = "SELECT c.catid , a.titel , c.cat FROM artikelen a JOIN Categorie c ON c.catid = a.catid  where  c.catid = a.catid";
  $result = $db-&amp;gt;query($query);
          while($row = $result-&amp;gt;fetch_assoc()){

if($row ['a.catid'] = ['c.catid'])
   {$selected = ($row['catid'] == $result);


    echo "&amp;lt;option value=\"".$row["catid"]."\" ".($selected ? " selected=\"selected\"":"")."&amp;gt;".$row["cat"]."&amp;lt;/option&amp;gt;";



}}}
?&amp;gt;















&amp;lt;?php   $link = mysqli_connect("160.153.129.204", "laurensvo92", "90F0411553l", "lvo92");

  $db = new mysqli("160.153.129.204", "laurensvo92", "90F0411553l", "lvo92");//set your database handler
  $query = "SELECT c.catid , a.titel , c.cat FROM artikelen a JOIN Categorie c ON c.catid = a.catid";
  $result = $db-&amp;gt;query($query);

echo(    "&amp;lt;form action='test.php' method='post' enctype='multipart/form-data'&amp;gt;");





?&amp;gt;          




    &amp;lt;/select&amp;gt;

    &amp;lt;select id='subcatsSelect'&amp;gt;

        &amp;lt;?php
        //  $query = "SELECT catid, cat FROM Categorie";
  $result = $db-&amp;gt;query($query);

  while($row = $result-&amp;gt;fetch_assoc()){
   // $subcats[$row['catid']][] = array("catid" =&amp;gt; $row['catid'], "val" =&amp;gt; $row['cat']);

        echo(       "&amp;lt;option value='catid'&amp;gt; {$row['titel']}&amp;lt;/option&amp;gt;");
  }






        ?&amp;gt;
        &amp;lt;/select&amp;gt;



      &amp;lt;select id='categoriesSelect'&amp;gt;

        &amp;lt;?php     $result = $db-&amp;gt;query($query);
while($row = $result-&amp;gt;fetch_assoc()){
          $resultofcar = ("&amp;lt;option value='{$row ['catid']}'&amp;gt; {$row['cat']}&amp;lt;/option&amp;gt;");
echo($resultofcar);


  }

?&amp;gt;
         &amp;lt;input id='Ga' type='submit'  value='Ga'name='Ga' /&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

</description>
      <category>php</category>
      <category>mysql</category>
    </item>
  </channel>
</rss>
