HELP!- display other table data on dropdown selection

Hi Gurus,
Just so you know I am completely new to this and I am just developing a website for my local sporting club.
I have set up a table is mysql with 10 columns- round, date, time, home_team, home_logo, home_score, pitch, away_score, away_team , away_logo

I want the site visitor to be able to select a round using a dropdown which i have already coded and seems to work.

HOWEVER this is where i am stuck…
How do i use that selection to populate the information elsewhere in my HTML website.
Sorry for being simplistic.


           <div class="result col-lg-6 col-lg-offset-0 col-md-8 col-md-offset-2 col-sm-10 col-sm-offset-1 clearfix">
              <h4 class="border">Latest Result</h4>
              <div class="team">
                <figure>
                  <img src="img/team2.png" alt="" class="team-background">
                
                  <figcaption>Sandown Lions</figcaption>
                </figure>
              </div>
              <div class="match-details">
                <header class="match-name"><h4>Round <?php 
mysql_connect("localhost","**********","*********");
mysql_select_db("sesccoma_matches");
$sql= "SELECT round FROM teams_ffv_seniors";
$result= mysql_query($sql);	
echo "<select round='round1'>";
while ($row =mysql_fetch_array($result)){
echo "<option Value='" . $row['round'] . "'>" .$row['round'] . "</option>";}
echo "</select>";
?></h4>
</header>
                <div class="score">
                  <span class="color">5</span>
                  <span>:</span>
                  <span>1</span>
                </div>
                <footer class="schedule">
                  <span class="team-name">Ross Reserve</span>
                  <span class="time">13 May </span>
                </footer>
              </div>
              <div class="team">
                <figure>
                  <img src="img/team1.png" alt="" class="team-background2">
                 
                  <figcaption>
                    Somerville Eagles SC
                  </figcaption>

                </figure>
              </div>
            </div>

you need a form to send the selected option to the next page. if you use method="POST" the choice will be published in $_POST['round1'] on th next page.

Thanks Chorn,

So am i correct is saying that the method =‘POST’ needs to be in the php area and then i use $_POST[round1] wherever i want the information to populate?

echo "<select name='round1'>";

while ($row =mysql_fetch_array($result)) {
    echo "<option value='".$row['round']."'>" .$row['round'] . "</option>";
}

echo "</select>";

And you use $_POST['round1'] to get selected data because name of a select is round1.

And don’t use mysql its not supported anymore, use mysqli or PDO.

When you displaying data you need to use htmlspecialchars($input, ENT_QUOTES | ENT_HTML401, "UTF-8");

1 Like

Thank you!
So if i wanted to display the ‘date’ (where it says 13 May in the html )from the row selected by ‘round number’ in the drop down box i would use the $_POST[‘round1’]

didn’t you try it?

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.