codeigniter how to get the value of table row - php

I'm just wondering if you could help me get the value of a table row, then placing it to a model.
Here is my view:
<div class="table_design">
<style>
#tbl_ulist1 tr:hover td{
background-color: yellow;
}
#txt_fn1{
border: none;
background-color: transparent;
}
</style>
<form action="userslist" method="POST">
<input type="submit" id="new_user" name="new_user" value="Add New User"/>
<table id="tbl_ulist1">
<tr>
<!-- <th>Edit/Delete</th>-->
<th>First Name</th>
<th>Last Name</th>
<th>Middle Name</th>
<th>Birth Date</th>
<th>Contact Details</th>
<th>Email Add</th>
<th>User Type</th>
<th>Status</th>
</tr>
<?php foreach ($userslist as $row) { ?>
<tr id="tr1" data-toggle="modal" data-target="#myModal">
<!--<td>Edit</td>-->
<td><input type="text" id="txt_fn1" value="<?php echo $row->FirstName ?>" readonly/></td>
<td><?php echo $row->LastName ?></td>
<td><?php echo $row->MiddleName ?></td>
<td><?php echo $row->Birthdate ?></td>
<td><?php echo $row->ContactDetails ?></td>
<td><?php echo $row->EmailAdd ?></td>
<td><?php echo $row->UserType ?></td>
<td><?php echo $row->Status ?></td>
</tr>
<?php } ?>
</table>
</form>
</div>
and here is my div modal:
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog" style="width: 80%; height: 60%; margin-top: 200px;">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
<h4 style="color: black;"></h4>
<div class="modal-body">
<iframe style="width: 100%; height: 60%; border: none;" frameborder="0" src="<?php echo site_url('inventorysys_controller/edit_user'); ?>"></iframe>
<div class="modal-footer">
</div>
</div>
</div>
</div>
</div>
</div>
Here is the view of my iframe in my modal:
<div id="content">
<link rel="stylesheet" href="<?php echo base_url('assets/css/bootstrap.min.css'); ?>">
<style>
#tbl_edituser{
color: black;
}
</style>
<form action="edit_user" method="POST" name="frm_edituser" id="frm_edituser">
<fieldset>
<legend>Edit User</legend>
<table id="tbl_edituser">
<tr>
<td>First Name:</td>
<td><input type="text" name="txt_userfirst" id="txt_userfirst" value="<?php //echo $system_users->FirstName ?>"/></td>
<td>Last Name:</td>
<td><input type="text" name="txt_userlast" id="txt_userlast" value="<?php //echo $system_users->LastName ?>"/></td>
<td>Middle Name:</td>
<td><input type="text" name="txt_usermiddle" id="txt_usermiddle" value="<?php //echo $system_users->MiddleName ?>"/></td>
<td><input type="hidden" name="txt_edituserID" id="txt_edituserID" value="<?php //echo $system_users->ID ?>"/></td>
</tr>
<tr>
<td>Birth Date:</td>
<td><input type="date" name="dt_user" id="dt_user" style="width: 100%; height: 80%" value="<?php //echo //$system_users->Birthdate ?>"/></td>
<td>Email Address:</td>
<td><input type="text" name="txt_emailaddress" id="txt_emailaddress" value="<?php// echo $system_users->EmailAdd ?>"/></td>
<td>Contact Details:</td>
<td><input type="text" name="txt_contactdetails" id="txt_contactdetails" value="<?php// echo $system_users->ContactDetails ?>"/></td>
</tr>
<tr>
<td>Username:</td>
<td><input type="text" name="txt_editusername" id="txt_editusername" value="<?php// echo $system_users->Username ?>"/></td>
<td>Password:</td>
<td><input type="password" name="txt_editpassword" id="txt_editpassword" value="<?php //echo $system_users->Password ?>"/></td>
<td>User Type:</td>
<td>
<select id="cbo_editusertype" name="cbo_editusertype" style="width: 100%">
<option><?php// echo $system_users->UserType ?></option>
<option>Administrator</option>
<option>User</option>
</select>
</td>
</tr>
<tr>
<td>Status:</td>
<td>
<select id="cbo_edituserstatus" name="cbo_edituserstatus" style="width: 100%">
<option><?php //echo $system_users->Status ?></option>
<option>Active</option>
<option>Inactive</option>
</select>
</td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td><input type="button" id="btn_edituserdetails" name="btn_edituserdetails" onclick="validate_editsystemusers();" value="Update"/> <input type="button" id="btn_deleteuserdetails" name="btn_deleteuserdetails" onclick="validate_deletesystemuser();" value="Delete"/></td>
</tr>
</table>
<input type="hidden" name="ninja14" id="ninja14" value=""/>
</fieldset>
</form>
Here is the controller of my modal:
public function edit_user(){
// $data_users['system_users'] = $this->inventory_model->select_systemusers();
// $this->load->view('homeview');
$this->load->view('edituser_view');
// $this->load->view('footer_view');
}
Help me on this one please! I've spend hours thinking about this one.

Related

How do I stop user from leaving quantity empty?

So this is my order page and I want to add an option which prevents the user from leaving the quantity option empty. I cannot seem to use the required option as it compels the user to fill every box instead of the one just selected.
Here is the code
<body>
<?php include('navbar.php'); ?>
<div class="container">
<h1 class="page-header text-center">ORDER</h1>
<form method="POST" action="purchase.php">
<table class="table table-striped table-bordered">
<thead>
<th class="text-center"><input type="checkbox" id="checkAll"></th>
<th class="productheading">Category</th>
<th class="productheading">Product Image
<th class="productheading">Product Name</th>
<th class="productheading">Price</th>
<th class="productheading">Quantity</th>
</thead>
<tbody>
<?php
$sql = "select * from product left join category on category.categoryid=product.categoryid order by product.categoryid asc, productname asc";
$query = $conn->query($sql);
$iterate = 0;
while ($row = $query->fetch_array()) {
?>
<tr>
<td class="text-center"><input type="checkbox" value="<?php echo $row['productid']; ?>||<?php echo $iterate; ?>" name="productid[]" style=""></td>
<td><?php echo $row['catname']; ?></td>
<td><a href="<?php if (empty($row['photo'])) {
echo "upload/noimage.jpg";
} else {
echo $row['photo'];
} ?>"><img src="<?php if (empty($row['photo'])) {
echo "upload/noimage.jpg";
} else {
echo $row['photo'];
} ?>" height="170px" width="80%"></a></td>
<td class="productname1"><?php echo $row['productname']; ?></td>
<td class="price">Rs <?php echo number_format($row['price'], 2); ?></td>
<!-->**HERE IS THE CODE THAT NEEDS TO BE FIXED**--> <td><input type="number" class="form-control" name="quantity<?php echo $iterate; ?>"></td>
</tr>
<?php
$iterate++;
}
?>
</tbody>
</table>
<div class="row">
<div class="col-md-3">
<input type="text" name="customer" class="form-control" placeholder="Customer Name" required>
</div>
<div class="col-md-3">
<input type="number" name="number" class="form-control" placeholder="Contact Number" required>
</div>
<div class="col-md-2" style="margin-left:-20px;">
<button type="submit" onclick="myFunction()" class="btn btn-primary"><span class="glyphicon glyphicon-floppy-disk"></span> Order</button>
<br />
<br />
<br />
</div>
</div>
</form>
</div>
<script type="text/javascript">
$(document).ready(function() {
$("#checkAll").click(function() {
$('input:checkbox').not(this).prop('checked', this.checked);
});
});
</script>
</body>
</html>
You can target those fields with jQuery/JavaScript and make it required by focusing on it and then prevent the form from submitting. Try this
$(document).ready(function() {
$('#order-form').submit(function(e){
let $quantities = $(this).find('.table input[type="number"]').filter(function(){
return $(this).closest('tr').find('input[type="checkbox"]').is(':checked') && $(this).val() === '';
})
if( $quantities.length > 0 ){
e.preventDefault();
$quantities.first().focus()
}
})
});
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#3.3.7/dist/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<div class="container">
<form method="POST" action="purchase.php" id="order-form">
<table class="table table-striped table-bordered">
<thead>
<th class="text-center"><input type="checkbox" id="checkAll"></th>
<th class="productheading">Category</th>
<th class="productheading">Product Image
<th class="productheading">Product Name</th>
<th class="productheading">Price</th>
<th class="productheading">Quantity</th>
</thead>
<tbody>
<tr>
<td class="text-center"><input type="checkbox" value="1" name="productid[]" checked></td>
<td>Dishes</td>
<td><img src="https://via.placeholder.com/150/0000FF/FFFFFF?text=Bara" height="170px" width="80%"></td>
<td class="productname1">Bara</td>
<td class="price">Rs 79.00</td>
<td><input type="number" class="form-control" name="quantity[]"></td>
</tr>
<tr>
<td class="text-center"><input type="checkbox" value="1" name="productid[]"></td>
<td>Dishes</td>
<td><img src="https://via.placeholder.com/150/FF0000/FFFFFF?text=Chwela" height="170px" width="80%"></td>
<td class="productname1">Chwela</td>
<td class="price">Rs 120.00</td>
<td><input type="number" class="form-control" name="quantity[]"></td>
</tr>
</tbody>
</table>
<button type="submit" class="btn btn-primary"><span class="glyphicon glyphicon-floppy-disk"></span> Order</button>
</form>
</div>
Answer in format requested by the OP
<body>
<?php include('navbar.php'); ?>
<div class="container">
<h1 class="page-header text-center">ORDER</h1>
<form method="POST" action="purchase.php" id="order-form">
<table class="table table-striped table-bordered">
<thead>
<th class="text-center"><input type="checkbox" id="checkAll"></th>
<th class="productheading">Category</th>
<th class="productheading">Product Image
<th class="productheading">Product Name</th>
<th class="productheading">Price</th>
<th class="productheading">Quantity</th>
</thead>
<tbody>
<?php
$sql = "select * from product left join category on category.categoryid=product.categoryid order by product.categoryid asc, productname asc";
$query = $conn->query($sql);
$iterate = 0;
while ($row = $query->fetch_array()) {
?>
<tr>
<td class="text-center"><input type="checkbox" value="<?php echo $row['productid']; ?>||<?php echo $iterate; ?>" name="productid[]" style=""></td>
<td><?php echo $row['catname']; ?></td>
<td><a href="<?php if (empty($row['photo'])) {
echo "upload/noimage.jpg";
} else {
echo $row['photo'];
} ?>"><img src="<?php if (empty($row['photo'])) {
echo "upload/noimage.jpg";
} else {
echo $row['photo'];
} ?>" height="170px" width="80%"></a></td>
<td class="productname1"><?php echo $row['productname']; ?></td>
<td class="price">Rs <?php echo number_format($row['price'], 2); ?></td>
<td><input type="number" class="form-control" name="quantity<?php echo $iterate; ?>"></td>
</tr>
<?php
$iterate++;
}
?>
</tbody>
</table>
<div class="row">
<div class="col-md-3">
<input type="text" name="customer" class="form-control" placeholder="Customer Name" required>
</div>
<div class="col-md-3">
<input type="number" name="number" class="form-control" placeholder="Contact Number" required>
</div>
<div class="col-md-2" style="margin-left:-20px;">
<button type="submit" class="btn btn-primary"><span class="glyphicon glyphicon-floppy-disk"></span> Order</button>
<br />
<br />
<br />
</div>
</div>
</form>
</div>
<script type="text/javascript">
$(document).ready(function() {
$("#checkAll").click(function() {
$('input:checkbox').not(this).prop('checked', this.checked);
});
$('#order-form').submit(function(e){
let $quantities = $(this).find('.table input[type="number"]').filter(function(){
return $(this).closest('tr').find('input[type="checkbox"]').is(':checked') && $(this).val() === '';
})
if( $quantities.length > 0 ){
e.preventDefault();
alert("Quantity is required")
$quantities.first().focus()
}
})
});
</script>
</body>
In case of users who have disabled Javascript, you should also check on the server for missing quantities:
// purchase.php
if (isset($_POST['productid'])) {
for ( $i=0; $i < sizeof($_POST['productid']); $i++ ) {
if ( $_POST['productid'][$i] && ! $_POST['quantity'][$i] ) {
echo "Missing quantity for " . $_POST['productid'][$i] . "<br>";
}
}
}

Is it possible to use media queries with a php file?

I am trying to make my site responsive and my media query was working but now it isn't. I made some changes and didn't use version control because I'm an idiot. Now I've taken out all the changes and the old media query isn't working, can anyone see why? I've included my css and the html I'm applying it to.
.contact_form {
margin: auto auto auto 27%;
}
.slides p {
margin: 2%;
text-align: center;
}
.slides h2 {
text-align: center;
font-size: 1.5em;
}
.required {
color: red;
}
.privacy p {
width: 60%;
text-align: center;
margin: auto;
}
#media screen and (max-width: 500px) {
.slides h2 {
text-align: center;
font-size: 1em;
margin: 10% auto auto auto;
}
.slides h1 {
text-align: center;
font-size: 2em;
margin: auto;
}
.contact_form {
margin: 2%;
}
.privacy p {
width: 90%;
text-align: center;
margin: auto;
}
.tablet_content {
display: none;
}
}
Html
<body>
<div class="banner">
<header>
<div id="ytWidget"></div>
<script src="https://translate.yandex.net/website-widget/v1/widget.js?widgetId=ytWidget&pageLang=en&widgetTheme=dark&autoMode=true" type="text/javascript"></script>
<br clear = "all">
<a href="index.html">
<h1>Laura Pohl Web Solutions</h1>
<h2>User Based Web Design</h2>
</a>
</header>
</div>
<div class="topnav" id="myTopnav">
Home
<div class="dropdown">
<button class="dropbtn">About</button>
<div class="dropdown-content">
My Story
Mascots
</div>
</div>
<div class="dropdown">
<button class="dropbtn">Portfolio</button>
<div class="dropdown-content">
Custom Web Design
Wordpress
<!--Wix
Squarespace-->
</div>
</div>
FAQ
Contact
<a href="javascript:void(0);" class="icon" onclick="myFunction()">
<i class="fa fa-bars"></i>
</a>
</div>
<main class="site-content">
<div class="gradient">
<br>
<div class="slide">
<div class="main">
<div class="slides">
<h1>Contact Questionnaire</h1>
<h2>If you’d like to work with me, I can’t wait to get started! Your first step is to fill out the custom form below.</h2>
<br>
<br>
</div>
</div>
<div class = "contact_form">
<form name="form4" action="Contact Us.php" method="post">
<input type = "hidden" name ="recipient" value ="1">
<input type = "hidden" name ="subject" value ="Contact Survey">
<input type = "hidden" name ="print_blank_fields" value ="1">
<input type="hidden" name="_pid" value="154040">
<input type="hidden" name="_fid" value="A7QPIZEA">
<table class ="contact_table">
<tbody>
<!--Row 1-->
<tr>
<td class = "questions">Name:<span class="required">*</span></td>
<td colspan = "6"><input name="sender" id="name" type="text" maxlength="30" class ="input_text_box required" title="Please type your name." required></td>
</tr>
<!--Row 2-->
<tr>
<td class = "questions">Email:</td>
<td colspan = "6"><input name="senderEmail" type="text" maxlength="30" class ="input_text_box"></td>
</tr>
<!--Row 3-->
<tr>
<td class = "questions">Phone:</td>
<td colspan = "6"><input name="senderPhone" type="text" id="textfield2" maxlength="30"class ="input_text_box"></td>
</tr>
<!--Row 4-->
<tr>
<td colspan = "7"> </td>
</tr>
<!--Row 5-->
<tr>
<td colspan = "7"> </td>
</tr>
<!--Row 6-->
<tr>
<td class = "questions" rowspan="2">Preferred Method of Contact?</td>
<td><input type="radio" name="preferredContact" value="phone" id="PreferredContact_0"></td>
<td colspan = "2" width = "30%">Phone</td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<!--Row 7-->
<tr>
<td><input type="radio" name="preferredContact" value="email" id="PreferredContact_2"></td>
<td colspan = "2">Email</td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<!--Row 8-->
<tr>
<td colspan = "7"> </td>
</tr>
<!--Row 9-->
<tr>
<td colspan = "7"> </td>
</tr>
<!--Row 10-->
<tr>
<td class = "questions" rowspan="2">Would you like a response?<span class="required">*</span></td>
<td><input type="radio" name="Response" value="Yes" id="PreferredContact_2"></td>
<td colspan = "2">Yes</td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<!--Row 11-->
<tr>
<td><input type="radio" name="Response" value="No" id="PreferredContact_3"></td>
<td>No</td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<!--Row 12-->
<tr>
<td colspan = "7"> </td>
</tr>
<!--Row 13-->
<tr>
<td colspan = "7"> </td>
</tr>
<!--Row 14-->
<tr>
<td class = "questions" rowspan="7">What would you like to talk about?<span class="required">*</span></td>
<td><input type="radio" name="topic" value="web_design"></td>
<td colspan = "5">Website Design</td>
</tr>
<!--Row 15-->
<tr>
<td><input type="radio" name="topic" value="re_design"></td>
<td colspan="5">Website Re-Design</td>
</tr>
<!--Row 16-->
<tr>
<td><input type="radio" name="topic" value="consultation"></td>
<td colspan="6">Schedule a Consultation</td>
</tr>
<!--Row 17-->
<tr>
<td><input type="radio" name="topic" value="quote"></td>
<td colspan="6">Request a Quote</td>
</tr>
<!--Row 18-->
<tr>
<td><input type="radio" name="topic" value="suggestions"></td>
<td colspan="6">Suggestions</td>
</tr>
<!--Row 19-->
<tr>
<td><input type="radio" name="topic" value="problems"></td>
<td colspan="6">Site Problems</td>
</tr>
<!--Row 20-->
<tr>
<td><input type="radio" name="topic" value="something_else"></td>
<td colspan="6">Something Else</td>
</tr>
<!--Row 21-->
<tr>
<td colspan = "7"> </td>
</tr>
<!--Row 22-->
<tr>
<td colspan = "7"> </td>
</tr>
<!--Row 23-->
<tr>
<td class = "questions" style="vertical-align:middle;">Message Text: </td>
<td colspan = "6" style="text-align: left">
<textarea rows = "5" name="message" maxlength="800" id="Comments" class ="input_text_box" required></textarea>
</td>
</tr>
<!--Row 24-->
<tr>
<td colspan = "7"> </td>
</tr>
<!--Row 25-->
<tr>
<td colspan = "7"> </td>
</tr>
<!--Row 26-->
<tr>
<td><input name="submit" type="submit" id="submit" title="Submit" value="Submit" style = "float:left"></td>
<td colspan = "5"> </td>
<td><input type="reset" name="reset" id="reset" value="Reset" style = "float:right"></td>
</tr>
</tbody>
</table>
</form>
</div>
</div>
</div>
<br clear = "all">
<br>
<div class="privacy">
<hr style="width: 20%;">
<p>I take your privacy seriously. I will never share any of your
information with anyone outside legal requirements. You will never be spammed or marketed
to by any of my partners.</p>
<hr style="width: 20%;">
</div>
</main>
<div class="big_screen_content">
<footer>
<!--start footer-->
© November 30, 2020 · Laura Pohl · Billerica, MA <!--Copyright signature-->
</footer>
<!--end footer-->
</div>

i get a empty table in foreach inside foreach : php

When in a form a user adds a number of schools, for example 3,
another form will appear which contains 3 lines containing the information of these 3 schools, and at the end I add the contents of the two forms in two tables.
In the first, wp_mairie_details, I add the information of the user.
In the second table I add the information of the schools.
I want to display the user's lists with the schools that last added in the form.
My first loop is displayed correctly but the second one displays the correct number of schools but I get an empty table.
<?php
foreach ( $dump_ecoles_classes_1 as $i => $ecoles_classe ) {
?>
<div class="abonn_style">
<span class="span_abonn_style">Nomde la mairie :</span><br>
<input type="text" name="nom_mairie" value="<?php echo $dump_ecoles_classes_1[$i]['nom_mairie']; ?>" disabled class="span_abonn_style">
<br>
<span class="span_abonn_style">Adresse:</span><br>
<textarea rows="4" cols="50" name="adress" value="<?php echo $dump_ecoles_classes_1[$i]['adress']; ?>" disabled class="span_abonn_style">
</textarea>
<br>
<span class="span_abonn_style">Responsable du projet:</span><br>
<input type="text" class="span_abonn_style" name="responsable" value="<?php echo $dump_ecoles_classes_1[$i]['responsable']; ?>" disabled>
<br>
<span class="span_abonn_style">E-mail:</span><br>
<input type="email" class="span_abonn_style" name="email" value="<?php echo $dump_ecoles_classes_1[$i]['email']; ?>" disabled>
<br>
<span class="span_abonn_style">Nombre de ecoles:</span><br>
<input type="number" name="ecoles" class="span_abonn_style" value="<?php echo $dump_ecoles_classes_1[$i]['ecoles']; ?>" disabled >
<br>
<?php
$i_var = $dump_ecoles_classes_1[$i]['ecoles'];
$mairie_ecoles_row = $wpdb->get_results("SELECT DISTINCT me.nom_ecole_mairie,me.responsable_mairie,me.email_mairie,me.nbr_classes_mairie,me.nbr_eleves_mairie,me.id_user FROM wp_mairie_ecoles me
INNER JOIN wp_mairie_details md ON md.id_user = me.id_user
INNER JOIN wp_pmpro_membership_orders mo ON mo.user_id = md.id_user
where me.id_user = '".$dump_ecoles_classes_1[$i]['id_user']."'
order by md.id_user");
$row_mairie_ecoles = objectToArray($mairie_ecoles_row);
foreach ( $row_mairie_ecoles as $k => $row_mairie_ecole ) {
?>
<table class="trios_table">
<tr class="trios_tr_style">
<th style="border: 2px solid black!important;background: #e4e4e4;">Nom de l’école
</th>
<th style="border: 2px solid black!important;background: #e4e4e4;">responsable
</th>
<th style="border: 2px solid black!important;background: #e4e4e4;">email
</th>
<th style="border: 2px solid black!important;background: #e4e4e4;">Nbre/classes
</th>
<th style="border: 2px solid black!important;background: #e4e4e4;">Nbre/élèves
</th>
</tr>
<tr class="trios_tr_style">
<td class="trios_td_style trios_td_style_1 ">
<?php
echo $row_mairie_ecoles[$k]['nom_ecole_mairie'];
?>
</td>
<td class="trios_td_style trios_td_style_1 ">
<?php
echo $row_mairie_ecoles[$k]['responsable_mairie'];
?>
</td>
<td class="trios_td_style trios_td_style_1 ">
<?php
echo $row_mairie_ecoles[$k]['email_mairie'];
?>
</td>
<td class="trios_td_style trios_td_style_1 ">
<?php
echo $row_mairie_ecoles[$k]['nbr_classes_mairie'];
?>
</td>
<td class="trios_td_style trios_td_style_1 ">
<?php
echo $row_mairie_ecolesrow_mairie_ecoles[$k]['nbr_eleves_mairie'];
?>
</td>
</tr>
</table>
<?php // } ?>
</div>
<?php } ?>
</div>
try this
<?php
foreach ( $dump_ecoles_classes_1 as $i => $ecoles_classe ) {
?>
<div class="abonn_style">
<span class="span_abonn_style">Nomde la mairie :</span><br>
<input type="text" name="nom_mairie" value="<?php echo $dump_ecoles_classes_1[$i]['nom_mairie']; ?>" disabled class="span_abonn_style">
<br>
<span class="span_abonn_style">Adresse:</span><br>
<textarea rows="4" cols="50" name="adress" value="<?php echo $dump_ecoles_classes_1[$i]['adress']; ?>" disabled class="span_abonn_style">
</textarea>
<br>
<span class="span_abonn_style">Responsable du projet:</span><br>
<input type="text" class="span_abonn_style" name="responsable" value="<?php echo $dump_ecoles_classes_1[$i]['responsable']; ?>" disabled>
<br>
<span class="span_abonn_style">E-mail:</span><br>
<input type="email" class="span_abonn_style" name="email" value="<?php echo $dump_ecoles_classes_1[$i]['email']; ?>" disabled>
<br>
<span class="span_abonn_style">Nombre de ecoles:</span><br>
<input type="number" name="ecoles" class="span_abonn_style" value="<?php echo $dump_ecoles_classes_1[$i]['ecoles']; ?>" disabled >
<br>
<?php
$i_var = $dump_ecoles_classes_1[$i]['ecoles'];
$mairie_ecoles_row = $wpdb->get_results("SELECT DISTINCT me.nom_ecole_mairie,me.responsable_mairie,me.email_mairie,me.nbr_classes_mairie,me.nbr_eleves_mairie,me.id_user FROM wp_mairie_ecoles me
INNER JOIN wp_mairie_details md ON md.id_user = me.id_user
INNER JOIN wp_pmpro_membership_orders mo ON mo.user_id = md.id_user
where me.id_user = '".$dump_ecoles_classes_1[$i]['id_user']."'
order by md.id_user");
$row_mairie_ecoles = objectToArray($mairie_ecoles_row);
foreach ( $row_mairie_ecoles as $k => $row_mairie_ecole ) {
?>
<table class="trios_table">
<tr class="trios_tr_style">
<th style="border: 2px solid black!important;background: #e4e4e4;">Nom de l’école
</th>
<th style="border: 2px solid black!important;background: #e4e4e4;">responsable
</th>
<th style="border: 2px solid black!important;background: #e4e4e4;">email
</th>
<th style="border: 2px solid black!important;background: #e4e4e4;">Nbre/classes
</th>
<th style="border: 2px solid black!important;background: #e4e4e4;">Nbre/élèves
</th>
</tr>
<tr class="trios_tr_style">
<td class="trios_td_style trios_td_style_1 ">
<?php
echo $row_mairie_ecoles[$k]['nom_ecole_mairie'];
?>
</td>
<td class="trios_td_style trios_td_style_1 ">
<?php
echo $row_mairie_ecoles[$k]['responsable_mairie'];
?>
</td>
<td class="trios_td_style trios_td_style_1 ">
<?php
echo $row_mairie_ecoles[$k]['email_mairie'];
?>
</td>
<td class="trios_td_style trios_td_style_1 ">
<?php
echo $row_mairie_ecoles[$k]['nbr_classes_mairie'];
?>
</td>
<td class="trios_td_style trios_td_style_1 ">
<?php
echo $row_mairie_ecolesrow_mairie_ecoles[$k]['nbr_eleves_mairie'];
?>
</td>
</tr>
</table>
<?php } ?>
</div>
<?php } ?>
</div>

mPDF error: Some data has already been output to browser, can't send PDF file while taking inputs

i created test1.php view this file contain inputs value in form on submit button redirecting to checkpdf.php , for creating pdf invoice file .but getting this error. how can solve it. in check pdf file getting all proper values without genrating pdf for testing.
following in code is in checkpdf.php
please check image
this is my test1.php view page
<?php
include 'config.php';
$query= "select * from qaote_dets";
if ($result=mysqli_query($conn,$query))
{
// Fetch one and one row
// Free result set
?>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css">
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">
</head>
<body>
<div class="col-md-12">
<h1>Test </h1>
</div>
<div class="col-md-12" style="padding-top: 32px;">
<div class="col-md-8" style="float:left;">
<form action='checkpdf.php' method='POST' id='quatepdf'>
<table border="1">
<tr>
<th>#sr. no</th>
<th>item no.</th>
<th>item description</th>
<th>quantity</th>
<th>price/unit</th>
</tr>
<?php
$i = 1;
while ($row=mysqli_fetch_row($result))
{
?>
<tr id="row<?php echo $i ?>">
<td>
<input type="checkbox" class="check1" id="checkdet<?php echo $i;?>" name="checkboxtest[]" value="<?php echo $row[1]; ?>">
</td>
<td>
<input type="text" class="form-control text1" id="text1" value="<?php echo $row[1]; ?> " name='item_name[]'><br>
</td>
<td>
<textarea class="form-control item desc" value="" name='item_desc[]'><?php echo $row[2];?></textarea>
</td>
<td>
<input type="text" class="form-control quantity<?php echo $i;?>" value="1" name='qty[]'>
</td>
<td>
<input type="text" class="form-control amnt<?php echo $i;?> " readonly="" name='amnt[]' value="<?php echo $row[3];?>" >
<input type="hidden" class="service<?php echo $i ?>" value="<?php echo $row[4];?>" name='service[]'>
</td>
</tr>
<?php $i++; } mysqli_data_seek($result, 0);?>
<tr>
<td>
<th colspan="3">Total</th>
</td>
<td>
<input type="text" readonly="" id="totamnt" value="" name="tolval">
</td>
</tr>
<tr>
<td>
<th colspan="3">GSt(18%)</th>
</td>
<td>
<input type="text" readonly="" id="gst" value="" name="gstamt">
</td>
</tr>
<tr>
<td>
<th colspan="3">Final Amount</th>
</td>
<td>
<input type="text" readonly="" id="finamt" value="" name="finalamt">
</td>
</tr>
</table>
<div class="col-md-12" style="padding-top:10px;">
<div class="col-md-4" style="float: left;">
<input type="button" value="Calculate" class="btn-success" id="Calculate">
</div>
<div class="col-md-4" style="float: left;">
<input type="submit" value="Genrate Pdf" class="btn-success" name="pdfbtn">
</div>
<div class="col-md-4"></div>
</div>
</form>
</div>
<div class="col-md-4" style="float:left;">
<table border = "1">
<tr>
<th>add product</th>
<th>#Sr no.</th>
<th>Item code</th>
<th>amount</th>
<th>installation charges</th>
</tr>
<?php
$i =1;
while ($row=mysqli_fetch_row($result))
{
?>
<tr>
<td>
<input type="checkbox" class="" name="" id="check<?php echo $i?>">
</td>
<td>
<span class=""> <?php echo $i;?></span>
</td>
<td>
<span class=""><?php echo $row[1];?> </span>
</td>
<td>
<span class=""><?php echo $row[3];?> </span>
</td>
<td>
<span class=""><?php echo $row[4];?></span>
</td>
</tr>
<?php $i++; } ?>
</table>
</div>
</div>
</body>
</html>
<?php
mysqli_free_result($result);
}
?>
this is my redirected checkpdf.php page
<?php
include("mpdf60/mpdf.php");
$logoFile = 'ssi.jpg';
$logoXPos = 10;
$logoYPos = 10;
$logoWidth = '40px';
/* valus checked */
$item_code = $_POST['item_name'];
$item_desc = $_POST['item_desc'];
$quantity = $_POST['qty'];
$price = $_POST['amnt'];
$service = $_POST['service'];
$totamt = $_POST['tolval'];
$gst = $_POST['gstamt'];
$final = $_POST['finalamt'];
/* close */
$pdf = new mPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
//$pdf->Cell(40,10,'Hello World!');
$pdf->Image( $logoFile, $logoXPos, $logoYPos, $logoWidth );
$pdf->WriteFixedPosHTML("<span> abc infotech<span>",550, 20, 50, 90, 'auto');
$pdf->WriteFixedPosHTML("<span> A-103, trimak co-op soc<span>",550, 25, 50, 90, 'auto');
$pdf->WriteFixedPosHTML("<span> vani ali, gandhi chowk<span>",550, 30, 50, 90, 'auto');
$pdf->WriteFixedPosHTML("<span> Badlapur(e) 421503<span>",550, 35, 50, 90, 'auto');
$pdf->WriteFixedPosHTML("<hr>",00, 44, 550, 55, 'auto');
$pdf->WriteFixedPosHTML("<div style='background-color:orange;'><span style='color:#000'>abc infotrch<span> <span stye='color:#000';>abcinfo#gmail.com</span> <span style='color:#000;'>contact : 9998898989</span></div>",50, 755, 1000, 5, 'auto');
// if(isset($_POST['pdfbtn'])){
if(!empty($_POST['checkboxtest'])) {
$htmlTable='<table border="1">
<tr>
<th>S. No.</th>
<th>Item code</th>
<th>Description</th>
<th>quantity</td>
<th>amount</th>
<th>service</th>
</tr>';
$i=1;
foreach($_POST['checkboxtest'] as $check) {
$htmlTable.='<tr>';
$htmlTable.='<td>'.$i;
$htmlTable.='</td>';
$htmlTable.='<td>'.$item_code[$i];
$htmlTable.='</td>';
$htmlTable.='<td>'. $item_desc[$i];
$htmlTable.='</td>';
$htmlTable.='<td>'.$quantity[$i];
$htmlTable.='</td>';
$htmlTable.='<td>'.$price[$i];;
$htmlTable.='</td>';
$htmlTable.='<td>'.$service[$i];
$htmlTable.='</td>';
$i++;
}
$htmlTable.='</tr>' ;
$htmlTable.='<tr> <td colspan=3> Total Amount </td>' ;
$htmlTable.='</tr> <td >'.$totamt.'</td></tr>' ;
$htmlTable.='<tr> <td colspan=3>Gst(18%) </td>' ;
$htmlTable.='</tr> <td >'.$gst.'</td></tr>' ;
$htmlTable.='<tr> <td colspan=3> Final Amount </td>' ;
$htmlTable.='</tr> <td >'.$final.'</td></tr>' ;
$htmlTable.='</table>';
}
// }
$pdf->WriteHTML($htmlTable);
$pdf->Output();
?>

I am trying to make a Edit form Using PHP

My html code but saved as Modyfyitems.php
<?include 'Login/login_check.php';?>
<?include 'inc/Application.php';?>
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Untitled Document</title>
<style type="text/css">
body {
background-color: #284489;
text-shadow: 0px 0px #FFFFFF;
color: #FFFFFF;
}
form1 {
background-color: #FFFFFF
}
</style>
<link rel="stylesheet" type="text/css" media="all" href="css/jsDatePick_ltr.min.css" />
<script type="text/javascript" src="js/jsDatePick.min.1.3.js"></script>
<script type="text/javascript">
window.onload = function(){
new JsDatePick({
useMode:2,
target:"datereceived",
dateFormat:"%d-%M-%Y"
});
};
</script>
</head>
<body>
<h2> </h2>
<form id="form1" name="form1" aling="center" method="post">
<div align="center">
<table width="393" border="0">
<tr>
<td><div align="center">
<h2><span style="text-align: left; color: #FFFFFF;">LAC Product Registery</span></h2>
</div></td>
</tr>
</table>
<p>
<input type="button" name="button4" id="button4" onClick="location.href='Menu.php'" value="Menu">
</p>
</div>
<div align="center" style="background-color: #FFFFFF; color: #000000;">
<table width="827" border="0" align="center">
<tr bgcolor="#FDFDFD">
<td width="501"><h3>Modify Items</h3>
<p>Enter Code
<input name="barcode" type="text" autofocus required="required" id="barcode" form="form1">
<input type="submit" name="search" id="search" onClick="location.href='Actions/loaditem.php'" value="Search">
</p>
<table width="500" border="0" cellpadding="10" cellspacing="1">
<tr>
<td width="141" bgcolor="#E8F1FC">Sponsor</td>
<td width="316" bgcolor="#E8F1FC"><?include 'Actions/loadLists/sponsor.php';?></td>
</tr>
<tr>
<td bgcolor="#f1f4f9">Date Received</td>
<td bgcolor="#f1f4f9"><input type="datetime" name="datereceived" value="<? echo $DateReceived; ?>" id="datereceived" placeholder="17-FEB-2014"></td>
</tr>
<tr>
<td bgcolor="#E8F1FC"><strong>Code</strong></td>
<td bgcolor="#E8F1FC"> </td>
</tr>
<tr>
<td bgcolor="#F1F4F9"><ul>
<li> Container</li>
</ul></td>
<td bgcolor="#F1F4F9"><input name="container" type="number" value="<? echo $Container; ?>" id="container" placeholder="0152"></td>
</tr>
<tr>
<td bgcolor="#E8F1FC"><ul>
<li>Pallet</li>
</ul></td>
<td bgcolor="#E8F1FC"><input name="pallet" type="number" value="<? echo $Pallet; ?>" id="number5" placeholder="0028"></td>
</tr>
<tr>
<td bgcolor="#F1F4F9"><ul>
<li>Amount</li>
</ul></td>
<td bgcolor="#F1F4F9"><input name="amount" type="number" id="number6" value="<? echo $Amount; ?>" placeholder="0002"></td>
</tr>
<tr>
<td bgcolor="#E8F1FC">Description</td>
<td bgcolor="#E8F1FC"><?include 'Actions/loadLists/descriptions.php';?></td>
</tr>
<tr>
<td bgcolor="#F1F4F9">Remarks</td>
<td bgcolor="#F1F4F9"><textarea name="remarks" id="remarks"><? echo $Remarks; ?></textarea></td>
</tr>
<tr>
<td bgcolor="#E8F1FC">Location</td>
<td bgcolor="#E8F1FC"><?include 'Actions/loadLists/locations.php';?></td>
</tr>
<tr>
<td height="18"> </td>
<td> </td>
</tr>
</table></td>
<td width="316" valign="top" style="text-align: left"><p><br>
</p>
<p> Documents</p>
<p> </p></td>
</tr>
</table>
</div>
<table width="383" border="0" align="center">
<tr>
<td width="377" style="text-align: center"><input type="button" name="button" id="button" value="Save">
...
<input type="button" name="button6" id="button6" onClick="location.href='Menu.php'" value="Cancel">
...
<input type="button" name="button2" id="button2" value="Delete">
...
<input type="button" name="button3" id="button3" value="Print Barcode"> </td>
</tr>
</table>
<p> </p>
<p> </p>
<p> </p>
</form>
<p> </p>
<p> </p>
</body>
</html>
Here is my PHP script
<?
$conn = mysql_connect('localhost', 'root', 'root');
if (!$conn)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("LAC", $conn);
$Barcode =$_REQUEST['barcode'];
$result = mysql_query("SELECT * FROM Lists WHERE Barcode = '$Barcode'");
$row = mysql_fetch_array($result);
if (!$result)
{
die("Error: Data not found..");
}
$Barcode = $row['Barcode'];
$Sponsor = $row['Sponsor'];
$DateReceived = $row['DateReceived'];
$Container = $row['Container'];
$Pallet = $row['Pallet'];
$Amount = $row['Amount'];
$Description = $row['Description'];
$Remarks = $row['Remarks'];
$Location = $row['Location'];
mysql_close($conn);
?>
So Basically I am trying to load all the text boxes and drop down boxes from the database when the correct barcode is entered and the search button is hit.
For some reason when I hit the search button it doesn't load anything it just reloads the page.
I am new to php but have programming experience in vb.net
I think your are initializing variables after fetching values from the database in PHP script. so the scope of those variable is only withing that file. So, I guess if you include that file in modifyitem.php, this would work.
thank you.

Categories