I can’t place a new column inside a table

Asked

Viewed 138 times

2

I wish you could help me to place a column (painted in yellow) as follows which is in the attached image. inserir a descrição da imagem aqui

I leave here also my code at the moment so I can give a help:

<?php
    $database ="anomalias";
    $server="127.0.0.1";

    $connect= mysql_connect('localhost','root','');
    $selecionar= mysql_select_db('anomalias');
    if ($selecionar) 
        {
            $SQL = "SELECT * FROM laboratorios";
            $result = mysql_query($SQL);

            echo"<br>";                
            echo "<table border='1'>";            
            echo "<td style='padding: 10px 20px 10px 20px'><h6>Salas</h6></td>";


            while ($db_field = mysql_fetch_array($result) ) 
            {       
                echo "<td style='padding: 10px 20px 20px 20px'> <a href='phpeditarsala.php?id=".$db_field['sala']."'>".$db_field['sala']."</a></td>";

            }

            echo "</table>";
        }

    ?>  
  • You want to put 8 columns in the table, but your query only returns 7 records, resulting in only 7 columns ?

  • For example, whenever I add a field in the comic I like to see the inserted field and also a column below where there is a button to edit!

  • How many columns the table has in the database ?

  • Currently there is only one that displays the rooms, and I wanted that under it (line) there is another that displays a button to edit the data

  • You want the button down, so okay.

  • Yes I always want another button to appear if another room appears, then that button to take the id and edit the same

  • Okay, I’ll post your solution.

  • There, check if that’s what you want.

  • The harm is that the way you put the data is shown in column and not in line and so if there is 1000 data in the comic the web page will have an infinite scroll

  • So I referred to aesthetics, regarding the amount of results, to avoid scroll too large, you can page the results.

  • I tried paging another job and I couldn’t... I’m still a javascript learner

  • But thanks, I’ve already managed to find a way with your help.

  • I can help you create the paging feature, you can email me. Since solved, give me the +1 and put as best solution, please thank you.

  • That ugly, where are the Trs ?

Show 9 more comments

1 answer

1


Your code is playing the tag <tr></tr> designating the lines.

Aesthetically it is ugly, you can improve this by adding another field in this table where you will put a button on the same line where I printed your result.

<?php
    $database ="anomalias";
    $server="127.0.0.1";

    $connect= mysql_connect('localhost','root','');
    $selecionar= mysql_select_db('anomalias');
    if ($selecionar) 
        {
            $SQL = "SELECT * FROM laboratorios";
            $result = mysql_query($SQL);

            echo"<br>";                
            echo "<table border='1'>";            



            while ($db_field = mysql_fetch_array($result) ) 
            {       
                echo "<tr><td style='padding: 10px 20px 10px 20px'><h6>Salas</h6></td>";
                echo "<td style='padding: 10px 20px 20px 20px'> <a href='phpeditarsala.php?id=".$db_field['sala']."'>".$db_field['sala']."</a></td></tr>";

            }

            echo "</table>";
        }

    ?>  

I believe that’s it.

Browser other questions tagged

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