How to make student id card in horizontal shape - php

How to make student id card in horizontal shape?
This code showing id card in vertical shape and I want in horizontal shape. How can I fix this issue? Please help me to fix this issue.
I want it like this:
----------------------------------
| Photo | Student Detail |
----------------------------------
here |Student Name : |
|Roll No: |
photo |Classs : |
|Grn : |
|Father Name : |
----------------------------------
and now its showing like this:
--------------------------------------------------------
Photo | Student Detail |
--------------------------------------------------------
here |
|
photo |
|
|
--------------------------------------------------------
Student Name: |
Roll No: |
Class: |
Grn: |
Father Name: |
--------------------------------------------------------
Code:
echo "<table class='hovertable' border='1' cellpadding='0' cellspacing='0'>";
echo "<tr><th>Photo</th><th>Student Detail</th></tr>";
if ($rows > 0) {
while($row = mysql_fetch_array($result)) {
echo "<tr><td>";
echo "<img src=http://localhost/student/images/".$row['photo'] ." width='150' height='100'></a></td>";
echo "<tr><tr><td>";
echo $row['name'];
echo "</tr></td>";
echo "<tr><td>";
echo $row['rollno'];
echo "</tr></td>";
echo "<td>";
echo $row['fathername'];
echo "</tr></td>";
echo "<td>";
echo $row['class'];
echo "</td></tr>";
}
} else {
echo "<tr><td colspan=\"5\">No results found!</td></tr>";
}
echo "</table>";

The details are below the photo, because you start a new row before $row['name']. You cannot nest rows the way you do. If you want to have the details side by side with the photo, you must start with a <td> tag and then break the parts with either <br/>
echo '<td>';
echo $row['name'], '<br/>';
echo $row['rollno'], '<br/>';
echo $row['fathername'], '<br/>';
echo $row['class'], '<br/>';
echo '</td></tr>';
or <div> tags, as #Fabio already suggested in the comments.

Related

How to passed value from looping result to new object?

How to passed value from looping result to new object using button ?
For example :
I have input text to get order number. The result for Order number 0001 is like this
| Order No | Delivery No | Invoice No | Delivery Date | Action |
=================================================================
| 0001 | D0001 | I0001 | 21-03-2018 |(process button)|
| 0001 | D0002 | I0002 | 21-03-2018 |(process button)|
I have no trouble to display table above, the problem is how to make those process button work ? Process button is to display detail of one invoice. From example above, if i click process button for Invoice I0002 result will be like this
| No. Item | Item Name | Price | Qty | Amount |
================================================
| 0000001 | apple | 5 | 2 | 10 |
and so on..
So far my work for first table
$select_order = "SELECT ORDER_NO, DELI_NO, INV_NO, DELI_DT, AMOUNT FROM ORDER WHERE ORDER_NO = '$text_input_order'";
$exec_order = odbc_exec($connSQL, $select_order);
while(odbc_fetch_row($exec_order))
{
$get_order_no = odbc_result($exec_order, "ORDER_NO");
$get_deli_no = odbc_result($exec_order, "DELI_NO");
$get_inv_no = odbc_result($exec_order, "INV_NO");
$get_deli_dt = odbc_result($exec_order, "DELI_DT");
$get_amount = odbc_result($exec_order, "AMOUNT");
?>
<tr>
<td><? echo $get_order_no;?></td>
<td><? echo $get_deli_no ;?></td>
<td><? echo $get_inv_no ;?></td>
<td><? echo $get_deli_dt ;?></td>
<td><? echo $get_amount ;?></td>
<td><input type="submit" value="proces" name="proces"></td>
</tr>
<?
}
Now I need your help to make second table using process button.
Please made the changes as per your requirements after button click.
<script>
$(function(){
$('button[name=proces]').click(function(){
var id= $(this).attr("id");
//some action here
//ex:
window.location.href="<put your site url>?id="+id;
//or an ajax function
});
});
</script>
<?php
$select_order = "SELECT ORDER_NO, DELI_NO, INV_NO, DELI_DT, AMOUNT FROM
ORDER WHERE ORDER_NO = '$text_input_order'";
$exec_order = odbc_exec($connSQL, $select_order);
while(odbc_fetch_row($exec_order))
{
$get_order_no = odbc_result($exec_order, "ORDER_NO");
$get_deli_no = odbc_result($exec_order, "DELI_NO");
$get_inv_no = odbc_result($exec_order, "INV_NO");
$get_deli_dt = odbc_result($exec_order, "DELI_DT");
$get_amount = odbc_result($exec_order, "AMOUNT");
?>
<tr>
<td><? echo $get_order_no;?></td>
<td><? echo $get_deli_no ;?></td>
<td><? echo $get_inv_no ;?></td>
<td><? echo $get_deli_dt ;?></td>
<td><? echo $get_amount ;?></td>
<td><input type="button" id=".$get_inv_no." value="proces" name="proces"></td>
</tr>
<?
}

if the date is same just display one time

if the date is same with database date just display one time only.Example:database date 16/2 then all 16/2 must display in a box, but other date also need to display. who help me to solve this problem.
<h1>Payment Record</h1>
<?php
$user_check=$_SESSION['login_user'];
$query = "SELECT * FROM `confirm_order` where customer = '$user_check'";
$result=mysqli_query($mysqli,$query);
while($row=mysqli_fetch_array($result))
{
?>
<table style="width:100%;border:1px solid black;margin-bottom:20px;">
<tr>
<td>Product Name: <?php echo $row['product_name'];?></td>
</tr>
<tr>
<td>Quantity: <?php echo $row['quantity']?></td>
</tr>
<tr>
<td>Receiver Name: <?php echo $row['receiver_name']?></td>
</tr>
<tr>
<td>Receiver Address: <?php echo $row['receiver_address']?></td>
</tr>
<tr>
<td>Receiver Contact: <?php echo $row['receiver_contact']?></td>
</tr>
<tr>
<td style="float:right">Date: <?php echo $row['date']?></td>
</tr>
</table>
<?php
}
?>
Example
id | product | date |
---|---------|------|
1 | book | 16/2 |
2 | pencil | 16/2 |
3 | shoe | 18/2 |
Result
-------
book |
pencil |
-------
shoe |
-------
Here is the complete solution:
$user_check=$_SESSION['login_user'];
$query = "SELECT * FROM `confirm_order` where customer = '$user_check'";
$result=mysqli_query($mysqli,$query);
$current_date=NULL;
$previous_date=NULL;
$table_open="<table border='1'>";
$table_close="</table><hr>";
$output=NULL;
while($row=mysqli_fetch_array($result))
{
$current_date=$row['date'];
if ($current_date==$previous_date) {
// SAME DATE
$output.= "<tr><td>SAME DATE</td><td>".$current_date."</td></tr>";
} else {
// NEW DATE
if ($previous_date<>NULL) {
$output.= $table_close;
}
$output.= $table_open."<tr><td>NEW DATE</td><td>".$current_date."</td></tr>";
}
$previous_date=$row['date'];
}
echo $output;

MySql/PHP Simple Report Query

I'm running a MySQL/PHP and i'm trying to display a simple report that tracks when a salesrep contacts a customer. I can't figure out what I'm doing wrong, as i'm a novice in this area. The simplest solution to me seems extremely convoluted (making a separate recordset for each figure). I figured there would have to be a simpler way.
I'm looking to display the number of contacts made during the current week/month/year in a simple table. see below. any help would be greatly appreciated.
|Current|Current| |
| Week | Month | YTD |
------|-------|-------|-------|
Brian | 7 | 14 | 37 |
------|-------|-------|-------|
Chad | 0 | 15 | 27 |
------|-------|-------|-------|
David | 11 | 26 | 52 |
------|-------|-------|-------|
Current recordsets
mysql_select_db($database_Sales, $Sales);
$query_rsCurWeek = "SELECT Sales.rep, COUNT(*) FROM Sales WHERE YEARWEEK(`date`, 1) = YEARWEEK(CURDATE(), 1) GROUP BY Sales.rep";
$rsCurWeek = mysql_query($query_rsCurWeek, $Sales) or die(mysql_error());
$row_rsCurWeek = mysql_fetch_assoc($rsCurWeek);
$totalRows_rsCurWeek = mysql_num_rows($rsCurWeek);
mysql_select_db($database_Sales, $Sales);
$query_rsCurMonth = "SELECT Sales.rep, COUNT(*) FROM Sales WHERE MONTH(date) = MONTH(CURDATE()) GROUP BY Sales.rep";
$rsCurMonth = mysql_query($query_rsCurMonth, $Sales) or die(mysql_error());
$row_rsCurMonth = mysql_fetch_assoc($rsCurMonth);
$totalRows_rsCurMonth = mysql_num_rows($rsCurMonth);
mysql_select_db($database_Sales, $Sales);
$query_rsCurYear = "SELECT Sales.rep, COUNT(*) FROM Sales WHERE YEAR(date) =
YEAR(CURDATE()) GROUP BY Sales.rep";
$rsCurYear = mysql_query($query_rsCurYear, $Sales) or die(mysql_error());
$row_rsCurYear = mysql_fetch_assoc($rsCurYear);
$totalRows_rsCurYear = mysql_num_rows($rsCurYear);
Current Output Table
<table width="400" border="1" cellspacing="0" cellpadding="0">
<tr>
<th width="175" align="center"></th>
<th width="75" align="center">Current<br />Week</th>
<th width="75" align="center">Current<br />Month</th>
<th width="75" align="center">YTD</th>
</tr>
<?php do { ?>
<tr>
<th align="left"><?php echo $row_rsCurYear['rep']; ?></th>
<td align="center"><?php echo $row_rsCurWeek['COUNT(*)']; ?></td>
<td align="center"><?php echo $row_rsCurMonth['COUNT(*)']; ?></td>
<td align="center"><?php echo $row_rsCurYear['COUNT(*)']; ?></td>
</tr>
<?php } while ($row_rsCurWeek = mysql_fetch_assoc($rsCurWeek)); ?>
try{
$sql = "SELECT * FROM contacts";
$result = $pdo->query($sql);
if($result->rowCount() > 0){
echo "<table>";
echo "<tr>";
echo "<th>username</th>";
echo "<th>current_week</th>";
echo "<th>current_month</th>";
echo "<th>ytd</th>";
echo "</tr>";
while($row = $result->fetch()){
echo "<tr>";
echo "<td>" . $row['username'] . "</td>";
echo "<td>" . $row['current_week'] . "</td>";
echo "<td>" . $row['current_month'] . "</td>";
echo "<td>" . $row['ytd'] . "</td>";
echo "</tr>";
}
echo "</table>";
// Free result set
unset($result);
} else{
echo "No records matching your query were found.";
}
} catch(PDOException $e){
die("ERROR: Could not able to execute $sql. " . $e->getMessage());
}

Eliminating duplicate specific rows?

Please Help!! I just want to display the Barangay which is talojongon with no other duplicate values
Let's say my current output is:
| Barangay | Disease |
__________________________________
| Talojongon | Cancer |
| Talojongon | Cancer |
| Talojongon | Cancer |
and i want to turn this to:
| Barangay | Disease |
__________________________________
| Talojongon | Cancer |
| | Cancer |
| | Cancer |
The receive in the database is for disease and status in the database is the barangay...thank you...Any suggestions is appreciated ..:)
This is my current part of my code
<br>
<table id="keywords" class="table table-striped table-bordered">
<thead>
<tr>
<th><center>Barangay</th></center>
<th><center>Diseases</th></center>
</tr>
</thead>
<tbody>
<?php
include 'database.php';
$pdo = Database::connect();
$sql = 'SELECT * FROM patients WHERE receive="Cancer"';
foreach ($pdo->query($sql) as $row){
echo '<tr>';
echo '<td><center>'. $row['status'] . '</center></td>';
echo '<td><center>'. $row['receive'] . '</center></td>';
}
Database::disconnect();
?>
</tr>
</tbody>
How about this?
<?php
include 'database.php';
$pdo = Database::connect();
$sql = 'SELECT * FROM patients WHERE receive="Cancer" order by status';
$last = '';
foreach ($pdo->query($sql) as $row){
echo '<tr>';
if($last == $row['status'])
{
echo '<td></td>';
}
else
{
$last = $row['status'];
echo '<td><center>'. $row['status'] . '</center></td>';
}
echo '<td><center>'. $row['receive'] . '</center></td>';
}
Database::disconnect();
?>
<?php
include 'database.php';
$pdo = Database::connect();
$sql = 'SELECT * FROM patients WHERE receive="Cancer"';
$counter=0;
foreach ($pdo->query($sql) as $row){
$counter++;
echo '<tr>';
if($counter==1){
echo '<td><center>Cancer</center></td>';
}else{
echo '<td><center></center></td>';
}
echo '<td><center>'. $row['receive'] . '</center></td>';
}
Database::disconnect();
?>
Simply echo the status just in the first row...
Save the last value of $row['status'] in a variable. If it's the same leave it blank in the output.
$last_status = null;
foreach ($pdo->query($sql) as $row) {
echo '<tr>';
$status = $row['status'] == $last_status ? '' : $row['status'];
echo '<td style="text-align: center;">' . $status . '</td>';
echo '<td style="text-align: center;">' . $row['receive'] . '</td>';
echo '</tr>';
$last_status = $row['status'];
}
Also, you shouldn't use the obsolete <center> tag, use CSS. And </tr> should be inside the loop, not at the end.
You probably should also use ORDER BY status in the query, so that all the rows with the same status are together.

PHP echo mysql table column names for html table header

RESOLVED
Works perfectly! Here is my final code:
<table>
<thead>
<tr>
<?php
$row = mysql_fetch_assoc($result);
foreach ($row as $col => $value) {
echo "<th>";
echo $col;
echo "</th>";
}
?>
<th>Edit</th>
</tr>
</thead>
<tbody>
<?php
// Write rows
mysql_data_seek($result, 0);
while ($row = mysql_fetch_assoc($result)) {
?>
<tr>
<?php
foreach($row as $key => $value){
echo "<td>";
echo $value;
echo "</td>";
}
?>
<td><button id="edit_project_button(<?php echo $row['ID']; ?>)" class="edit-project-button edit button" onclick="editproject(<?php echo $row['ID']; ?>)">Edit</button></td>
</tr>
<?php } ?>
</tbody>
</table>
I wish to echo out a HTML table using mysql_fetch functions appropriately. I plan on making a thead to contain the mysql table column names and a tbody to contain the mysql table resultset. The SQL query selects a couple of columns from the table, with default limit set.
The issue: It doesn't seem to print the first row of table data, everything else displays (record #1 missing)
It displays the with column names echo'd within each , it then skips the first record and successfully echo's the 2nd row onward. For example:
| id | firstname | lastname | date_start | date_end | clientid | members | edit |
| 2 | Cal | Clark | 2012-12-12 | 2012-12-12 | 22 | Rob | (edit button) |
| 3 | Rob | Robin | 2012-12-12 | 2012-12-12 | 33 | Cal | (edit button) |
I'm 100% sure that the first record will display from my query in phpmyadmin.
Here is my code:
<table>
<thead>
<tr>
<?php
$row = mysql_fetch_assoc($result);
foreach ($row as $col => $value) {
echo "<th>";
echo $col;
echo "</th>";
}
?>
<th>Edit</th>
</tr>
</thead>
<?php
// Write rows
while ($row = mysql_fetch_array($result)) {
?>
<tr>
<td><?php echo $row[0]; ?></td>
<td><?php echo $row[1]; ?></td>
<td><?php echo $row[2]; ?></td>
<td><?php echo $row[3]; ?></td>
<td><?php echo $row[4]; ?></td>
<td><?php echo $row[5]; ?></td>
<td><?php echo $row[6]; ?></td>
<td><button id="edit_project_button(<?php echo $row[0]; ?>)" class="edit-project-button edit button" onclick="editproject(<?php echo $row[0]; ?>)">Edit</button></td>
</tr>
<?php } ?>
</table>
I feel so oblivious right now =/
make a rewind of your data first!!
mysql_data_seek($result, 0);
while ($row = mysql_fetch_array($result)) {
...

Categories