I have a quote table that people insert basic information, such as name, product type etc. Which is all fine.
The admin can see the quote table and has a button to view the information in a structured manner.
Now what i have been trying to do is add a button called "Accept" and "Deny" which would move the table entry to the Denied or accepted table (same structure as the quote table)
I have looked around on google but only found assistance in making a button to delete entries or add new entries.
Below is the admin quote viewing page code with the view button:
<?php
session_start();
include("dbconnection.php");
include("checklogin.php");
check_login();
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
<meta charset="utf-8" />
<title>Admin | Manage Logged Claims</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta content="" name="description" />
<meta content="" name="author" />
<link href="assets/plugins/bootstrap-select2/select2.css" rel="stylesheet" type="text/css" media="screen"/>
<link href="assets/plugins/jquery-datatable/css/jquery.dataTables.css" rel="stylesheet" type="text/css"/>
<link href="assets/plugins/datatables-responsive/css/datatables.responsive.css"
rel="stylesheet" type="text/css" media="screen"/>
<link href="assets/plugins/boostrapv3/css/bootstrap.min.css" rel="stylesheet" type="text/css"/>
<link href="assets/plugins/boostrapv3/css/bootstrap-theme.min.css" rel="stylesheet" type="text/css"/>
<link href="assets/plugins/font-awesome/css/font-awesome.css" rel="stylesheet" type="text/css"/>
<link href="assets/css/animate.min.css" rel="stylesheet" type="text/css"/>
<link href="assets/plugins/jquery-scrollbar/jquery.scrollbar.css" rel="stylesheet" type="text/css"/>
<link href="assets/css/style.css" rel="stylesheet" type="text/css"/>
<link href="assets/css/responsive.css" rel="stylesheet" type="text/css"/>
<link href="assets/css/custom-icon-set.css" rel="stylesheet" type="text/css"/>
</head>
<body class="">
<?php include("header.php");?>
<div class="page-container row">
<?php include("leftbar.php");?>
<div class="clearfix"></div>
<!-- END SIDEBAR MENU -->
</div>
</div>
<div class="page-content">
<!-- BEGIN SAMPLE PORTLET CONFIGURATION MODAL FORM-->
<div id="portlet-config" class="modal hide">
<div class="modal-header">
<button data-dismiss="modal" class="close" type="button"></button>
<h3>Widget Settings</h3>
</div>
<div class="modal-body"> Widget settings form goes here </div>
</div>
<div class="clearfix"></div>
<div class="content">
<ul class="breadcrumb">
<li>
<p>YOU ARE HERE</p>
</li>
<li>Claims Logged </li>
</ul>
<div class="page-title"> <i class="icon-custom-left"></i>
<h3>Manage Logged Claims</h3>
</div>
<div class="row-fluid">
<div class="span12">
<div class="grid simple ">
<div class="grid-title">
<h4>Table <span class="semi-bold">Styles</span></h4>
<div class="tools">
<a href="javascript:;" class="remove">
</a> </div>
</div>
<div class="grid-body ">
<table class="table table-hover table-condensed" id="example">
<thead>
<tr>
<th style="width:1%">#</th>
<th style="width:10%">Name</th>
<th style="width:10%" data-hide="phone,tablet">Email</th>
<th style="width:10%">Contact no</th>
<th style="width:20%" data-hide="phone,tablet">Claim Requested</th>
<th style="width:10%">Action </th>
</tr>
</thead>
<tbody>
<?php $ret=mysql_query("select * from prequest order by id desc");
$cnt=1;
while($row=mysql_fetch_array($ret))
{?>
<tr >
<td class="v-align-middle"><?php echo $cnt;?></td>
<td class="v-align-middle"><?php echo $row['name'];?></td>
<td class="v-align-middle"><span class="muted"><?php echo $row['email'];?></span></td>
<td><span class="muted"><?php echo $row['contactno'];?>
</span></td>
<td class="v-align-middle"><?php echo $row['wdd'];?>
<?php echo $row['cms'];?>
<?php echo $row['seo'];?>
<?php echo $row['smo'];?>
<?php echo $row['swd'];?>
<?php echo $row['dwd'];?>
<?php echo $row['fwd'];?>
<?php echo $row['dr'];?>
<?php echo $row['whs'];?>
<?php echo $row['wm'];?>
<?php echo $row['ed'];?>
<?php echo $row['wta'];?>
<?php echo $row['opi'];?>
<?php echo $row['ld'];?>
<?php echo $row['da'];?>
<?php echo $row['osc'];?>
<?php echo $row['nd'];?>
<?php echo $row['others'];?>
</td>
<td><button class="btn-danger-dark">View</button></td> <--VIEW BUTTON
</tr>
<?php $cnt=$cnt+1; } ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<div class="addNewRow"></div>
</div>
</div>
<script src="assets/plugins/jquery-1.8.3.min.js" type="text/javascript">
</script>
<script src="assets/plugins/jquery-ui/jquery-ui-1.10.1.custom.min.js" type="text/javascript"></script>
<script src="assets/plugins/boostrapv3/js/bootstrap.min.js" type="text/javascript"></script>
<script src="assets/plugins/breakpoints.js" type="text/javascript"></script>
<script src="assets/plugins/jquery-unveil/jquery.unveil.min.js" type="text/javascript"></script>
<script src="assets/plugins/jquery-scrollbar/jquery.scrollbar.min.js" type="text/javascript"></script>
<script src="assets/plugins/jquery-block-ui/jqueryblockui.js" type="text/javascript"></script>
<script src="assets/plugins/jquery-numberAnimate/jquery.animateNumbers.js" type="text/javascript"></script>
<script src="assets/plugins/bootstrap-select2/select2.min.js" type="text/javascript"></script>
<script src="assets/plugins/jquery-datatable/js/jquery.dataTables.min.js" type="text/javascript" ></script>
<script src="assets/plugins/jquery-datatable/extra/js/dataTables.tableTools.min.js" type="text/javascript" >
</script>
<script type="text/javascript" src="assets/plugins/datatables-responsive/js/datatables.responsive.js"></script>
<script type="text/javascript" src="assets/plugins/datatables-responsive/js/lodash.min.js"></script>
<script src="assets/js/datatables.js" type="text/javascript"></script>
<script src="assets/js/core.js" type="text/javascript"></script>
<script src="assets/js/chat.js" type="text/javascript"></script>
<script src="assets/js/demo.js" type="text/javascript"></script>
</body>
</html>
Have you considered a different approach?
If the two tables have the exact same structure, then all you need is a single table and add a column called 'accepted' and use 1 and 0 values to act as true and false.
Then you can search this single table WHERE 'accepted' = 1 for accepted entries, or 0 for denied entries. And to change an entry's status, simply update a single column. Much easier.
Example:
$result = mysqli_query("SELECT * FROM tableName WHERE accepted = 1");
That will get only entries you have marked as accepted.
Change it to WHERE accepted = 0" to get the denied entries.
And here is how you can allow the admin to change an entry's accepted/denied status easily:
$update = mysqli_query("UPDATE tableName SET accepted = 1 WHERE id = 12345");
By the way, I suggest you use mysqli instead of mysql, heres a good answer why.
Related
Am having a problem with fetching posts from database. The posts are fecthed properly but each row has a different post. The posts are fetched vertically which is not what i want.
Here is my code;
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<title>Document</title>
</head>
<body>
<?php
require 'config.php';
?>
<?php $sql = "SELECT * FROM contents";
$query_run = mysqli_query($con, $sql);
//Check if there is data
$check_data = mysqli_num_rows($query_run) > 0;
if($check_data) {
while($row = mysqli_fetch_assoc($query_run)) {
?>
<section>
<div class="container">
<div class="row">
<div class="col-4">
<div class="card mt-5">
<div class="card-body">
<img src="images/<?php echo $row['images'] ?>" alt="" class="card-img-top">
<h2 class="card-title"><?php echo $row['title']; ?></h2>
<h3 class="card-desc"><?php echo $row['short_desc']; ?></h3>
</div>
</div>
</div>
<div class="col-4">
<div class="card mt-5">
<div class="card-body">
<img src="images/<?php echo $row['images'] ?>" alt="" class="card-img-top">
<h2 class="card-title"><?php echo $row['title']; ?></h2>
<h3 class="card-desc"><?php echo $row['short_desc']; ?></h3>
</div>
</div>
</div>
</div>
</div>
</section>
<?php
//To fetch the data into the correct places we will need to divide the php from while loop();
}
}
?>
</body>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
</body>
</html>
Here is the output of the above code;
The posts tripple them selves according to the columns in the code but I would like to have a different post in every card in the same row
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<title>Document</title>
</head>
<body>
<?php
require 'config.php';
?>
<?php $sql = "SELECT * FROM contents";
$query_run = mysqli_query($con, $sql);
//Check if there is data
$check_data = mysqli_num_rows($query_run) > 0;
if($check_data) {
$rows = mysqli_fetch_assoc($query_run)
?>
<section>
<div class="container">
<?php
$total_rows = count($rows) % 3 > 0 ? count($rows) % 3 + 1 : count($rows) / 3 ;
$rows_counter = 0;
$column_counter = 0;
while($rows_counter<$total_rows)
{
?>
<div class="row">
<?php for($i=0;$i<$rows_counter+1==$total_rows ? count($row)%3 ? 3;$i++) {
$row = $rows[$colum_counter]
$column_counter++;
?>
<div class="col-4">
<div class="card mt-5">
<div class="card-body">
<img src="images/<?php echo $row['images'] ?>" alt="" class="card-img-top">
<h2 class="card-title"><?php echo $row['title']; ?></h2>
<h3 class="card-desc"><?php echo $row['short_desc']; ?></h3>
</div>
</div>
</div>
<?php } ?>
</div>
</div>
</section>
<?php
}
$rows_counter++;
}
?>
</body>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
</body>
</html>
I am trying to retrieve data from a database and display it on the PHP file using the following code:
index.php
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Control Panel</title>
<!-- Bootstrap -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<!-- Font Awesome -->
<link href="css/font-awesome.min.css" rel="stylesheet">
<!-- NProgress -->
<link href="css/nprogress.css" rel="stylesheet">
<!-- iCheck -->
<link href="css/green.css" rel="stylesheet">
<!-- Datatables -->
<link href="css/dataTables.bootstrap.min.css" rel="stylesheet">
<link href="css/buttons.bootstrap.min.css" rel="stylesheet">
<link href="css/fixedHeader.bootstrap.min.css" rel="stylesheet">
<link href="css/responsive.bootstrap.min.css" rel="stylesheet">
<link href="css/scroller.bootstrap.min.css" rel="stylesheet">
<!-- Custom Theme Style -->
<link href="css/custom.min.css" rel="stylesheet">
</head>
<body class="nav-md">
<div class="container body">
<div class="main_container">
<div class="col-md-12 left_col">
<div class="left_col scroll-view">
<div class="col-md-12 col-sm-12 col-xs-12">
<div class="x_panel">
<div class="x_content">
<?php
$count_rows = 0;
include 'database_connection.php';
$sql = "SELECT date, ip, activate FROM software";
$result = $conn->query($sql);
echo "<table id='datatable-buttons class='table table-striped table-bordered'>
<tr>
<th>S/N</th>
<th>Date</th>
<th>IP Address</th>
<th>Activation</th>
</tr>";
while ($row = mysqli_fetch_array($result)) {
$count_rows++;
echo "<tr>";
echo "<td>" . $count_rows . "</td>";
echo "<td>" . $row['date'] . "</td>";
echo "<td>" . $row['ip'] . "</td>";
echo "<td>" . $row['activate'] . "</td>";
echo "</tr>";
}
mysqli_close($conn);
?>
<!-- jQuery -->
<script src="js/jquery.min.js"></script>
<!-- Bootstrap -->
<script src="js/bootstrap.min.js"></script>
<!-- FastClick -->
<script src="js/fastclick.js"></script>
<!-- NProgress -->
<script src="js/nprogress.js"></script>
<!-- iCheck -->
<script src="js/icheck.min.js"></script>
<!-- Datatables -->
<script src="js/jquery.dataTables.min.js"></script>
<script src="js/dataTables.bootstrap.min.js"></script>
<script src="js/dataTables.buttons.min.js"></script>
<script src="js/buttons.bootstrap.min.js"></script>
<script src="js/buttons.flash.min.js"></script>
<script src="js/buttons.html5.min.js"></script>
<script src="js/buttons.print.min.js"></script>
<script src="js/dataTables.fixedHeader.min.js"></script>
<script src="js/dataTables.keyTable.min.js"></script>
<script src="js/dataTables.responsive.min.js"></script>
<script src="js/responsive.bootstrap.js"></script>
<script src="js/dataTables.scroller.min.js"></script>
<script src="js/jszip.min.js"></script>
<script src="js/pdfmake.min.js"></script>
<script src="js/vfs_fonts.js"></script>
<!-- Custom Theme Scripts -->
<script src="js/custom.min.js"></script>
</body>
</html>
I am getting the results but it's not properly formatted. With almost the same code I can get the design but not the data: Here's the code that is working but not showing the data.
index.html (Incomplete code)
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Control Panel</title>
<!-- Bootstrap -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<!-- Font Awesome -->
<link href="css/font-awesome.min.css" rel="stylesheet">
<!-- NProgress -->
<link href="css/nprogress.css" rel="stylesheet">
<!-- iCheck -->
<link href="css/green.css" rel="stylesheet">
<!-- Datatables -->
<link href="css/dataTables.bootstrap.min.css" rel="stylesheet">
<link href="css/buttons.bootstrap.min.css" rel="stylesheet">
<link href="css/fixedHeader.bootstrap.min.css" rel="stylesheet">
<link href="css/responsive.bootstrap.min.css" rel="stylesheet">
<link href="css/scroller.bootstrap.min.css" rel="stylesheet">
<!-- Custom Theme Style -->
<link href="css/custom.min.css" rel="stylesheet">
</head>
<body class="nav-md">
<div class="container body">
<div class="main_container">
<div class="col-md-12 left_col">
<div class="left_col scroll-view">
<div class="col-md-12 col-sm-12 col-xs-12">
<div class="x_panel">
<div class="x_content">
<table id="datatable-buttons" class="table table-striped table-bordered">
<thead>
<tr>
<th>S/N</th>
<th>Date</th>
<th>IP Address</th>
<th>Activation</th>
</tr>
</thead>
<tbody>
<tr>;
<td> $row['id'] </td>
<td> $row['date'] </td>
<td> $row['ip'] </td>
<td> $row['activate'] </td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<!-- jQuery -->
<script src="js/jquery.min.js"></script>
<!-- Bootstrap -->
<script src="js/bootstrap.min.js"></script>
<!-- FastClick -->
<script src="js/fastclick.js"></script>
<!-- NProgress -->
<script src="js/nprogress.js"></script>
<!-- iCheck -->
<script src="js/icheck.min.js"></script>
<!-- Datatables -->
<script src="js/jquery.dataTables.min.js"></script>
<script src="js/dataTables.bootstrap.min.js"></script>
<script src="js/dataTables.buttons.min.js"></script>
<script src="js/buttons.bootstrap.min.js"></script>
<script src="js/buttons.flash.min.js"></script>
<script src="js/buttons.html5.min.js"></script>
<script src="js/buttons.print.min.js"></script>
<script src="js/dataTables.fixedHeader.min.js"></script>
<script src="js/dataTables.keyTable.min.js"></script>
<script src="js/dataTables.responsive.min.js"></script>
<script src="js/responsive.bootstrap.js"></script>
<script src="js/dataTables.scroller.min.js"></script>
<script src="js/jszip.min.js"></script>
<script src="js/pdfmake.min.js"></script>
<script src="js/vfs_fonts.js"></script>
<!-- Custom Theme Scripts -->
<script src="js/custom.min.js"></script>
</body>
</html>
Of course I know that the index.html code is Incorrect or incomplete. However it does load the bootstrap table design perfectly. What am I doing on the PHP file?
Please guide me here.
Screenshot of index.php : http://oi65.tinypic.com/z7ed3.jpg
Screenshot of index.html: http://oi68.tinypic.com/2zqqvc6.jpg
Please change your code in index.php file:
<table id='datatable-buttons class='table table-striped table-bordered'>
to
<table id='datatable-buttons' class='table table-striped table-bordered'>
you didn't close quote after id datatable-buttons
and add </table> after the end of while block
In your case, you can change your code to code below:
<table id="datatable-buttons" class="table table-striped table-bordered">
<thead>
<tr>
<th>S/N</th>
<th>Date</th>
<th>IP Address</th>
<th>Activation</th>
</tr>
</thead>
<tbody>
<?php
$count_rows = 0;
include 'database_connection.php';
$sql = "SELECT `date`, `ip`, `activate` FROM `software`";
$result = $conn->query($sql);
while ($row = mysqli_fetch_array($result)):
$count_rows++;
?>
<tr>
<td><?php echo $count_rows ?></td>
<td><?php echo $row['id']; ?></td>
<td><?php echo $row['date']; ?></td>
<td><?php echo $row['ip']; ?></td>
<td><?php echo $row['activate']; ?></td>
</tr>
<?php endwhile; ?>
</tbody>
</table>
I want to fetch records from database in category field with a button next to it, and when I click on that button there is a bootstrap collapse on which I have to display records from another database which is the sub-category of that specific category field and it should dynamically fetch the records as per above category field., and will be keep on changing when changes done from admin side. I want to write PHP code in SQL query, below code shows no error but does not provides me the expected outcome. Please Help me friends.
<?php
$conn = mysqli_connect("localhost","root","","zuuvee");
$query = mysqli_query($conn, "SELECT * FROM category_name");
$query1 = mysqli_query($conn, "SELECT * FROM subcategory_name WHERE category = 'Apparel & Accessories'");
?>
<!DOCTYPE html>
<html>
<head>
<title>Category</title>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="style.css">
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
</head>
<body>
<?php
while ($row = mysqli_fetch_array($query))
{
?>
<ul>
<li>
<span class="number"><?php echo $row['ID']; ?></span>
<span><a class="btn btn-primary" data-toggle="collapse" href="#third<?php echo $row['ID']; ?>" aria-expanded="false"></a>
<span><label name ="lb1"><?php echo $row['name']; ?></label></span>
<div class="collapse" id="third<?php echo $row['ID']; ?>">
<div class="card" style="width: 18rem;">
<div class="card-body">
<?php
while ($row1 = mysqli_fetch_array($query1))
{
?>
<h5 class="card-title"><?php echo $row1['subcategory']; ?></h5>
<?php
}
?>
</div>
</div>
</div></span>
<span class="points">00</span>
<span class="badge"><i class= "fa fa-microchip" aria-hidden="true"></i></span>
</li>
</ul>
<?php
}
?>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js" integrity="sha384-vFJXuSJphROIrBnz7yo7oB41mKfc8JzQZiCq4NCceLEaO4IHwicKwpJf9c9IpFgh" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js" integrity="sha384-alpBpkh1PFOepccYVYDB4do5UnbKysX5WZXm3XxPqe5iKTfUKjNkCk9SaVuEZflJ" crossorigin="anonymous"></script>
</body>
</html>
previous page (added as edit)
<!DOCTYPE html>
<html lang="en">
<head>
<script src="jquery-2.1.1.min.js"></script>
<script src="jquery/jquery-ui-1.11.2/jquery-ui.js"></script>
<link rel="stylesheet" type="text/css" href="jquery/jquery-ui-1.11.2/jquery-ui.css">
<link rel="stylesheet" type="text/css" href="bootstrap-3.3.1-dist/dist/css/bootstrap-theme.css">
<link rel="stylesheet" type="text/css" href="bootstrap-3.3.1-dist/dist/css/bootstrap-theme.min.css">
<link rel="stylesheet" type="text/css" href="bootstrap-3.3.1-dist/dist/css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="bootstrap-3.3.1-dist/dist/css/bootstrap.min.css">
<script src="bootstrap-3.3.1-dist/dist/js/bootstrap.js"></script>
<script src="bootstrap-3.3.1-dist/dist/js/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css" href="/CSS/handover.css">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>IgG Dashboard</title>
<script>
$(document).ready(function() {
// Datepicker Popups calender to Choose date.
$(function() {
$("#datepicker").datepicker({ dateFormat: 'yy-mm-dd' });
});
});
</script>
<!-- Just for debugging purposes. Don't actually copy these 2 lines! -->
<!--[if lt IE 9]><script src="../../assets/js/ie8-responsive-file-warning.js"></script><![endif]-->
<script src="../../assets/js/ie-emulation-modes-warning.js"></script>
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="Dashboard.php">IgG Dashboard</a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>Messages</li>
<li>Scripts and Options Editor</li>
<li>Add User</li>
<li id= "dash"><p >Welcome <?php echo " " .$_SESSION['myuser']." ";?><a class="btn bg-info" href="Dashboard.php">Main Site</a></p></li>
</ul>
</div><!-- /.nav-collapse -->
</div><!-- /.container -->
</div><!-- /.navbar -->
<div class="jumbotron">
<div class="container-fluid">
<br>
<br>
<br><br>
<?php
$scripte = ($_POST["scriptake"]);
$scriptot =($_POST["scriptot"]);
include 'config.php';
echo '<h2>'.$scripte.' Equipment</h2>';
echo '<h2>Total Hours '.$scriptot.'</h2>';
echo'<table class="table table-responsive"><tr><form action="equiptest.php" method="post"><th>Script Hour</th><th>Equipment Required</th><th>Stage</th></tr>';
$x = 1;
$p = 1;
$r=1;
while($x <= $scriptot ) {
echo "<tr><td>".$x++."</td><td><input name='equip".$r++."'` ></td><td><input name='stage".$p++."'><input name='ohyeah' type='hidden' value= '".$scriptot."'></td></tr>";
}
echo'<tr><td colspan="2"><input type="submit" class="btn btn-primary"></td></tr></form></table>';
?>
</div>
Can I do this with a post variable. I get undefined. However if I write
equip1 = ($_POST["equip1"]);
echo $equip1;
it works
<?php
$scriptot = ($_POST["ohyeah"]);// working
$y = 1;
$x = 1;
$r= 1;
while($x <= $scriptot ) {//working
${"equip".$x} = ($_POST["equip".$x]); //not working
echo ${"equip" .$x};//not working
$x++; // working
}
I am trying to create dyanmic variables. Idea in this case is to insert POST to database
so want
$equip1
$equip2
$equip3 etc
Thanks
For organizational purposes, you should really use arrays.
For instance, in a form you can set the input name to 'equip[1]' and the value will imported to PHP as $_POST['equip'][1]. Then you can just run:
foreach($_POST['equip'] as $key=>$value) {
# where $key = 1, the $value will be of equip[1]
}
May not be exactly what you're after, but it seems like a much cleaner solution than what you are attempting.
This is how I try.
<?php while ( have_posts() ) : the_post(); ?>
<div class="contentTitle"><?php the_title(); ?></div>
<div class="contentText">
<?php the_content(); ?>
</div>
<?php endwhile ?>
I develop a jQuery mobile site and want to display pie chart, the data fetch form database to show in pie chart. Since the jQuery mobile link to another page using div, I make one div in index.php to display data from database, then when the data is showing up, I can view the data by click on the view link. At this part, I make jQuery load to load page piechart.php when click on the view link. The piechart.php page success called by jQuery load, but pie chart not appear, BUT if I right click on page and click view inspect element, it starts showing up normally the pie chart.
Why do I need to right click to display it??
This is index.php
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>SSPIC</title>
<meta name="viewport" content="width=device-width, maximum-scale=1.0, minimum-scale=1.0, initial-scale=1" />
<meta name="description" content="This site was created from a template originally designed and developed by Codify Design Studio. Find more free templates at http://www.adobe.com/devnet/author_bios/chris_converse.html" />
<link href="jquery-mobile/jquery.mobile.structure-1.0.min.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/formcalculations.js"></script>
<link href="styles/cakeform.css" rel="stylesheet" type="text/css" />
<script src="jquery-mobile/jquery-1.6.4.min.js" type="text/javascript"></script>
<script src="jquery-mobile/jquery.mobile-1.0.min.js" type="text/javascript"></script>
<link rel="stylesheet" href="themes/my_company.min.css" />
<link rel="stylesheet" href="includes/overrides.css" />
<script type="text/javascript" src="includes/custom.js"></script>
<script type="text/javascript" src="js/jquery-1.7.1.min.js"></script>
<link href="stylesheets/app.css" media="screen, projector, print" rel="stylesheet" type="text/css" />
<link href="stylesheets/pizza.css" media="screen, projector, print" rel="stylesheet" type="text/css" />
<script src="javascripts/vendor/snap.svg.js"></script>
<script src="javascripts/pizza.js"></script>
<script type="text/javascript">
function MM_popupMsg(msg) { //v1.0
alert(msg);
}
</script>
</head>
<body onload='hideTotal()'>
<div data-role="page" id="home" data-theme="a">
<div data-role="header">
<h1>Homepage</h1>
</div>
<div data-role="content">
<ul data-role="listview">
<li class="btn_a">About Us</li>
<li class="btn_s">Services</li>
<li class="btn_l">Search</li>
<li class="btn_c">Upload</li>
<li class="btn_c">Chart</li>
</ul>
</div>
<div data-role="">
</div>
</div>
<div data-role="page" id="locations" data-title="Find a Locations">
<div data-role="header">
<h1>Search Data</h1>
back
</div>
<div data-role="content">
<p></p>
<h2>Search Data</h2>
</div>
<div data-role="footer">
<div data-role="controlgroup" data-type="horizontal">
Home
</div>
<h4>©2013 SSPIC</h4>
</div>
</div>
<div data-role="page" id="contact_us" data-title="Contact Us">
<div data-role="header">
<h1>Upload</h1>
back
</div>
<div data-role="content" class="content_container">
<p><form action="insertimage.php" method="post" enctype="multipart/form-data" name="form1">
<h2 align="center"> </h2>
<h2 align="center">Information</h2>
<table width="63%" border="1" align="center">
<tr>
<td width="40%">Upload File</td>
<td width="60%"><input name="pic" type="file" id="pic" /></td>
</tr>
<tr>
<td colspan="2"><div align="center">
<input type="submit" name="Submit" value="Submit" />
</div></td>
</tr>
</table>
<p align="center"> </p>
<p align="center"> </p>
<p align="center">
</form></p>
</div>
<div data-role="footer">
<div data-role="controlgroup" data-type="horizontal">
Home
</div>
<h4>©2013 SSPIC</h4>
</div>
</div>
<div data-role="page" id="chart" data-title="chart Us" class="chart">
<div data-role="header">
<h1>Pie Chart</h1>
back
</div>
<div id="output" data-role="content" class="content_container"></div>
<div data-role="content" class="content_container" id="k_chart">
<p>
<form action="insertimage.php" method="post" enctype="multipart/form-data" name="form1">
<h2 align="center"> </h2>
<h2 align="center">Display File</h2>
<table width="63%" border="1" align="center" class="table_chart">
<tr>
<td width="40%">Bil</td>
<td width="60%">Pusat rawatan</td>
<td width="60%">Pengasas</td>
<td width="60%">Bil pengamal</td>
<td width="60%">Total</td>
<td width="60%">Phone number</td>
<td width="60%">Peratus</td>
<td width="60%">view chart</td>
</tr>
<?php
include("connection.php");
$sel = mysql_query("select * from info");
$a = 1;
while($get_sel = mysql_fetch_array($sel))
{
?>
<tr>
<td width="40%"><?php echo $a++;?></td>
<td width="60%"><?php echo $get_sel['nama_PusatRawatan'];?></td>
<td width="40%"><?php echo $get_sel['nama_Pengasas'];?></td>
<td width="60%"><?php echo $get_sel['bilangan_Pengamal'];?></td>
<td width="40%"><?php echo $get_sel['totalPrice'];?></td>
<td width="60%"><?php echo $get_sel['phonenumber'];?></td>
<td width="60%"><?php echo $get_sel['peratus'];?></td>
<td width="60%"><div class="id"><?php echo $get_sel['id'];?></div><span class="viewBtn">View</span></td>
</tr>
<?php
}
?>
</table>
<p align="center"> </p>
<p align="center"> </p>
<p align="center">
</form></p>
</div>
<div data-role="footer">
<div data-role="controlgroup" data-type="horizontal">
Home
</div>
<h4>©2013 SSPIC</h4>
</div>
</div>
<script>
$(document).ready(function(e) {
// Pizza.init();
$('.viewBtn').on('click',function()
{
var id = $(this).closest('td').find('.id').text();
$('#k_chart').hide();
$('#output').load("piechart.php?id="+id);//load page to display pie chart
});
$(window).load(function() {
Pizza.init({
donut: false, // enable donut chart
donut_inner_ratio: 0.4, // between 0 and 1
percent_offset: 35, // relative to radius
stroke_color: '#333',
stroke_width: 0,
show_percent: true, // show or hide the percentage on the chart.
animation_speed: 500,
animation_type: 'elastic' // options: backin, backout, bounce, easein, easeinout, easeout, linear
});
});
});
</script>
</body>
</html>
This one is piechart.php
<link href="jquery-mobile/jquery.mobile.structure-1.0.min.css" rel="stylesheet" type="text/css" />
<script src="jquery-mobile/jquery.mobile-1.0.min.js" type="text/javascript"></script>
<link rel="stylesheet" href="themes/my_company.min.css" />
<link rel="stylesheet" href="includes/overrides.css" />
<link href="stylesheets/app.css" media="screen, projector, print" rel="stylesheet" type="text/css" />
<link href="stylesheets/pizza.css" media="screen, projector, print" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/jquery-1.7.1.min.js"></script><script src="javascripts/vendor/snap.svg.js"></script>
<script src="javascripts/pizza.js"></script>
<div data-role="content" class="content_container">
<p>
<div id="jquery-script-menu">
<div class="jquery-script-center">
<div class="jquery-script-clear"></div>
</div>
</div>
<h1 style="margin-top:150px;" align="center">Papar peratus lulus pie chart </h1>
<div class="row">
<div class="large-12 columns">
<h3>Graphs</h3>
</div>
</div>
<?php
include("connection.php");
$id_info = $_GET['id'];
$papar = mysql_query("select *from info where id = '$id_info'");
$get_papar = mysql_fetch_array($papar);
if($get_papar['peratus']>0 and $get_papar['peratus']<=50)
{
$xlulus = $get_papar['peratus'];
$lulus = 100 - $xlulus;
}
else
{
$lulus = $get_papar['peratus'];
$xlulus = 100 - $lulus;
}
?>
<div class="row">
<div class="large-4 small-4 columns">
<ul data-pie-id="svg">
<li data-value="<?php echo $xlulus;?>">Tidak memenuhi syarat</li><li data-value="<?php echo $lulus;?>">Memenuhi syarat</li>
</ul>
</div>
<div class="large-8 small-8 columns">
<div id="svg"></div>
</div>
</div>
</p>
</div>
The jQuery code is at the bottom of page index.php..
You need to correctly time your plugin initialization.
First forget about document ready and window load, they will not work correctly with jQuery Mobile application (usually they trigger before jQuery Mobile content is successfully enhanced).
Instead you should learn how to use jQuery Mobile page events, for example pageinit event exists to replace document ready.
Read more about it here.
Now regarding your main problem, your plugin must be initialized during the pageshow event. A lot of visual plugins (carousels, charts ..) require correct page height. When working with jQuery Mobile page height is correctly calculated only during pageshow event, it will be 0 in any other case.
Page event initialization order can be found here.