Jump to content

Show only checked fields in table


vanea

Recommended Posts

hello. i'm newbie. please help me.

 

I have a page(raport.php) which extract all data from MYSQL table named also "data". this page crate a html table to show all extracted fields

 

raport.php

<?
    include ("../conex.php");
    include ("restrictie.php");

?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title></title>
    </head>
<style type="text/css">
table {font-size: 80%; font-family: Arial,Verdana,Helvetica,sans-serif;  border: 1px thin #000000;}
table.brul {font-family: Arial,Verdana,Helvetica,sans-serif;  border: 0px thin #ccc;}
td.brul {border: 0px #ccc;}
td.aprob {border: 0px #ccc; font-size: 120%; }
td.brul2 {font-size: 300%; border: 0px #ccc;}
tr.brul {border: 0px #ccc;}
td.inregi {border: 0px #ccc; font-style:italic;}
font {font-size: 100%; font-family: Arial,Verdana,Helvetica,sans-serif;}
font.man {font-size: 200%; font-family: Arial,Verdana,Helvetica,sans-serif; font-style: italic;}
font.subsol {font-size: 75%; font-family: Arial,Verdana,Helvetica,sans-serif;}
th {font-family: Arial,Verdana,Helvetica,sans-serif; border: 1px solid #000000; background-color: #eee}
td {font-family: Arial,Verdana,Helvetica,sans-serif; border: 1px solid #000000;}
</style>    <body>

<?php
$ziua=date("d.m.Y");
$ora=date("H:i:s");

$result = mysql_query("SELECT * FROM data");

echo "<table class='brul' cellpadding='0' cellspacing='0' width='100%'>
        <tr>
      <td colspan='1' rowspan='2'></td>
            <td class='brul2'>Lista colaboratorilor</td>
            <td class='aprob'><center>APROB<br>Director adjunct<br>_______ A. Marinsescu<br>&#8222;__&#8221; __________ 20__</center></td>
        </tr>
        <tr>
            <td class='inregi'>Inregistr&#259ri actualizate &#537i tip&#259rite la data de <b>$ziua - $ora</b></td>
        </tr>
</table><br>
<table cellpadding='5' cellspacing='0'>
<tr>
<th>Nr</th>
<th>Nume, prenume</th>
<th>Data na&#351terii</th>
<th>Locul na&#351terii</th>
<th>Sex</th>
<th>Domiciliul</th>
<th>Telefon</th>
<th>Buletin de identitate</th>
<th>Cod personal</th>
<th>Poli&#355a</th>
<th>Institu&#355ia absolvit&#259</th>
<th>Data absolvirii</th>
<th>Forma de &#238nv&#259t&#259m&#238nt</th>
<th>Specialitatea dup&#259 diplom&#259</th>
<th>Calificarea dup&#259 diplom&#259</th>
<th>Studii</th>
<th>Func&#355ia</th>
<th>Data angaj&#259rii</th>
<th>Ordinul angaj&#259rii</th>
<th>Vechime</th>
</tr>";

$i = 0;
while($row = mysql_fetch_array($result))
  {
$i++;
  echo "<tr>";
  echo "<th>".$i."</th>";
  echo "<th>" . $row['nume'] . "</th>";
  echo "<td>" . $row['date'] . "</td>";
  echo "<td>" . $row['loc_nastere'] . "</td>";
  echo "<td>" . $row['sex'] . "</td>";
  echo "<td>" . $row['domiciliul'] . "</td>";
  echo "<td>" . $row['telefon'] . "</td>";
  echo "<td>" . $row['nr_pas'] . "</td>";
  echo "<td>" . $row['cod_pers'] . "</td>";
  echo "<td>" . $row['polita'] . "</td>";
  echo "<td>" . $row['inst_abs'] . "</td>";
  echo "<td>" . $row['data_abs'] . "</td>";
  echo "<td>" . $row['form_stud'] . "</td>";
  echo "<td>" . $row['sp_dipl'] . "</td>";
  echo "<td>" . $row['cal_dipl'] . "</td>";
  echo "<td>" . $row['studii'] . "</td>";
  echo "<td>" . $row['functia'] . "</td>";
  echo "<td>" . $row['data_angaj'] . "</td>";
  echo "<td>" . $row['ordin_angaj'] . "</td>";
  echo "<td>" . $row['vechime'] . "</td>";
  echo "</tr>";
  }
echo "</ul></table><br><font class='subsol'>__________________________________________________________________________________<br>Datele ce se con&#355in &#238n acest tabel nu trebuie s&#259 fie transmise persoanelor ce nu au dreptul de a le vedea.</font>";

mysql_close();
?>

</body>
</html>

 

this page look like this

1.png

 

the problem is: when I want to print this page to simple A4 paper, the last 4-5 vertical fields(columns) of table doesn't fit into the page.

 

so... can you help me to create a page where I will have the form with all vertical fields from table. they will look like text with chekbox. if i will check 10 fields from 15 then will be call page(raport.php) from the top of this post where will be creating the table with only 10 columns.

 

I know it's hard to do this. but please give me at least a little example how to do this thing.

 

thank you. sorry for my bad english

Link to comment
https://forums.phpfreaks.com/topic/163539-show-only-checked-fields-in-table/
Share on other sites

Doing what you want to do is possible but would be very complex and not likely something anyone on here can explain to you how to do with a working example.

 

I suggest if your are not comfortable with the concept that you hire a programmer to do so for you.

 

A quick simple solution would be to modify the existing raport.php file as such

 

The below lines of code reference the table row with each column reported.  If you only wanted to output 10 columns then adjust the data below to only show the data you want by removing the referring lines you don't need.

 

  echo "<tr>";

  echo "<th>".$i."</th>";

  echo "<th>" . $row['nume'] . "</th>";

  echo "<td>" . $row['date'] . "</td>";

  echo "<td>" . $row['loc_nastere'] . "</td>";

  echo "<td>" . $row['sex'] . "</td>";

  echo "<td>" . $row['domiciliul'] . "</td>";

  echo "<td>" . $row['telefon'] . "</td>";

  echo "<td>" . $row['nr_pas'] . "</td>";

  echo "<td>" . $row['cod_pers'] . "</td>";

  echo "<td>" . $row['polita'] . "</td>";

  echo "<td>" . $row['inst_abs'] . "</td>";

  echo "<td>" . $row['data_abs'] . "</td>";

  echo "<td>" . $row['form_stud'] . "</td>";

  echo "<td>" . $row['sp_dipl'] . "</td>";

  echo "<td>" . $row['cal_dipl'] . "</td>";

  echo "<td>" . $row['studii'] . "</td>";

  echo "<td>" . $row['functia'] . "</td>";

  echo "<td>" . $row['data_angaj'] . "</td>";

  echo "<td>" . $row['ordin_angaj'] . "</td>";

  echo "<td>" . $row['vechime'] . "</td>";

  echo "</tr>";

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.