filipgothic 0 Junior Poster in Training

hey, I need help with this code, I have made database and code for inserting data, now I need code that will display data for group, in database I have groupnaziv, and id, here is code for inserting which works great, after that I will post code that I need help with

 <p align="center"><font color="#0000FF">Registracija koncerata</font></p>
  <p align="center">Naziv koncerta: 
    <input type="text" name="enter_koncert" id="enter_koncert" />
  </p>
  <p align="center"><font color="#0000FF">Broj prodatih karata</font></p>
  <p align="center">Broj: 
    <input type="text" name="enter_karte" id="enter_karte" />
  </p>

   <p align="center"><font color="#0000FF">Mesto</font></p>
  <p align="center">Mesto: 
    <input type="text" name="enter_mesto" id="enter_mesto" />
  </p>

  <p align="center"><font color="#0000FF">Datum</font></p>
  <p align="center">Datum: 
    <input type="text" name="enter_datum" id="enter_datum" />
  </p>

  <p align="center">Grupa kojoj koncert pripada: 
    <select name="grupa_select" id="grupa_select">
      <?php
    while($row = mysql_fetch_array($sql_2))
    {
    echo "<option>".$row['grupanaziv']."</option>";
    }
    ?>
    </select>
  </p>
  <p align="center">
    <input type="submit" name="unos_koncert" id="unos_koncert" value="- Sacuvaj koncert-" />
  </p>
  <p>
    <label></label>
  </p>

 <?php
  if (isset($_POST['unos_koncert'])){
    $enter_koncert = $_POST['enter_koncert'];
    $enter_karte = $_POST['enter_karte'];
    $enter_mesto = $_POST['enter_mesto'];
    $enter_datum = $_POST['enter_datum'];
    $grupa_select = $_POST['grupa_select'];
    if (empty($enter_koncert)){
  die ("ERROR: Niste uneli naziv koncerta!");
  }
  $con = mysql_connect($hostname,$db_username,$db_password);
    if (!$con)
    {
        die('Could not connect: ' . mysql_error());
    }
    mysql_select_db($db_name, $con);
        $sql = mysql_query("select id from grupe where grupanaziv ='".$grupa_select."'");
        $grupa = mysql_fetch_array($sql);
    $sql = "insert into koncerti values (NULL,'".$enter_koncert."','".$enter_karte."','".$enter_mesto."','".$enter_datum."',".$grupa['id'].")";
    if (!mysql_query($sql,$con))
    {
        die('Error: ' . mysql_error());
    }
    echo "Podaci uspesno uneseni u bazu podataka!";
  }
  ?>

here is code that I work with, I need same this that is inserted displayed, but I need options selected first which I made, but now code has to chose that option and extract data for that only, not whole data from that table

<p align="center"><font color="#0000FF">Pregled grupa</font></p>

<p align="center">Grupa kojoj koncert pripada: 
    <select name="grupa_select" id="grupa_select">
      <?php
    while($row = mysql_fetch_array($sql))
    {
    echo "<option>".$row['grupanaziv']."</option>";
    }
    ?>
    </select>
  </p>
  <p align="center">
    <input type="submit" name="pregled_grupe" id="pregled_grupe" value="- Izaberi grupu-" />
  </p>
  <p>
    <label></label>
  </p>
  <?php

so after pressing submit button, pregled_grupe should display data that from previous group selected ['grupanaziv'] and select id from group because other table is connected with group by id, naziv is just name to be displayed, id is important, so now I need code that will extract data from table concerts,concert has grupa_id is = id (from table grupe)

if u guys dont understand, I can post whole code and table, or give u access to my site

thanks in advance

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.