I'm doing on a project but my problem is that i don't have any idea on how to make a print button to print my report..the report is in a table..can somebody please help me with this one?my question is how can i add a button for printing?
here is my code for the viewing of specific record
<?php
include_once 'dbconfig.php';
$username = isset($_GET['username']) ? $_GET['username'] : '';
$password = isset($_GET['password']) ? $_GET['password'] : '';
$province = isset($_GET['province']) ? $_GET['province'] : '';
if(isset($_GET['user_id']))
{
$user_id = $_GET['user_id'];
extract($crud->getID($user_id));
}
?>
<body>
<div id="Survey-view">
<div id="header">
</div>
<p><strong>INFORMATION</strong></p>
<hr />
<div id="main-frame">
<table id="information-content" cellspacing="0">
<thead>
<tr>
<th>Username</th>
<th>Password</th>
<th>Province</th>
</tr>
<tbody>
<tr>
<td><?php echo $username; ?></td>
<td><?php echo $password; ?></td>
<td><?php echo $province; ?></td>
</tr>
</tbody>
</thead>
</table>
</div>
<br />
<br />
<p><strong>ASP</strong></p>
<hr />
<div id="asp">
<table id="asp-content" cellspacing="0">
<thead>
<tr>
<th>Date Survey</th>
<th>Date Submitted</th>
<th>Date Approved</th>
<th>Date Recv'd by Region</th>
<th>Date Recv'd by DARPO</th>
</tr>
<tbody>
<tr>
<td><?php echo $username; ?></td>
<td><?php echo $username; ?></td>
<td><?php echo $username; ?></td>
<td><?php echo $username; ?></td>
<td><?php echo $username; ?></td>
</tr>
</tbody>
</thead>
</table>
</div><!-- End of asp-->
<br />
<br />
<p><strong>DENR/DARPO</strong></p>
<hr />
<div id="denrdarpo">
<table id="denrdarpo-content" cellspacing="0">
<thead>
<tr>
<th>Date Survey</th>
<th>Date Submitted</th>
<th>Date Approved</th>
<th>Date Recv'd by Region</th>
<th>Date Recv'd by DARPO</th>
</tr>
<tbody>
<tr>
<td><?php echo $username; ?></td>
<td><?php echo $username; ?></td>
<td><?php echo $username; ?></td>
<td><?php echo $username; ?></td>
<td><?php echo $username; ?></td>
</tr>
</tbody>
</thead>
</table>
</div><!--End of denrdarpo-->
<br />
<br />
<p><strong>OTHERS</strong></p>
<hr />
<div id="others">
<table id="others-content" cellspacing="0">
<tr>
<td>Project Number</td>
<td><input type="text" value="<?php echo $username; ?>" disabled></td>
<td>Module Number</td>
<td><input type="text" value="<?php echo $username; ?>" disabled></td>
</tr>
<tr>
<td>Fund Year</td>
<td><input type="text" value="<?php echo $username; ?>" disabled></td>
<td>LAD Target</td>
<td><input type="text" value="<?php echo $username; ?>" disabled></td>
</tr>
<tr>
<td>Land Category</td>
<td><select disabled>
<option><?php echo $username; ?></option>
</select></td>
<td>LAnd Type</td>
<td><select disabled>
<option><?php echo $username; ?></option>
</select></td>
</tr>
<tr>
<td>Date Reported</td>
<td><input type="text" value="<?php echo $username; ?>" disabled></td>
<td>Date Suspended</td>
<td><input type="text" value="<?php echo $username; ?>" disabled></td>
</tr>
<tr>
<td>Date Completed</td>
<td><input type="text" value="<?php echo $username; ?>" disabled></td>
<td>Number of Lots</td>
<td><input type="text" value="<?php echo $username; ?>" disabled></td>
</tr>
<tr>
<td>Station</td>
<td><input type="text" value="<?php echo $username; ?>" disabled></td>
<td>Contractor</td>
<td><input type="text" value="<?php echo $username; ?>" disabled></td>
</tr>
<tr>
<td>Agency</td>
<td><input type="text" value="<?php echo $username; ?>" disabled></td>
<td>Cert 40</td>
<td><input type="text" value="<?php echo $username; ?>" disabled></td>
</tr>
</table>
</div>
</div>
</body>
Every time I need to do this I go to my old Gmail account, print a page and then view the source code cus I'm too lazy to remember the functions..
This is how Google does it.
<script type="text/javascript">// <![CDATA[
document.body.onload=function(){document.body.offsetHeight;window.print()};
// ]]></script>
You could just as easily attach it to a button instead of doing it on load.
<button onclick="document.body.offsetHeight;window.print();">Print</button>
Here's a working example.
And this one will remove the button from the printed page:
<button onclick="this.style.display='none';document.body.offsetHeight;window.print();this.style.display='inline';">Print</button>
And another example.
<html>
<head>
<script type="text/javascript">
function openWin()
{
var myWindow=window.open('','','width=200,height=100');
myWindow.document.write("<p>This is 'myWindow'</p>");
myWindow.document.close();
myWindow.focus();
myWindow.print();
myWindow.close();
}
</script>
</head>
<body>
<input type="button" value="Open window" onclick="openWin()" />
</body>
</html>
Related
I have create a table using php dynamically. But i need to update some of the cell value depending on user input. But i can't figure out how to do that. my codes are given below.
I have found a way to make names an array is to use [] in names attribute from stackoverflow. but it didn't work for me.If i echo $_POST['std_name'] in while loop or outside of loop only the last row of student name is counted. Please Someone help. I am stuck here for 3 days.
<form action="" method="post">
<table>
<tr>
<th>Student ID</th>
<th>Student Name</th>
<th>Student Father Name</th>
<th>Student Mother Name</th>
<th>Student Parents Mobile Number</th>
<th>Student Mobile Number</th>
<th>Student Batch Name</th>
<th>Student College Name</th>
<th>Student Gender</th>
<th>Student Picture</th>
<th>Student Admit Date</th>
<th>January</th>
<th>February</th>
<th>March</th>
<th>April</th>
<th>May</th>
<th>June</th>
<th>July</th>
<th>August</th>
<th>September</th>
<th>October</th>
<th>November</th>
<th>December</th>
</tr>
<tr>
<?php
$host="localhost";
$username="root";
$password="";
$db="paragon_first_year";
$qry="select * from `student_info`";
$con=mysqli_connect($host,$username,$password);
mysqli_select_db($con,$db);
$res=mysqli_query($con,$qry);
if(mysqli_num_rows($res)>0){
while($dt=mysqli_fetch_array($res)){?>
<td><input type="text" name="std_id[]" value="<?php echo $dt['std_id']?>"></td>
<td><input type="text" name="std_name[]" value="<?php echo $dt['std_name']?>"></td>
<td><input type="text" name="std_father_name[]" value="<?php echo $dt['std_father_name']?>"></td>
<td><input type="text" name="std_mother_name[]" value="<?php echo $dt['std_mother_name']?>"></td>
<td><input type="text" name="std_parent_mob[]" value="<?php echo $dt['std_parents_mob_no']?>"></td>
<td><input type="text" name="std_mob[]" value="<?php echo $dt['std_mob_no']?>"></td>
<td><?php echo $dt['std_batch_name'] ?></td>
<td><?php echo $dt['std_college_name'] ?></td>
<td><?php echo $dt['std_gender'] ?></td>
<td><img style="height:100px;width:100px;" src="uploadImage/<?php echo $dt['std_name']."_".$dt['std_pic'] ?>" alt=""></td>
<td><?php echo $dt['std_admit_date'] ?></td>
<td><input type="text" name="jan[]" value="<?php echo $dt['january']?>"></td>
<td><input type="text" name="feb[]" value="<?php echo $dt['february']?>"></td>
<td><input type="text" name="mar[]" value="<?php echo $dt['march']?>"></td>
<td><input type="text" name="apr[]" value="<?php echo $dt['april']?>"></td>
<td><input type="text" name="may[]" value="<?php echo $dt['may']?>"></td>
<td><input type="text" name="jun[]" value="<?php echo $dt['june']?>"></td>
<td><input type="text" name="jul[]" value="<?php echo $dt['july']?>"></td>
<td><input type="text" name="aug[]" value="<?php echo $dt['august']?>"></td>
<td><input type="text" name="sep[]" value="<?php echo $dt['september']?>"></td>
<td><input type="text" name="oct[]" value="<?php echo $dt['october']?>"></td>
<td><input type="text" name="nov[]" value="<?php echo $dt['november']?>"></td>
<td><input type="text" name="dec[]" value="<?php echo $dt['december']?>"></td>
</tr><?php
}
}
?>
</table>
<center>
<input type="submit" name="submit" value="Update Data">
</center>
</form>
</body>
my table is showing nicely
hope someone help. Thanks in advance.
You can use array keys to pass information. In this example, the first key is the database primary key, and the second key is the variable name.
The resulting array would look something like this:
$row[123][std_name] = 'joe';
$row[123][std_father_name] = 'bob';
... etc
$row[124][std_name] = 'sally';
$row[124][std_father_name] = 'john';
...etc
Then, as you iterate through the rows, you get the key (123) to use to update the database, as in where std_id=123.
Note: I have used prepared statements to show updating the database. This is essential. Never put variables in a query using concatenation ( i.e., "select * from table where id='$id'")
Lastly, note the structure. Start with PHP, no print or echo statements. This allows you to work with user input and then redirect. First initialize, then work with user input, then do page logic, and lastly get out of php and output the view (html)
This example is not copy and paste; it has things that need to be filled in, and probably debugged. It is merely intended to show the big picture.
<?php
// initialize
$host="localhost";
$username="root";
$password="";
$db="paragon_first_year";
$con=mysqli_connect($host,$username,$password);
// a simple wrapper to make the prepared query more manageable
// see https://phpdelusions.net/mysqli/mysqli_connect#helper
function prepared_query($mysqli, $sql, $params, $types = "")
{
$types = $types ?: str_repeat("s", count($params));
$stmt = $mysqli->prepare($sql);
$stmt->bind_param($types, ...$params);
$stmt->execute();
return $stmt;
}
// work with user input
if($_SERVER['REQUEST_METHOD'] === 'POST') {
$dataRows = (array)$_POST['data'];
foreach($dataRows as $id=>$data) {
$sql = "INSERT INTO student_info SET std_name=?, std_father_name=?, " .
// etc .
"WHERE std_id=?";
$params = array(
$data['std_name'],
$data['std_father_name'],
// etc...
$id
);
// this does the prepare, bind, and execute... Yes, I could just do the
// bind and execute here, but the time savings isn't worth the trouble.
$stmt = prepared_query($con, $sql, $params);
}
// always redirect after a POST
header('Location: /path/to/next/page/or/this/page');
die;
}
// no user input; ok to use plain old query.
$qry="select * from `student_info`";
mysqli_select_db($con,$db);
$res=mysqli_query($con,$qry);
?>
<html>
...
<form action="" method="post">
<table>
<tr>
<th>Student ID</th>
<th>Student Name</th>
<th>Student Father Name</th>
<th>Student Mother Name</th>
<th>Student Parents Mobile Number</th>
<th>Student Mobile Number</th>
<th>Student Batch Name</th>
<th>Student College Name</th>
<th>Student Gender</th>
<th>Student Picture</th>
<th>Student Admit Date</th>
<th>January</th>
<th>February</th>
<th>March</th>
<th>April</th>
<th>May</th>
<th>June</th>
<th>July</th>
<th>August</th>
<th>September</th>
<th>October</th>
<th>November</th>
<th>December</th>
</tr>
<!-- don't need mysqli_num_rows; the while won't loop if no results -->
<?php while($dt=mysqli_fetch_array($res)): ?>
<tr>
<td><?= $dt['std_id'] ?></td>
<td><input type="text" name="data[<?= $dt['std_id'] ?>]['std_name']" value="<?= $dt['std_name'] ?>"></td>
<td><input type="text" name="data[<?= $dt['std_id'] ?>]['std_father_name']" value="<?= $dt['std_father_name'] ?>"></td>
<td><input type="text" name="data[<?= $dt['std_id'] ?>]['std_mother_name']" value="<?= $dt['std_mother_name'] ?>"></td>
<td><input type="text" name="data[<?= $dt['std_id'] ?>]['std_parent_mob']" value="<?= $dt['std_parents_mob_no'] ?>"></td>
<td><input type="text" name="data[<?= $dt['std_id'] ?>]['std_mob']" value="<?= $dt['std_mob_no'] ?>"></td>
<td><?= $dt['std_batch_name'] ?></td>
<td><?= $dt['std_college_name'] ?></td>
<td><?= $dt['std_gender'] ?></td>
<td><img style="height:100px;width:100px;" src="uploadImage/<?= $dt['std_name']."_".$dt['std_pic'] ?>" alt=""></td>
<td><?= $dt['std_admit_date'] ?></td>
<td><input type="text" name="data[<?= $dt['std_id'] ?>]['jan']" value="<?= $dt['january'] ?>"></td>
<td><input type="text" name="data[<?= $dt['std_id'] ?>]['feb']" value="<?= $dt['february'] ?>"></td>
<td><input type="text" name="data[<?= $dt['std_id'] ?>]['mar']" value="<?= $dt['march'] ?>"></td>
<td><input type="text" name="data[<?= $dt['std_id'] ?>]['apr']" value="<?= $dt['april'] ?>"></td>
<td><input type="text" name="data[<?= $dt['std_id'] ?>]['may']" value="<?= $dt['may'] ?>"></td>
<td><input type="text" name="data[<?= $dt['std_id'] ?>]['jun']" value="<?= $dt['june'] ?>"></td>
<td><input type="text" name="data[<?= $dt['std_id'] ?>]['jul']" value="<?= $dt['july'] ?>"></td>
<td><input type="text" name="data[<?= $dt['std_id'] ?>]['aug']" value="<?= $dt['august'] ?>"></td>
<td><input type="text" name="data[<?= $dt['std_id'] ?>]['sep']" value="<?= $dt['september'] ?>"></td>
<td><input type="text" name="data[<?= $dt['std_id'] ?>]['oct']" value="<?= $dt['october'] ?>"></td>
<td><input type="text" name="data[<?= $dt['std_id'] ?>]['nov']" value="<?= $dt['november'] ?>"></td>
<td><input type="text" name="data[<?= $dt['std_id'] ?>]['dec']" value="<?= $dt['december'] ?>"></td>
<?php endwhile; ?>
</tr>
</table>
<center>
<input type="submit" name="submit" value="Update Data">
</center>
</form>
</body>
i tried to edit this soo much times but unable to do so. Please help me.
There is php Code also But it is not showing down. Above this is the if statement for the result more than zero and the only problem i got is that gender checked is working only in one form and in other form the gender checked don't worked. The form element is closing itself after starting. Please Help me i shall be thankful to you.
My Code is here.
<table>
<tr>
<th>S.NO.</th>
<th>Name</th>
<th>Email</th>
<th>Address</th>
<th>City</th>
<th>State</th>
<th>Phone</th>
<th>Gender</th>
<th colspan="2">Action</th>
<th>Delete</th>
</tr>
<?php
while($row = mysqli_fetch_assoc($result))
{
$srnumber++;
?>
<tr class="<?php echo $row['id']; ?> tablerow">
<td><?php echo $srnumber;?></td>
<td class="<?php echo $row['id'];?> td3"><?php echo $row['name'];?></td>
<td class="<?php echo $row['id'];?> td4"><?php echo $row['email'];?></td>
<td class="<?php echo $row['id'];?> td5"><?php echo $row['address'];?></td>
<td class="<?php echo $row['id'];?> td6"><?php echo $row['city'];?></td>
<td class="<?php echo $row['id'];?> td7"><?php echo $row['state'];?></td>
<td class="<?php echo $row['id'];?> td8"><?php echo $row['phone'];?></td>
<td class="<?php echo $row['id'];?> td9"><?php echo $row['gender'];?></td>
<td><a onclick="userupdateclick(<?php echo $row['id']; ?>);" class="update" data-value="<?php echo $row['id']; ?>">Update</a></td>
<td></td>
<td><a onclick="deleteuser(<?php echo $row['id']; ?>);" href="#" class="delete" data-value="<?php echo $row['id']; ?>">Delete</a></td>
</tr>
<tr class="<?php echo $row['id'];?> datavalue" style="display: none;">
<form action="dashboard.php" method="post" id="updateform" class="<?php echo $row['id'];?> formclass">
<td><?php echo $srnumber;?></td>
<td><input type="hidden" name="upid" value="<?php echo $row['id'];?>">
<input type="text" name='upname' id="name" value="<?php echo $row['name'];?>"></td>
<td><input type="text" name='upemail' id="email" value="<?php echo $row['email'];?>"></td>
<td><input type="text" name='upaddress' id="address" value="<?php echo $row['address'];?>"></td>
<td><select name="upcity" id="city">
<option id="blankcity" value="blankcity"></option>
<option value="jalandhar" id="jalandhar" <?php if($row['city']=="jalandhar"){echo 'selected';} ?> >Jalandhar</option>
<option value="chandigarh" id="chandigarh" <?php if($row['city']=="chandigarh"){echo 'selected';} ?> >Chandigarh</option>
<option value="new_chandigarh" id="new_chandigarh" <?php if($row['city']=="new_chandigarh"){echo 'selected';} ?>>New Chandigarh</option>
<option value="panchkula" id="panchkula" <?php if($row['city']=="panchkula"){echo 'selected';} ?> >Panchkula</option>
<option value="sirsa" id="sirsa" <?php if($row['city']=="sirsa"){echo 'selected';} ?> >Sirsa</option>
<option value="mohali" id="mohali" <?php if($row['city']=="mohali"){echo 'selected';} ?> >Mohali</option>
</select></td>
<td><select name="upstate" id="state">
<option id="blankstate" value="blankstate" ></option>
<option value="punjab" id="punjab" <?php if($row['state']=="punjab"){echo 'selected';} ?>>Punjab</option>
<option value="hariyana" id="hariyana" <?php if($row['state']=="hariyana"){echo 'selected';} ?>>Hariyana</option>
<option value="chandigarh" id="schandigarh" <?php if($row['state']=="chandigarh"){echo 'selected';} ?>>Chandigarh</option>
</select></td>
<td><input type="text" name='upphone' id="phone" value="<?php echo $row['phone'];?>"></td>
<td><input type="radio" name="upgender" value="male" id="male" <?php if($row['gender']=='male'){echo 'checked';} ?>>Male
<input type="radio" name="upgender" value="female" id="female" <?php if($row['gender']=='female'){echo 'checked';} ?>>female</td>
<td><a type="button" onclick="usersaveupdate(<?php echo $row['id']; ?>);" href="#" class="saveupdate" data-value="<?php echo $row['id']; ?>"> Save </a></td>
<td><a onclick="usercancelclick(<?php echo $row['id']; ?>);" href="#" class="cancel" data-value="<?php echo $row['id']; ?>">Cancel</a></td>
<td><a onclick="deleteuserform(<?php echo $row['id']; ?>);" href="#" class="delete" data-value="<?php echo $row['id']; ?>">Delete</a></td>
</form>
</tr>
</table>
In my project I need to make the subtotal of the line (quantite*montant) dynamicali.
For the moment I have there:
I want the montant total it is auto make 1*110 for example and it is directly displayed.
My code :
<div id="contenu">
<h2>Renseigner ma fiche de frais du mois <?php echo $numMois."-".$numAnnee ?></h2>
<form method="POST" action="index.php?uc=gererFrais&action=validerMajFraisForfait">
<div class="corpsForm">
<fieldset>
<legend>Eléments forfaitisés
</legend>
<table width=100%>
<tr>
<td>Libelle</td>
<td>Nombre</td>
<td>Montant unitaire</td>
<td>Montant total</td>
</tr>
<?php
foreach ($lesFraisForfait as $unFrais)
{
$idFrais = $unFrais['idfrais'];
$libelle = $unFrais['libelle'];
$quantite = $unFrais['quantite'];
$montant = $unFrais['montant'];
?>
<tr>
<td><?php echo $libelle ?></td>
<td><input type="number" id="idFrais" name="lesFrais[<?php echo $idFrais?>]" size="10" min="0" autocomplete="off" maxlength="5" value="<?php echo $quantite?>" onkeyup="calculer()">
<td><input type="text" id="montant" value="<?php echo $montant ?>" disabled></td>
</tr>
<?php
}
?>
</table>
</fieldset>
</div>
<div class="piedForm">
<p>
<input id="ok" type="submit" value="Valider" size="20" />
<input id="annuler" type="reset" value="Effacer" size="20" />
</p>
</div>
</form>
Here I added another Answer for you.
So basically in your FOREACH Loop you have to create INCREMENTAL VARIABLE
<?php
$incr = 1;
foreach ($lesFraisForfait as $unFrais)
{
$idFrais = $unFrais['idfrais'];
$libelle = $unFrais['libelle'];
$quantite = $unFrais['quantite'];
$montant = $unFrais['montant'];
?>
<tr>
<td><?php echo $libelle ?></td>
<td><input type="number" id="<?php echo 'idFrais'.$incr; ?>" size="10" min="0" autocomplete="off" maxlength="5" value="<?php echo $quantite?>" onkeyup="calculer(this)">
<td><input type="text" id="<?php echo 'montant'.$incr; ?>" value="<?php echo $montant ?>" disabled></td>
<td id='subtotal<?php echo $incr;?>'><?php echo $quantite*$montant; ?></td>
</tr>
<?php
$incr ++;
}
?>
Since you already have ONKEYUP='calculer' on your javascript code this below.
function calculer( e ){
var i = e.getAttribute('id').length;
var input_identifier = e.getAttribute('id').substring(i-1,i);
var subtotal = document.getElementById('subtotal'+input_identifier)
var quantity = e.value;
var montant = document.getElementById('montant'+input_identifier);
subtotal.textContent = parseInt(quantity) + parseInt(montant.value);
return;
}
This should work.
please add td for total :
<tr>
<td><?php echo $libelle ?></td>
<td><input type="number" id="idFrais" name="lesFrais[<?php echo $idFrais?>]" size="10" min="0" autocomplete="off" maxlength="5" value="<?php echo $quantite?>" onkeyup="calculer()">
<td><input type="text" id="montant" value="<?php echo $montant ?>" disabled></td>
<td><input type="text" value="<?php echo ($montant*$quantite) ?>" disabled></td>
</tr>
You just have to add the following 4th TD.
<td><?php echo $quantite*$montant; ?></td>
That should work.
i'm trying to make a table with html and php code which displays dynamically data, above that i use css for this table, and when i use live mode on dreamweaver it displays perfectly the table with css but empty, but not on chrome or whatever is the web browser, and actually i try to integrate the whole html and css in a ready template.
for the information this is the html code that i used:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<div class="background">Placez ici le contenu de class "background"
<center>
<h1>VOS SOUMISSIONS</h1>
<table width="1327" height="128" border="2" cellpadding="20" cellspacing="10">
<tr>
<th width="208">SENDER</th>
<th width="258">TYPE</th>
<th width="258">TITRE</th>
<th width="290">AUTEUR</th>
<th width="289">ABSTRACT</th>
<th width="289">KEYWORDS</th>
<th width="289">DATE</th>
<th width="289">FICHIER</th>
</tr>
<?php
//On recupere les identifiants, les pseudos et les emails des utilisateurs
$result = mysql_query("SELECT * FROM manusrit where id='".$_SESSION["id"]."'");
while($row = mysql_fetch_array($result))
{
?>
<tr>
<td class="left"><?php echo $row['sender']; ?></td>
<td class="left"><?php echo $row['type']; ?></td>
<td class="left"><?php echo htmlentities($row['titre'], ENT_QUOTES, 'UTF-8'); ?></td>
<td class="left"><?php echo htmlentities($row['auteur'], ENT_QUOTES, 'UTF-8'); ?></td>
<td class="left"><?php echo $row['abstract']; ?></td>
<td class="left"><?php echo $row['keywords']; ?></td>
<td class="left"><?php echo $row['date']; ?></td>
<td class="left"><?php echo $row['file']; ?></td>
<td class="left"><form action="/Application/soumissions/<?php echo $row['file']; ?>" method="post">
<input type="submit" value="Download" />
</form></td>
<?php
}
?>
</tr>
</table>
<p> </p><h2><strong>LES AUTRES SOUMISSIONS</strong></h2>';
<table width="1346" height="128" border="2" cellpadding="20" cellspacing="10">
<tr>
<th width="208">SENDER</th>
<th width="258">TYPE</th>
<th width="258">TITRE</th>
<th width="290">AUTEUR</th>
<th width="289">ABSTRACT</th>
<th width="289">KEYWORDS</th>
<th width="289">DATE</th>
<th width="289">FICHIER</th>
<th width="41">ETAT</th>
<th width="84">DECISION</th>
<th width="101">RAPPORT</th>
<th width="120">TELECHARGER</th>
</tr>
<?php
//On recupere les identifiants, les pseudos et les emails des utilisateurs
$req = mysql_query("SELECT * FROM manusrit where id2='1' AND id3='".$_SESSION["id3"]."'");
while (($rows=mysql_fetch_array($req)))
{
?>
<tr>
<td class="left"><?php echo $rows['sender']; ?></td>
<td class="left"><?php echo $rows['type']; ?></a></td>
<td class="left"><?php echo htmlentities($rows['titre'], ENT_QUOTES, 'UTF-8'); ?></td>
<td class="left"><?php echo htmlentities($rows['auteur'], ENT_QUOTES, 'UTF-8'); ?></a></td>
<td class="left"><?php echo $rows['abstract']; ?></td>
<td class="left"><?php echo $rows['keywords']; ?></td>
<td class="left"><?php echo $rows['date']; ?></td>
<td class="left"><?php echo $rows['file']; ?></td>
<td class="left"><?php echo $rows['etat']; ?></td>
<td class="left"><?php echo $rows['decision']; ?></td>
<td class="left"><form action="/Application/rapport/<?php echo $row['rapport']; ?>" method="post">
<input type="submit" value="Voir le rapport" />
</form></td>
<td class="left"><form action="/Application/soumissions/<?php echo $rows['file']; ?>" method="post">
<input type="submit" value="Download" />
</form></td>
<?php
}
?>
</tr>
</table>
</center>
</div>
</body>
</html>
And this is the css code:
.background {
font-family: "Courier New", Courier, monospace;
font-size: 12px;
font-style: italic;
color: #FFF;
background-color: #666;
background-repeat: repeat;
width: 1327px;
}
Thnx for your help!
Presuming that the html provided is your full document, you don't have the css file included. You will need to add
<link rel="stylesheet" type="text/css" href="style.css">
before the end of the head tag. Also the href attribute must be whatever your css file is actually named.
I want to sum table rows dynamically as the user inputs values. Since the number of rows can vary I want to use a php loop to accomplish this. I'm having problems getting the loop to work correctly. If, for example, there are two individual rows to sum only the bottom row will be summed.
<script type="text/javascript">
var sumScoreF = function(a) {
var rowtotal = 0;
n = new Array();
for (i = 1; i <= 3; i++) {
if (parseInt(document.getElementById(a + i).value) > 0) {
n[i] = parseInt(document.getElementById(a + i).value);
rowtotal += n[i];
}
}
document.getElementById(a + 'total').value = rowtotal;
};
</script>
The following is an example of a single row sum. The total column continues to be summed as values are entered. This is a nice effect but not necessary.
<table>
<tr>
<td>col1</td>
<td>col2</td>
<td>col3</td>
<td>total</td>
</tr>
<tr>
<td>
<input name="p1g1" id="p1g1" type="text" value="" onChange="sumScoreF('p1g')" />
</td>
<td>
<input name="p1g2" id="p1g2" type="text" value="" onChange="sumScoreF('p1g')" />
</td>
<td>
<input name="p1g3" id="p1g3" type="text" value="" onChange="sumScoreF('p1g')" />
</td>
<td>
<input name="p1gtotal" id="p1gtotal" type="text" value="" />
</td>
</tr>
</table>
Here is my attempt at looping additional rows using php and javascript. The first row will not sum but the second row will. I think the problem is with the javascript variable "m" in that it goes directly to the last row but I can't figure out how to fix it.
<table>
<tr>
<td>col1</td>
<td>col2</td>
<td>col3</td>
<td>total</td>
</tr>
<?php for($j=1;$j<=3;$j++) { ?>
<script type="text/javascript">
var k = <?php echo json_encode($j); ?>;
var m = 'p'+k+'g';
</script>
<tr>
<td>
<input name="<?php echo 'p'.$j.'g1'; ?>" id="<?php echo 'p'.$j.'g1'; ?>" type="text" onChange="sumScoreF('m')" />
</td>
<td>
<input name="<?php echo 'p'.$j.'g2'; ?>" id="<?php echo 'p'.$j.'g2'; ?>" type="text" onChange="sumScoreF('m')" />
</td>
<td>
<input name="<?php echo 'p'.$j.'g3'; ?>" id="<?php echo 'p'.$j.'g3'; ?>" type="text" onChange="sumScoreF('m')" />
</td>
<td>
<input name="<?php echo 'p'.$j.'gtotal'; ?>" id="<?php echo 'p'.$j.'gtotal'; ?>" type="text" />
</td>
</tr>
<?php } ?>
Any help is greatly appreciated. Thanks.
Used PHP to echo the loop variable within the onChange javascript function call:
<table>
<tr>
<td>col1</td>
<td>col2</td>
<td>col3</td>
<td>total</td>
</tr>
<?php for($j=1;$j<=3;$j++) { ?>
<tr>
<td>
<input name="<?php echo 'p'.$j.'g1'; ?>" id="<?php echo 'p'.$j.'g1'; ?>" type="text" onChange="sumScoreF('<?php echo 'p'.$j.'g'; ?>')" />
</td>
<td>
<input name="<?php echo 'p'.$j.'g2'; ?>" id="<?php echo 'p'.$j.'g2'; ?>" type="text" onChange="sumScoreF('<?php echo 'p'.$j.'g'; ?>')" />
</td>
<td>
<input name="<?php echo 'p'.$j.'g3'; ?>" id="<?php echo 'p'.$j.'g3'; ?>" type="text" onChange="sumScoreF('<?php echo 'p'.$j.'g'; ?>')" />
</td>
<td>
<input name="<?php echo 'p'.$j.'gtotal'; ?>" id="<?php echo 'p'.$j.'gtotal'; ?>" type="text" />
</td>
</tr>
<?php } ?>