Display data on screen according to clicked ID

Asked

Viewed 1,093 times

1

Hello, I’m having a little problem here maybe easy to solve, but I’m not getting it. I have a first screen (.php students) where will have several search terms, and one of them will be by study time, where will bring me some results from the database. So far everything is working perfectly. Follow the search screen print.

inserir a descrição da imagem aqui

Follow the code to make this search work:

<?php
                                                    if($startaction == 5){
                                                            if($acao == "search_time") {
                                                                    if(empty($_POST['select_time'])) {
                                                                        echo'<script type="text/javascript">abre_modal( \'#dialog\' );</script>';
                                                                    } else {
                                                                    //pegar nome via post
                                                                    $searched_time = $_POST['select_time'];
                                                                    $result = mysql_query("SELECT * FROM alunos WHERE Dia_Horario LIKE '%".$searched_time."%' " );
                                                        $check_time = mysql_num_rows($result);
                                                                        if($check_time >= 1){
                                                                             while($ln = mysql_fetch_array($result)) {
                                                                                $radio = $ln['ID'];
                                                                                $id = $ln['ID'];
                                                                                $full_name = $ln['Nome_completo'];
                                                                                $hora_estudo = $ln['Dia_Horario'];

                                                        ?>

                            <div class="scroll-y">

                                <tr>
                                    <td> <a data-toggle="modal" data-target="#dialog01" href="#<?php echo $radio; ?>"> Clicar Aqui</a></td>
                                    <a href="">
                                        <td>
                                            <?php echo $id; ?>
                                        </td>
                                    </a>
                                    <td>
                                        <a href='http://www.dpaulatreinamentos.com/system/teste03/views/pages/aluno.php?id_aluno=<?php echo $id; ?>' class='nomecompleto' title='".$full_name."'>
                                            <?php echo $full_name ?>
                                        </a>
                                    </td>
                                    <td>
                                        <?php echo $hora_estudo; ?>
                                    </td>
                                </tr>

                            </div>


                            <?php

                                                                } } else {
                                                                    echo'<script type="text/javascript">abre_modal( \'#dialog\' );</script>';

                                                                }
                                                                }
                                                            }

                                                            }

                                ?>   

After we click on the name of the student, a new page is loaded, on this page will have the complete data of the student but with fields for editing where I can work only with this student, register new classes, change data but only this student, is already pulling the ID on the link and loading the new page already with the ID in the URL, but the data does not appear, follow print of the second screen. inserir a descrição da imagem aqui

It follows part of the code I put:

 <?php 



    $searched_time = $_POST['select_time'];

                               $pegaid = $_GET["ID"];
                                                                    $result = mysql_query("SELECT * FROM alunos WHERE ID = '$pegaid'" );
                                                        $check_time = mysql_num_rows($result);
                                                                        if($check_time >= 1){
                                                                             while($ln = mysql_fetch_array($result)) {
                                                                                $radio = $ln['ID'];
                                                                                $id = $ln['ID'];
                                                                                $full_name = $ln['Nome_completo'];
                                                                                $hora_estudo = $ln['Dia_Horario'];

       echo $id;                           

  ?>
   <form>
     <?php echo $pegaid; ?>
     <input type="text" class="txt-medium bradius" value="<?php echo $full_name; ?>"/>
     <input type="submit" value="Atualizar" class="sb-search-medium" />
  </form>
</div>
<footer>

</footer>

Would you have someone to help me? If so, I will thank you very much.

2 answers

1

I advise you to work on mysqli then you can select only table that is

SELECT * FROM alunos

after you give a

<? php while($ln = mysqli_fetch_assoc($result)){ ?>

then lists each one that will only display and or that will edit

<div id="<?php echo $ln['id']; ?>">

<h4><?php echo $ln['Nome_completo']; ?></h4>
<p><?php echo $ln['Dia_Horario']; ?></p>

</div>

and don’t forget to close a while

<?php } ?>

of course to update some functions of the bank you will need to use the update.

  • That’s not what I need, but it’s worth the help

1

It is not working because in your print the variable name is (id_student), however in your script you are trying to rescue (ID).

So that’s not it: $pegaid = $_GET["ID"];

And yes this: $pegaid = $_GET["id_student"];

That must be the reason, without student no return is not even?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.