The code does not display the data.
I try to display the values of each ReportItems in a table.
The code does not display any error when I call it.
Please can someone help me? Thank you very much.
//The code does not display the data.
I try to display the values of each ReportItems in a table.
The code does not display any error when I call it.
Please can someone help me? Thank you very much.
<?php
$url =
"https://api.booker.com/v4.1/merchant/location/.../Report/DailySales?access_token={...}&date_from={...}&date_to={...}";
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$headers = array(
"Ocp-Apim-Subscription-Key: {...}",
);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$resp = curl_exec($curl);
curl_close($curl);
var_dump($resp);
$obj = json_decode($resp, true);
$i = 0;
$nw= array_filter($obj['ReportItems'], function($v,$k){
return in_array($k, ['Date', 'DateOffset', 'Discount', 'Discount', 'GiftCertificate', 'GiftCertificateRefund', 'Orders', 'Refunds', 'Services', 'SubTotal', 'Tax', 'Tip', 'Total']);
}, ARRAY_FILTER_USE_BOTH);
$i=0;
foreach($nw as $k => $v){
$last = $i !== count($nw)-1 ? ','.PHP_EOL : '';
echo "\"$k\": \"$v\"".$last;
$i++;
}
$arrays = json_decode($resp);
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSON</title>
<link rel="shortcut icon" type="image/x-icon" href="icon.ico">
<meta name="description" content="HTML, PHP, JSON, REST API">
<style>table, th, td {border: 1px solid black;}</style>
</head>
<body>
<?php foreach ($nw as $k => $v) { ?>
<div style="width:200px;border:2px solid black;height:20px;">
<?php echo 'Date: ' . $v -> Date ?> </div><br />
<div style="width:200px;border:2px solid black;height:20px;"> <?php echo 'DateOffset: ' . $v -> DateOffset ?> </div><br />
<div style="width:200px;border:2px solid black;height:20px;"> <?php echo 'Discount: ' . $v -> Discount ?> </div><br />
<div style="width:200px;border:2px solid black;height:20px;"> <?php echo 'GiftCertificate: ' . $v -> GiftCertificate ?> </div><br />
<div style="width:200px;border:2px solid black;height:20px;"> <?php echo 'GiftCertificateRefund: ' . $v -> GiftCertificateRefund ?> </div><br />
<div style="width:200px;border:2px solid black;height:20px;"> <?php echo 'Orders: ' . $v -> Orders ?> </div><br />
<div style="width:200px;border:2px solid black;height:20px;"> <?php echo 'Refund: ' . $v -> Refund ?> </div><br />
<div style="width:200px;border:2px solid black;height:20px;"> <?php echo 'Services: ' . $v -> Services ?> </div><br />
<div style="width:200px;border:2px solid black;height:20px;"> <?php echo 'SubTotal: ' . $v -> SubTotal ?> </div><br />
<div style="width:200px;border:2px solid black;height:20px;"> <?php echo 'Tax: ' . $v -> Tax ?> </div><br />
<div style="width:200px;border:2px solid black;height:20px;"> <?php echo 'Tip: ' . $v -> Tip ?> </div><br />
<div style="width:200px;border:2px solid black;height:20px;"> <?php echo 'Total: ' . $v -> Total ?> </div><br />
<br />
<?php } ?>
<table style="width:100%"; class="data-table">
<tr>
<th>Date:</th>
<th>DateOffset:</th>
<th>Discount:</th>
<th>GiftCertificate:</th>
<th>GiftCertificateRefund:</th>
<th>Orders:</th>
<th>Refund:</th>
<th>Services:</th>
<th>SubTotal:</th>
<th>Tax:</th>
<th>Tip:</th>
<th>Total:</th>
</tr>
<?php foreach ($nw as $k => $v) { ?>
<tr>
<td><?php echo $v -> Date ?> </td>
<td><?php echo $v -> DateOffset ?> </td>
<td><?php echo $v -> Discount ?> </td>
<td><?php echo $v -> GiftCertificate ?> </td>
<td><?php echo $v -> GiftCertificateRefund ?> </td>
<td><?php echo $v -> Orders ?> </td>
<td><?php echo $v -> Refund ?> </td>
<td><?php echo $v -> Services ?> </td>
<td><?php echo $v -> SubTotal ?> </td>
<td><?php echo $v -> Tax ?> </td>
<td><?php echo $v -> Tip ?> </td>
<td><?php echo $v -> Total ?> </td>
</tr>
<?php } ?>
</table>
</body>
</html>
Please can someone help me?
Thank you.
Related
This question already has answers here:
Output a php multi-dimensional array to a html table
(3 answers)
Closed 3 years ago.
I need to create REST API in PHP. I take JSON data from https://jsonplaceholder.typicode.com/ . Now I need to put all that data in table HTML. It is one array, inside with other 200 array. How can i create all row automaticly, without typing whole code by hands.
This is the code how i take data from https://jsonplaceholder.typicode.com/ :
<?php
$url = 'https://jsonplaceholder.typicode.com/todos/';
$cURL = curl_init();
curl_setopt($cURL, CURLOPT_URL, $url);
curl_setopt($cURL, CURLOPT_HTTPGET, true);
curl_setopt($cURL, CURLOPT_RETURNTRANSFER, true);
curl_setopt($cURL, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Accept: application/json'
));
$result = curl_exec($cURL);
curl_close($cURL);
$arrays = json_decode($result);
?>
I tried like this:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSON</title>
<link rel="shortcut icon" type="image/x-icon" href="icon.ico">
<meta name="description" content="HTML, PHP, JSON, REST API">
<style>table, th, td {border: 1px solid black;}</style>
</head>
<body>
<?php foreach ($arrays as $key => $value) { ?>
<div style="width:80px;border:2px solid black;height:20px;"> <?php echo 'User ID: ' . $value -> userId ?> </div><br />
<div style="width:50px;border:2px solid black;height:20px;"> <?php echo 'ID: ' . $value -> id ?> </div><br />
<div style="width:550px;border:2px solid black;height:20px;"> <?php echo 'Title: ' . $value -> title ?> </div><br />
<div style="width:90px;border:2px solid black;height:20px;"> <?php echo 'Completed: ' . $value -> completed ?> </div><br />
<br /> <?php } ?>
<table table style="width:100%"; table class="data-table">
<tr>
<th> User ID:</th> <th>ID:</th> <th>Title:</th><th>Completed</th>
</tr>
<tr>
<td><?php echo $value -> userId ?> </td> <td><?php echo $value -> id ?> </td> <td><?php echo $value -> title ?> </td><td><?php echo $value -> completed ?> </td>
</tr>
<tr>
<td><?php echo $value -> userId ?> </td> <td><?php echo $value -> id ?> </td> <td><?php echo $value -> title ?> </td><td><?php echo $value -> completed ?> </td>
</tr>
</table>
</body>
</html>
But i dont know to do it by once for all 200 row. Any suggestion?
use foreach() one more time and put <table> outside of it:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSON</title>
<link rel="shortcut icon" type="image/x-icon" href="icon.ico">
<meta name="description" content="HTML, PHP, JSON, REST API">
<style>table, th, td {border: 1px solid black;}</style>
</head>
<body>
<?php foreach ($arrays as $value) { ?>
<div style="width:80px;border:2px solid black;height:20px;"> <?php echo 'User ID: ' . $value -> userId ?> </div><br />
<div style="width:50px;border:2px solid black;height:20px;"> <?php echo 'ID: ' . $value -> id ?> </div><br />
<div style="width:550px;border:2px solid black;height:20px;"> <?php echo 'Title: ' . $value -> title ?> </div><br />
<div style="width:90px;border:2px solid black;height:20px;"> <?php echo 'Completed: ' . $value -> completed ?> </div><br />
<br />
<?php } ?>
<table style="width:100%"; class="data-table">
<tr>
<th> User ID:</th>
<th>ID:</th>
<th>Title:</th>
<th>Completed</th>
</tr>
<?php foreach ($arrays as $value) { ?>
<tr>
<td><?php echo $value -> userId ?> </td>
<td><?php echo $value -> id ?> </td>
<td><?php echo $value -> title ?> </td>
<td><?php echo $value -> completed ?> </td>
</tr>
<?php } ?>
</table>
</body>
</html>
Note:- I am not sure that you want first foreach() inside <body> or not? so please check and if not needed then remove it.
I have a shopping cart page which the total price didn't show up in the table the products added (picture below). I can't figure out where's the error. I need help, thanks in advance!
Here's my code:
example.php
<?php include("dbconnection.php");?>
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Meal</title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
</head>
<body>
<div class="container" style="width:60%;">
<h2 align="center">SoftAOX Tutorial | Creating an Online Shopping Cart in PHP & Mysql</h2>
<?php
$query = "SELECT * FROM meal ORDER BY meal_id ASC";
$result = mysqli_query($con, $query);
if(mysqli_num_rows($result) > 0) {
while($row = mysqli_fetch_array($result)) {
?>
<div class="col-md-3">
<form method="post" action="shop.php?action=add&id=<?php echo $row["meal_id"]; ?>">
<div style="border: 1px solid #eaeaec; margin: -1px 19px 3px -1px; box-shadow: 0 1px 2px rgba(0,0,0,0.05); padding:10px;" align="center">
<img src="<?php echo $row["meal_image_Upload"]; ?>" class="img-responsive">
<h5 class="text-info"><?php echo $row["meal_name"]; ?></h5>
<h5 class="text-danger">$ <?php echo $row["meal_price"]; ?></h5>
<input type="text" name="quantity" class="form-control" value="1">
<input type="hidden" name="hidden_name" value="<?php echo $row["meal_name"]; ?>">
<input type="hidden" name="hidden_price" value="<?php echo $row["meal_price"]; ?>">
<input type="submit" name="add" style="margin-top:5px;" class="btn btn-default" value="Add to Bag">
</div>
</form>
</div>
<?php
}
}
?>
<div style="clear:both"></div>
<h2>My Shopping Bag</h2>
<div class="table-responsive">
<table class="table table-bordered">
<tr>
<th width="40%">Product Name</th>
<th width="10%">Quantity</th>
<th width="20%">Price Details</th>
<th width="15%">Order Total</th>
<th width="5%">Action</th>
</tr>
<?php
if(!empty($_SESSION["cart"])) {
$total = 0;
foreach($_SESSION["cart"] as $keys => $values) {
?>
<tr>
<td><?php echo $values["item_name"]; ?></td>
<td><?php echo $values["item_quantity"] ?></td>
<td><?php echo $values["product_price"]; ?></td>
<td><?php echo number_format(($values["item_quantity"] * $values["product_price"]), 2); ?></td>
<td><span class="text-danger">X</span></td>
</tr>
<?php
$total = $total + ($values["item_quantity"] * $values["product_price"]);
}
?>
<tr>
<td colspan="3" align="right">Total</td>
<td align="right"><?php echo number_format($total, 2); ?></td>
<td></td>
</tr>
<?php
}
?>
</table>
</div>
</div>
</body>
</html>
shop.php
<?php
include("dbconnection.php");
if(isset($_POST["add"])) {
if(isset($_SESSION["cart"])) {
$item_array_id = array_column($_SESSION["cart"], "product_id");
if(!in_array($_GET["id"], $item_array_id)) {
$count = count($_SESSION["cart"]);
$item_array = array(
'product_id' => $_GET["id"],
'item_name' => $_POST["hidden_name"],
'product_price' => $_POST["hidden_price"],
'item_quantity' => $_POST["quantity"]
);
$_SESSION["cart"][$count] = $item_array;
echo '<script>window.location="example.php"</script>';
} else {
echo '<script>alert("Products already added to cart")</script>';
echo '<script>window.location="example.php"</script>';
}
} else {
$item_array = array(
'product_id' => $_GET["id"],
'item_name' => $_POST["hidden_name"],
'product_price' => $_POST["hidden_price"],
'item_quantity' => $_POST["quantity"]
);
$_SESSION["cart"][0] = $item_array;
}
}
if(isset($_GET["action"])) {
if($_GET["action"] == "delete") {
foreach($_SESSION["cart"] as $keys => $values) {
if($values["product_id"] == $_GET["id"]) {
unset($_SESSION["cart"][$keys]);
echo '<script>alert("Product has been removed")</script>';
echo '<script>window.location="example.php"</script>';
}
}
}
}
?>
Your product price is RM6.90. Give only numbers to multiply.
If you want to find out the float no from product price, consider using regex.
This is the way u could do it
$productprice = "RM6.90";
preg_match('/([0-9]+\.[0-9]+)/', $productprice, $matches);
$floatproductprice = (float)$matches[0];// it will contain the float value
$floatproductprice should be used to calculate the total and also this value
should be stored in the database. Also change the type of price details and order total in database to Float or Double.
Your product price appears to have the literal "RM" in it as a suffix. This will cause PHP to abort number processing treating values as zeros.
You must remove non-numeric characters from your strings to make them true numbers. Something like the following may help. Kind of ugly, but simple use.
$capture_prefix = ""; #prefix for last number
function capture_number( $text )
{
global $capture_prefix;
$number = preg_replace( '/^[^\d]+/', "", $text );
$capture_prefix = substr( $text, 0, strlen($text) - strlen($number) );
return $number;
}
I have a .php file that when I add three extra fields to it to be displayed (which begin with 'Client Vehicle'), it pushes down a 'div class' and it creates a lot of emtpy space. Things end up being on two pages instead of just one. Instead, there is a big empty space where my 'div class' used to be (its a table named 'invoice-details')
If I take away these fields, everything is spaced correctly. How can I add them and push the 'invoice-details' table back up into place?
Here are my css& php files:
.clearfix:after {
content: "";
display: table;
clear: both
}
a {
color: #375bc8;
text-decoration: underline
}
body {
position: relative;
width: 21cm;
height: 29.7cm;
margin: 0 auto;
color: #3A3A3A;
background: #FFFFFF;
font-family: sans-serif;
font-size: 14px
}
header {
padding: 10px 0;
margin-bottom: 30px
}
#logo {
text-align: right;
margin-bottom: 30px
}
#invoice-logo {
max-height: 125px;
text-align: right
}
.invoice-title {
color: #375bc8;
font-size: 2em;
line-height: 1.4em;
font-weight: normal;
margin: 20px 0
}
#company {
float: right;
text-align: right;
width: 40%
}
#client {
float: left;
width: 55%;
margin-right: 5%
}
.invoice-details {
text-align: right
}
.invoice-details table {
border-collapse: collapse;
border-spacing: 0;
text-align: right;
width: 40%;
margin: 0 0 0 auto;
font-size: 12px
}
.invoice-details table td {
width: auto;
margin: 0;
padding: 0 0 0.5em 0
}
table.item-table {
width: 100%;
border-collapse: collapse;
border-spacing: 0;
margin-bottom: 20px;
font-size: 12px
}
table.item-table tr:nth-child(2n-1) td {
background: #F5F5F5
}
table.item-table th {
padding: 10px 15px;
border-bottom: 1px solid #606060;
white-space: nowrap;
text-align: left
}
table.item-table th.text-right {
text-align: right
}
table.item-table td {
padding: 10px 15px
}
table.item-table .invoice-sums {
text-align: right
}
footer {
color: #878787;
width: 100%;
border-top: 2px solid #878787;
padding: 8px 0
}
.text-right {
text-align: right
}
.text-red {
color: #ea5340
}
.text-green {
color: #77b632
}
<html lang="<?php echo lang('cldr'); ?>">
<head>
<meta charset="utf-8">
<title>
<?php echo lang( 'invoice'); ?>
</title>
<link rel="stylesheet" href="<?php echo base_url(); ?>assets/default/css/templates.css">
<link rel="stylesheet" href="<?php echo base_url(); ?>assets/default/css/custom-pdf.css">
</head>
<body>
<header class="clearfix">
<div id="logo">
<?php echo invoice_logo_pdf(); ?>
</div>
<div id="client">
<div>
<b><?php echo $invoice->client_name; ?></b>
</div>
<?php if ($invoice->client_vat_id) { echo '
<div>' . lang('vat_id_short') . ': ' . $invoice->client_vat_id . '</div>'; } if ($invoice->client_tax_code) { echo '
<div>' . lang('tax_code_short') . ': ' . $invoice->client_tax_code . '</div>'; } if ($invoice->client_address_1) { echo '
<div>' . $invoice->client_address_1 . '</div>'; } if ($invoice->client_address_2) { echo '
<div>' . $invoice->client_address_2 . '</div>'; } if ($invoice->client_city && $invoice->client_zip) { echo '
<div>' . $invoice->client_city . ' ' . $invoice->client_zip . '</div>'; } else { if ($invoice->client_city) { echo '
<div>' . $invoice->client_city . '</div>'; } if ($invoice->client_zip) { echo '
<div>' . $invoice->client_zip . '</div>'; } } if ($invoice->client_state) { echo '
<div>' . $invoice->client_state . '</div>'; } if ($invoice->client_country) { echo '
<div>' . get_country_name(lang('cldr'), $invoice->client_country) . '</div>'; } echo '
<br/>'; if ($invoice->client_phone) { echo '
<div>' . lang('phone_abbr') . ': ' . $invoice->client_phone . '</div>'; } ?>
<br/>
<p>
<?php echo 'Client Vehicle'; ?>
</p>
<p>
<?php echo 'Year'; ?>:
<?php echo $invoice->client_custom_year; ?></p>
<p>
<?php echo 'Make'; ?>:
<?php echo $invoice->client_custom_make; ?></p>
<p>
<?php echo 'Model'; ?>:
<?php echo $invoice->client_custom_model; ?></p>
</div>
<div id="company">
<div><b><?php echo $invoice->user_name; ?></b>
</div>
<?php if ($invoice->user_vat_id) { echo '
<div>' . lang('vat_id_short') . ': ' . $invoice->user_vat_id . '</div>'; } if ($invoice->user_tax_code) { echo '
<div>' . lang('tax_code_short') . ': ' . $invoice->user_tax_code . '</div>'; } if ($invoice->user_address_1) { echo '
<div>' . $invoice->user_address_1 . '</div>'; } if ($invoice->user_address_2) { echo '
<div>' . $invoice->user_address_2 . '</div>'; } if ($invoice->user_city && $invoice->user_zip) { echo '
<div>' . $invoice->user_city . ' ' . $invoice->user_zip . '</div>'; } else { if ($invoice->user_city) { echo '
<div>' . $invoice->user_city . '</div>'; } if ($invoice->user_zip) { echo '
<div>' . $invoice->user_zip . '</div>'; } } if ($invoice->user_state) { echo '
<div>' . $invoice->user_state . '</div>'; } if ($invoice->user_country) { echo '
<div>' . get_country_name(lang('cldr'), $invoice->user_country) . '</div>'; } echo '
<br/>'; if ($invoice->user_phone) { echo '
<div>' . lang('phone_abbr') . ': ' . $invoice->user_phone . '</div>'; } if ($invoice->user_fax) { echo '
<div>' . lang('fax_abbr') . ': ' . $invoice->user_fax . '</div>'; } ?>
</div>
</header>
<main>
<div class="invoice-details clearfix">
<table>
<tr>
<td>
<?php echo lang( 'invoice_date') . ':'; ?>
</td>
<td>
<?php echo date_from_mysql($invoice->invoice_date_created, true); ?></td>
</tr>
<tr>
<td>
<?php echo lang( 'due_date') . ': '; ?>
</td>
<td>
<?php echo date_from_mysql($invoice->invoice_date_due, true); ?></td>
</tr>
<tr>
<td>
<?php echo lang( 'amount_due') . ': '; ?>
</td>
<td>
<?php echo format_currency($invoice->invoice_balance); ?></td>
</tr>
<?php if ($payment_method): ?>
<tr>
<td>
<?php echo lang( 'payment_method') . ': '; ?>
</td>
<td<?php echo $payment_method->payment_method_name; ?></td>
</tr>
<?php endif; ?>
</table>
</div>
<h1 class="invoice-title"><?php echo lang('invoice') . ' ' . $invoice->invoice_number; ?></h1>
<table class="item-table">
<thead>
<tr>
<th class="item-name">
<?php echo lang( 'item'); ?>
</th>
<th class="item-desc">
<?php echo lang( 'description'); ?>
</th>
<th class="item-amount text-right">
<?php echo lang( 'qty'); ?>
</th>
<th class="item-price text-right">
<?php echo lang( 'price'); ?>
</th>
<?php if ($show_discounts) : ?>
<th class="item-discount text-right">
<?php echo lang( 'discount'); ?>
</th>
<?php endif; ?>
<th class="item-total text-right">
<?php echo lang( 'total'); ?>
</th>
</tr>
</thead>
<tbody>
<?php foreach ($items as $item) { ?>
<tr>
<td>
<?php echo $item->item_name; ?></td>
<td>
<?php echo nl2br($item->item_description); ?></td>
<td class="text-right">
<?php echo format_amount($item->item_quantity); ?>
</td>
<td class="text-right">
<?php echo format_currency($item->item_price); ?>
</td>
<?php if ($show_discounts) : ?>
<td class="text-right">
<?php echo format_currency($item->item_discount); ?>
</td>
<?php endif; ?>
<td class="text-right">
<?php echo format_currency($item->item_subtotal); ?>
</td>
</tr>
<?php } ?>
</tbody>
<tbody class="invoice-sums">
<tr>
<td <?php echo($show_discounts ? 'colspan="5"' : 'colspan="4"'); ?>class="text-right">
<?php echo lang( 'subtotal'); ?>
</td>
<td class="text-right">
<?php echo format_currency($invoice->invoice_item_subtotal); ?></td>
</tr>
<?php if ($invoice->invoice_item_tax_total > 0) { ?>
<tr>
<td <?php echo($show_discounts ? 'colspan="5"' : 'colspan="4"'); ?>class="text-right">
<?php echo lang( 'item_tax'); ?>
</td>
<td class="text-right">
<?php echo format_currency($invoice->invoice_item_tax_total); ?>
</td>
</tr>
<?php } ?>
<?php foreach ($invoice_tax_rates as $invoice_tax_rate) : ?>
<tr>
<td <?php echo($show_discounts ? 'colspan="5"' : 'colspan="4"'); ?>class="text-right">
<?php echo $invoice_tax_rate->invoice_tax_rate_name . ' (' . $invoice_tax_rate->invoice_tax_rate_percent . '%)'; ?>
</td>
<td class="text-right">
<?php echo format_currency($invoice_tax_rate->invoice_tax_rate_amount); ?>
</td>
</tr>
<?php endforeach ?>
<tr>
<td <?php echo($show_discounts ? 'colspan="5"' : 'colspan="4"'); ?>class="text-right">
<b><?php echo lang('total'); ?></b>
</td>
<td class="text-right">
<b><?php echo format_currency($invoice->invoice_total); ?></b>
</td>
</tr>
<tr>
<td <?php echo($show_discounts ? 'colspan="5"' : 'colspan="4"'); ?>class="text-right">
<?php echo lang( 'paid'); ?>
</td>
<td class="text-right">
<?php echo format_currency($invoice->invoice_paid); ?>
</td>
</tr>
<tr>
<td <?php echo($show_discounts ? 'colspan="5"' : 'colspan="4"'); ?>class="text-right">
<b><?php echo lang('balance'); ?></b>
</td>
<td class="text-right">
<b><?php echo format_currency($invoice->invoice_balance); ?></b>
</td>
</tr>
</tbody>
</table>
</main>
<footer>
<?php if ($invoice->invoice_terms) : ?>
<div class="notes">
<b><?php echo lang('terms'); ?></b>
<br/>
<?php echo nl2br($invoice->invoice_terms); ?>
</div>
<?php endif; ?>
</footer>
</body>
</html>
Here is my updated .php file with the added div. The new revision only works down to the new div I added as I guess because this is nested?
<html lang="<?php echo lang('cldr'); ?>">
<head>
<meta charset="utf-8">
<title><?php echo lang('invoice'); ?></title>
<link rel="stylesheet" href="<?php echo base_url(); ?>assets/default/css/templates.css">
<link rel="stylesheet" href="<?php echo base_url(); ?>assets/default/css/custom-pdf.css">
</head>
<body>
<header class="clearfix">
<div id="logo">
<?php echo invoice_logo_pdf(); ?>
</div>
<div id="client">
<div>
<b><?php echo $invoice->client_name; ?></b>
</div>
<?php if ($invoice->client_vat_id) {
echo '<div>' . lang('vat_id_short') . ': ' . $invoice->client_vat_id . '</div>';
}
if ($invoice->client_tax_code) {
echo '<div>' . lang('tax_code_short') . ': ' . $invoice->client_tax_code . '</div>';
}
if ($invoice->client_address_1) {
echo '<div>' . $invoice->client_address_1 . '</div>';
}
if ($invoice->client_address_2) {
echo '<div>' . $invoice->client_address_2 . '</div>';
}
if ($invoice->client_city && $invoice->client_zip) {
echo '<div>' . $invoice->client_city . ' ' . $invoice->client_zip . '</div>';
} else {
if ($invoice->client_city) {
echo '<div>' . $invoice->client_city . '</div>';
}
if ($invoice->client_zip) {
echo '<div>' . $invoice->client_zip . '</div>';
}
}
if ($invoice->client_state) {
echo '<div>' . $invoice->client_state . '</div>';
}
if ($invoice->client_country) {
echo '<div>' . get_country_name(lang('cldr'), $invoice->client_country) . '</div>';
}
echo '<br/>';
if ($invoice->client_phone) {
echo '<div>' . lang('phone_abbr') . ': ' . $invoice->client_phone . '</div>';} ?>
<br>
<div>
<b><?php echo '<u>Client Vehicle</u>'; ?>:</b>
<br>
<?php echo 'Year'; ?>:
<?php echo $invoice->client_custom_year; ?>
</br>
<br>
<?php echo 'Make'; ?>:
<?php echo $invoice->client_custom_make; ?>
</br>
<br>
<?php echo 'Model'; ?>:
<?php echo $invoice->client_custom_model; ?>
</br>
</div>
</div>
<div id="company">
<div><b><?php echo $invoice->user_name; ?></b></div>
<?php if ($invoice->user_vat_id) {
echo '<div>' . lang('vat_id_short') . ': ' . $invoice->user_vat_id . '</div>';
}
if ($invoice->user_tax_code) {
echo '<div>' . lang('tax_code_short') . ': ' . $invoice->user_tax_code . '</div>';
}
if ($invoice->user_address_1) {
echo '<div>' . $invoice->user_address_1 . '</div>';
}
if ($invoice->user_address_2) {
echo '<div>' . $invoice->user_address_2 . '</div>';
}
if ($invoice->user_city && $invoice->user_zip) {
echo '<div>' . $invoice->user_city . ' ' . $invoice->user_zip . '</div>';
} else {
if ($invoice->user_city) {
echo '<div>' . $invoice->user_city . '</div>';
}
if ($invoice->user_zip) {
echo '<div>' . $invoice->user_zip . '</div>';
}
}
if ($invoice->user_state) {
echo '<div>' . $invoice->user_state . '</div>';
}
if ($invoice->user_country) {
echo '<div>' . get_country_name(lang('cldr'), $invoice->user_country) . '</div>';
}
echo '<br/>';
if ($invoice->user_phone) {
echo '<div>' . lang('phone_abbr') . ': ' . $invoice->user_phone . '</div>';
}
if ($invoice->user_fax) {
echo '<div>' . lang('fax_abbr') . ': ' . $invoice->user_fax . '</div>';
}
?>
</div>
</header>
<main>
<div class="invoice-details clearfix">
<table>
<tr>
<td><?php echo lang('invoice_date') . ':'; ?></td>
<td><?php echo date_from_mysql($invoice->invoice_date_created, true); ?></td>
</tr>
<tr>
<td><?php echo lang('due_date') . ': '; ?></td>
<td><?php echo date_from_mysql($invoice->invoice_date_due, true); ?></td>
</tr>
<tr>
<td><?php echo lang('amount_due') . ': '; ?></td>
<td><?php echo format_currency($invoice->invoice_balance); ?></td>
</tr>
<?php if ($payment_method): ?>
<tr>
<td><?php echo lang('payment_method') . ': '; ?></td>
<td<?php echo $payment_method->payment_method_name; ?></td>
</tr>
<?php endif; ?>
</table>
</div>
<h1 class="invoice-title"><?php echo lang('invoice') . ' ' . $invoice->invoice_number; ?></h1>
<table class="item-table">
<thead>
<tr>
<th class="item-name"><?php echo lang('item'); ?></th>
<th class="item-desc"><?php echo lang('description'); ?></th>
<th class="item-amount text-right"><?php echo lang('qty'); ?></th>
<th class="item-price text-right"><?php echo lang('price'); ?></th>
<?php if ($show_discounts) : ?>
<th class="item-discount text-right"><?php echo lang('discount'); ?></th>
<?php endif; ?>
<th class="item-total text-right"><?php echo lang('total'); ?></th>
</tr>
</thead>
<tbody>
<?php
foreach ($items as $item) { ?>
<tr>
<td><?php echo $item->item_name; ?></td>
<td><?php echo nl2br($item->item_description); ?></td>
<td class="text-right">
<?php echo format_amount($item->item_quantity); ?>
</td>
<td class="text-right">
<?php echo format_currency($item->item_price); ?>
</td>
<?php if ($show_discounts) : ?>
<td class="text-right">
<?php echo format_currency($item->item_discount); ?>
</td>
<?php endif; ?>
<td class="text-right">
<?php echo format_currency($item->item_subtotal); ?>
</td>
</tr>
<?php } ?>
</tbody>
<tbody class="invoice-sums">
<tr>
<td <?php echo($show_discounts ? 'colspan="5"' : 'colspan="4"'); ?> class="text-right">
<?php echo lang('subtotal'); ?>
</td>
<td class="text-right"><?php echo format_currency($invoice->invoice_item_subtotal); ?></td>
</tr>
<?php if ($invoice->invoice_item_tax_total > 0) { ?>
<tr>
<td <?php echo($show_discounts ? 'colspan="5"' : 'colspan="4"'); ?> class="text-right">
<?php echo lang('item_tax'); ?>
</td>
<td class="text-right">
<?php echo format_currency($invoice->invoice_item_tax_total); ?>
</td>
</tr>
<?php } ?>
<?php foreach ($invoice_tax_rates as $invoice_tax_rate) : ?>
<tr>
<td <?php echo($show_discounts ? 'colspan="5"' : 'colspan="4"'); ?> class="text-right">
<?php echo $invoice_tax_rate->invoice_tax_rate_name . ' (' . $invoice_tax_rate->invoice_tax_rate_percent . '%)'; ?>
</td>
<td class="text-right">
<?php echo format_currency($invoice_tax_rate->invoice_tax_rate_amount); ?>
</td>
</tr>
<?php endforeach ?>
<tr>
<td <?php echo($show_discounts ? 'colspan="5"' : 'colspan="4"'); ?> class="text-right">
<b><?php echo lang('total'); ?></b>
</td>
<td class="text-right">
<b><?php echo format_currency($invoice->invoice_total); ?></b>
</td>
</tr>
<tr>
<td <?php echo($show_discounts ? 'colspan="5"' : 'colspan="4"'); ?> class="text-right">
<?php echo lang('paid'); ?>
</td>
<td class="text-right">
<?php echo format_currency($invoice->invoice_paid); ?>
</td>
</tr>
<tr>
<td <?php echo($show_discounts ? 'colspan="5"' : 'colspan="4"'); ?> class="text-right">
<b><?php echo lang('balance'); ?></b>
</td>
<td class="text-right">
<b><?php echo format_currency($invoice->invoice_balance); ?></b>
</td>
</tr>
</tbody>
</table>
</main>
<footer>
<?php if ($invoice->invoice_terms) : ?>
<div class="notes">
<b><?php echo lang('terms'); ?></b><br/>
<?php echo nl2br($invoice->invoice_terms); ?>
</div>
<?php endif; ?>
</footer>
</body>
</html>
Add the div tag for the new added elements
<div>
<p>
<?php echo 'Client Vehicle'; ?>
</p>
<p>
<?php echo 'Year'; ?>:
<?php echo $invoice->client_custom_year; ?></p>
<p>
<?php echo 'Make'; ?>:
<?php echo $invoice->client_custom_make; ?></p>
<p>
<?php echo 'Model'; ?>:
<?php echo $invoice->client_custom_model; ?></p>
</div>
Below is my while loop table, currently it's showing just one item per row. I can't seem to figure out how to get 4 items/columns to show before it shows a new row below. Any help with this would be much appreciated, thank you!
Jerome
<table style="background-color: white">
<?php
while ($row = mysql_fetch_array($rs)) {
?>
Collapse | Copy Code
<tr <?php //if ($i % 2) echo ' style="background-color: #ECECFB;"';?>>
<td class="rows"><font color="4D4D4D" size="3"><? echo '<a type="video/x-matroska" href=file://///'.$row["Link"].' target=blank>'.$row["Name"].'</a>' ?><br />
<? echo '<a type="video/x-matroska" href=file://///'.$row["Link"].' target=blank><img src='.$row["Picture"].' height=210px width=141px></a>' ?><br />
<? echo '('.$row["Type"].')' ?> <? echo $row["Year"] ?> <? echo $row["Rating"] ?> <? echo date('H:i', mktime(0,$row["Length"])); ?><br />
<? echo $row["Genre"] ?><br />
<? if ($row["Queue"]==='x') {
echo
"<center><a title=Remove From Watch List href='deletequeue.php?id=".$row['ID']."'><img align='center' width='20px' src='http://www.ourlittlelucas.net/ourflix/images/Minus.png'></a></td></font></center>";
}
else {
echo "<center><a title=Add To Watch List href='addqueue.php?id=".$row['ID']."'><img align='center' width='20px' src='http://www.ourlittlelucas.net/ourflix/images/Plus.png'></a></td></font></center>";
}
?>
</td></tr></font>
<?php $i++?>
<?php
}
?>
</table>
Try it
<table style="background-color: white">
<?php
while ($row = mysql_fetch_array($rs))
{
?>
Collapse | Copy Code
<tr <?php //if ($i % 2) echo ' style="background-color: #ECECFB;"';?>>
<td class="rows">
<font color="4D4D4D" size="3"><?php echo '<a type="video/x-matroska" href=file://///'.$row["Link"].' target=blank>'.$row["Name"].'</a>'; ?><br />
<?php echo '<a type="video/x-matroska" href=file://///'.$row["Link"].' target=blank><img src='.$row["Picture"].' height=210px width=141px></a>'; ?><br />
<?php echo '('.$row["Type"].')' ?>
<?php echo $row["Year"] ;?>
<?php echo $row["Rating"]; ?>
<?php echo date('H:i', mktime(0,$row["Length"])); ?><br />
<?php echo $row["Genre"] ;?><br />
<?php
if ($row["Queue"]=="x") {
echo
"<center><a title=Remove From Watch List href='deletequeue.php?id=".$row['ID']."'><img align='center' width='20px' src='http://www.ourlittlelucas.net/ourflix/images/Minus.png'></a></td></font></center>";
}
else
{
echo "<center><a title=Add To Watch List href='addqueue.php?id=".$row['ID']."'><img align='center' width='20px' src='http://www.ourlittlelucas.net/ourflix/images/Plus.png'></a></td></font></center>";
}
?>
</td></tr></font>
<?php $i++?>
<?php
}
?>
</table>
Hey everyone I have been trying to figure this out for a while and just cant get around while its not showing the second fetch where weaponF is,
<?php
session_start();
if(!$_SESSION['logged']){
header("Location: login_page.php");
exit;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<style type="text/css">
div {
position: relative;
left: 5px;
top: 25px;
width: 280px;
padding: 10px;
color: black;
display: none;
}
</style>
<script language="JavaScript">
function setVisibility(id1,id2,id3) {
if(document.getElementById('bt1').value=='H'){
document.getElementById('bt1').value = 'S';
document.getElementById(id1).style.display = 'none';
document.getElementById(id2).style.display = 'none';
document.getElementById(id3).style.display = 'none';
}else{
document.getElementById('bt1').value = 'H';
document.getElementById(id1).style.display = 'inline';
document.getElementById(id2).style.display = 'inline';
document.getElementById(id3).style.display = 'inline';
}
}
function setvisibility(id4){
if(document.getElementById('bt2').value=='HP'){
document.getElementById('bt2').value = 'SP';
document.getElementById('id4').style.display = 'none';
}else{
document.getElementById('bt2').value = 'HP';
document.getElementById('id4').style.display = 'inline';
}
}
function setvisibility(id5){
if(document.getElementById('bt3').value=='HC'){
document.getElementById('bt3').value = 'SC';
document.getElementById('id5').style.display = 'none';
}else{
document.getElementById('bt3').value = 'HC';
document.getElementById('id5').style.display = 'inline';
}
}
function setvisibility(id6){
if(document.getElementById('bt4').value=='HM'){
document.getElementById('bt4').value = 'SM';
document.getElementById('id6').style.display = 'none';
}else{
document.getElementById('bt4').value = 'HM';
document.getElementById('id6').style.display = 'inline';
}
}
function setvisibility(id7){
if(document.getElementById('bt5').value=='HI'){
document.getElementById('bt5').value = 'SI';
document.getElementById('id7').style.display = 'none';
}else{
document.getElementById('bt5').value = 'HI';
document.getElementById('id7').style.display = 'inline';
}
}
</script>
<body>
<center>
<?php
$con=mysqli_connect(secret);
$validUser = mysqli_real_escape_string($con, $_SESSION['username']);
$result = mysqli_query($con, "SELECT level, exp, maxexp, str, dex, inte, sta, crit, hp, atk, def, dfire, dwater, dposion, atkfire, atkwater, atkposion, weapon FROM users WHERE username = '$validUser'");
$data = mysqli_fetch_array($result,MYSQLI_ASSOC);
$weapon = $data['weapon'];
$weaponQ = mysqli_query($con, "SELECT * FROM equipment WHERE wname= '$weapon'") or die(mysqli_error($con));
$weaponF = mysqli_fetch_array($weaponQ,MYSQLI_ASSOC);
mysqli_close($con);
?>
<body><center>
<table border="1">
<td>Level:<?php echo $data['level']; ?></td>
<td
<?php if ($data['exp'] == $data['maxexp']) {
echo "bgcolor = white";
}
else
{
echo "bgcolor = white";
}
?>
>Exp:<?php echo $data['exp']; ?>/<?php echo $data['maxexp']; ?></td>
<td>Str:<?php echo $data['str']; ?></td>
<td>Dex:<?php echo $data['dex']; ?></td>
<td>Int:<?php echo $data['inte']; ?></td>
<td>Stam:<?php echo $data['sta']; ?></td>
<td>Crit:<?php echo $data['crit']; ?>%</td>
</table>
<?php
if ($data['exp'] == $data['maxexp']) {
echo "<a href='levelup.php'>Level up </a>";
}
else
{
echo "";
}
?>
</center>
<table border="1" align="left">
<tr>
<td>
<a onclick="setVisibility('sub3','sub4','sub5');" id="bt1" href="#">Explore</a><br /><br />
<a onclick="setVisibility('sub6');" id="bt4" href="#">Market</a><br /><br />
<a onclick="setVisibility('sub1');" id="bt2" href="#">Profile</a><br /><br />
<a onclick="setVisibility('sub2');" id="bt3" href="#">Casino</a><br /><br />
<a onclick="setVisibility('sub7');" id="bt5" href="#">Inventory</a><br /><br />
Logout
</td>
</tr>
</table>
<br />
<div id="sub3" align="center">Map</div>
<br><br><br><br><br>
<div id="sub4" align="center">Arrows</div>
<div id="sub5" align="center">Mobs</div>
<div id="sub1" align="center">
<table border="1" align="center">
<td>
<?php
echo "<font size='+2'>Base Stats</font>";
echo "<br><br>";
echo "Str: ";
echo $data['str'];
echo "<br>";
echo "Dex: ";
echo $data['dex'];
echo "<br>";
echo "Int: ";
echo $data['inte'];
echo "<br>";
echo "Stam: ";
echo $data['sta'];
echo "<br>";
echo "Crit: ";
echo $data['crit'];
echo "%";
echo "<br>";
echo "Atk: ";
echo $data['atk'];
echo "<br>";
echo "Def: ";
echo $data['def'];
echo "<br><br>";
echo "<font size='+2'>Bonus Atk</font>";
echo "<br><br>";
echo "Atk Fire: ";
echo $data['atkfire'];
echo "%";
echo "<br>";
echo "Atk Water: ";
echo $data['atkwater'];
echo "%";
echo "<br>";
echo "Atk Posion: ";
echo $data['atkposion'];
echo "%";
echo "<br><br>";
echo "<font size='+2'>Bonus Res</font>";
echo "<br><br>";
echo "Def Fire: ";
echo $data['dfire'];
echo "%";
echo "<br>";
echo "Def Water: ";
echo $data['dwater'];
echo "%";
echo "<br>";
echo "Def Posion: ";
echo $data['dposion'];
echo "%";
?>
</td>
</table>
</div>
<div id="sub2" align="center">Casino</div>
<div id="sub6" align="center">Market</div>
<div id="sub7" align="center">
<table border="1" bordercolor="white">
<tr>
<td bordercolor="white" height="50px" width="50px"></td>
<td width="50px" height="50px" bordercolor="black">
Head
</td>
</tr><br />
<tr>
<td width="50px" height="50px" bordercolor="black">
<img onmouseover="<?php echo $weaponF['name']; ?>" src="equipment/<?php echo $data['weapon']; ?>.png" />
</td>
<td width="50px" height="50px" bordercolor="black">
Chest
</td>
<td width="50px" height="50px" bordercolor="black">
RightArm
</td>
</tr>
<tr>
<td bordercolor="white" height="50px" width="50px">
</td>
<td bordercolor="black" height="50px" width="50px">
Pants
</td>
</tr>
<tr>
<td bordercolor="white" height="50px" width="50px">
</td>
<td bordercolor="black" height="50px" width="50px">
Shoes
</td>
</tr>
</table>
</div>
<?php echo $data['weapon'];
echo $weaponF['wname']; ?>
</body>
It dose not show any errors or faults, Please help haha here is all my code make it easier to view and help I hope lol
i think username and name is your table columns so try
$validUser = mysqli_real_escape_string($con, $_SESSION['username']);
mysqli_query("SELECT * FROM users WHERE username ='$validUser' LIMIT 1");
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con, "SELECT level, exp, maxexp, str, dex, inte, sta, crit, hp, atk, def, dfire, dwater, dposion, atkfire, atkwater, atkposion, weapon FROM users WHERE username = '$validUser'");
$data = mysqli_fetch_array($result,MYSQLI_ASSOC);
$weapon = $data['weapon'];
$weaponQ = mysqli_query($con, "SELECT * FROM equipment WHERE wname= '$weapon'") or die(mysqli_error($con));
if(mysqli_num_rows($weaponQ) > 0) {
$weaponF = mysqli_fetch_array($weaponQ,MYSQLI_ASSOC);
}
else {
echo 'No rows found';
}
mysqli_close($con);
and also there is no work of below query so you can remove this:-
mysqli_query("SELECT * FROM users WHERE username ='$validUser' LIMIT 1");