Add the class in each row of the table - php

I am working on my code as I have got a list of checkboxes in the table. I have got a problem with adding the class in each row because it will only add one class in one row when I select all the checkboxes and click on a button.
Here is the checkboxes:
<tr class="read" data-id="236'" data-url="TTNsN1UxWXh5LzYwUjZaSlR1Qk4xZz09" data-sort="1556928960">
<td class="inbox-small-cells">
<div id="mail_checkbox" name="mail_checkbox">
<input type="checkbox" id="mail_checkbox1" name="mail_checkbox1" class="mail-check" unchecked="">
</div>
</td>
<td class="inbox-small-cells"><i class="fa fa-star"></i></td>
<td class="view-message dont-show">
<div id="mail_check">Rob <myname#example.com></rob#example.com></div>
</td>
<td class="view-message">
<div id="mail_check">Hey!</div>
</td>
<td class="view-message inbox-small-cells">
<div id="mail_check"></div>
</td>
<td class="view-message text-right">
<div id="mail_check">04 May</div>
</td>
</tr>
<tr class="read" data-id="235'" data-url="U21hT0hpemZRUWlwUmN3amVjMUJzQT09" data-sort="1556479689">
<td class="inbox-small-cells">
<div id="mail_checkbox" name="mail_checkbox">
<input type="checkbox" id="mail_checkbox1" name="mail_checkbox1" class="mail-check" unchecked="">
</div>
</td>
<td class="inbox-small-cells"><i class="fa fa-star"></i></td>
<td class="view-message dont-show">
<div id="mail_check">Shibbir <name2#example.com></creativeartbd#gmail.com></div>
</td>
<td class="view-message">
<div id="mail_check">Image in body and attachement</div>
</td>
<td class="view-message inbox-small-cells">
<div id="mail_check"><i class="fa fa-paperclip"></i></div>
</td>
<td class="view-message text-right">
<div id="mail_check">28 Apr</div>
</td>
</tr>
<tr class="read" data-id="234'" data-url="NWpoUGcwK1lIb2tJQWlzR0grQVhEUT09" data-sort="1556479271">
<td class="inbox-small-cells">
<div id="mail_checkbox" name="mail_checkbox">
<input type="checkbox" id="mail_checkbox1" name="mail_checkbox1" class="mail-check" unchecked="">
</div>
</td>
<td class="inbox-small-cells"><i class="fa fa-star"></i></td>
<td class="view-message dont-show">
<div id="mail_check">Shibbir <name2#example.com></creativeartbd#gmail.com></div>
</td>
<td class="view-message">
<div id="mail_check">checking message body</div>
</td>
<td class="view-message inbox-small-cells">
<div id="mail_check"></div>
</td>
<td class="view-message text-right">
<div id="mail_check">28 Apr</div>
</td>
</tr>
I have tried this:
$(document).on('click','#Markasunread',function() {
alert("you are working on Markasunread now chris");
$("#mail_checkbox1").each(function() {
if ($(this).prop('checked') == true) {
$(".mail-check").prop("checked", false);
$("#select_all").prop("checked", false);
$(this).addClass("unread");
}
});
});
And I have also tried this:
$(document).on('click','#Markasunread',function() {
$("#mail_checkbox1").each(function() {
if ($(this).prop('checked') == true) {
$(".mail-check").prop("checked", false);
$("#select_all").prop("checked", false);
$(this).closest("tr").addClass("unread");
}
});
});
And this:
$(document).on('click','#Markasunread',function() {
$("#mail_checkbox1").each(function() {
if ($(this).prop('checked') == true) {
$(".mail-check").prop("checked", false);
$("#select_all").prop("checked", false);
$("#mail_checkbox1").closest("tr").addClass("unread");
}
});
});
What I am trying to achieve is when I select all the checkboxes and click on a button, I want to remove the class "read" and add the class "unread" in each row where the ticked checkboxes are.
Can you please show me an example how I could add the class for each row in the table where the ticked checkboxes are?
Thank you.

You arent allowed to use an ID more than once. So change the ID´s to a unique one.
Also try to use better JQuery Selectors. With "table input:checked" you´ll get all checked input fields inside your table. Now you can loop them to get the parent tr and add the unread class.
$('#actionButton').click(event => {
let inputs = $('table input:checked').toArray();
inputs.forEach(input => {
$(input).closest('tr').addClass('unread');
});
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<table>
<tbody>
<tr class="read" data-id="236'" data-url="TTNsN1UxWXh5LzYwUjZaSlR1Qk4xZz09" data-sort="1556928960">
<td class="inbox-small-cells">
<div id="1_1" name="mail_checkbox">
<input type="checkbox" id="mail_checkbox1" name="mail_checkbox1" class="mail-check" unchecked="">
</div>
</td>
<td class="inbox-small-cells"><i class="fa fa-star"></i></td>
<td class="view-message dont-show">
<div id="1_2">Rob
<myname#example.com>
</rob#example.com>
</div>
</td>
<td class="view-message">
<div id="1_3">Hey!</div>
</td>
<td class="view-message inbox-small-cells">
<div id="1_4"></div>
</td>
<td class="view-message text-right">
<div id="1_5">04 May</div>
</td>
</tr>
<tr class="read" data-id="235'" data-url="U21hT0hpemZRUWlwUmN3amVjMUJzQT09" data-sort="1556479689">
<td class="inbox-small-cells">
<div id="2_1" name="mail_checkbox">
<input type="checkbox" id="mail_checkbox2" name="mail_checkbox1" class="mail-check" unchecked="">
</div>
</td>
<td class="inbox-small-cells"><i class="fa fa-star"></i></td>
<td class="view-message dont-show">
<div id="2_2">Shibbir
<name2#example.com>
</creativeartbd#gmail.com>
</div>
</td>
<td class="view-message">
<div id="2_3">Image in body and attachement</div>
</td>
<td class="view-message inbox-small-cells">
<div id="2_4"><i class="fa fa-paperclip"></i></div>
</td>
<td class="view-message text-right">
<div id="2_5">28 Apr</div>
</td>
</tr>
<tr class="read" data-id="234'" data-url="NWpoUGcwK1lIb2tJQWlzR0grQVhEUT09" data-sort="1556479271">
<td class="inbox-small-cells">
<div id="3_1" name="mail_checkbox">
<input type="checkbox" id="mail_checkbox3" name="mail_checkbox1" class="mail-check" unchecked="">
</div>
</td>
<td class="inbox-small-cells"><i class="fa fa-star"></i></td>
<td class="view-message dont-show">
<div id="3_2">Shibbir
<name2#example.com>
</creativeartbd#gmail.com>
</div>
</td>
<td class="view-message">
<div id="3_3">checking message body</div>
</td>
<td class="view-message inbox-small-cells">
<div id="3_4"></div>
</td>
<td class="view-message text-right">
<div id="3_5">28 Apr</div>
</td>
</tr>
</tbody>
</table>
<input type="button" id="actionButton" value="Change">

Related

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>

MPDF Checkbox not showing in PDF only dot

Im using MPDF to output my html form into a PDF. But my problem is, when it converts to PDF the box shape of checkbox is gone, below is the sample how i coded the checkbox
<input type='checkbox' name='opening' value='referal' checked="checked"> Check 1
<input type='checkbox' name='opening' value='referal2' checked="checked"> Check 2
Here's the html output before converting:
Here's the html output before converting:
Here's the mpdf OUTPUT:
Here's the mpdf output:
As you can see, the check '✓' became dot '.' and the box shape is gone.
Is there something wrong with my code? Or It is just not possible with MPDF?
But let me add, if I'm using radio button, all is fine. But what I need is checkbox not radio button.
Radio Button OUTPUT:Radio Button
Heres my full code GeneratePDF.php
<?php
include('mpdf60/mpdf.php');
$html .=
"
<!DOCTYPE html>
<html>
<head>
<title>Applicant Information Sheet</title>
<link rel='stylesheet' href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css'>
<link rel='stylesheet' type='text/css' href='style.css'>
</head>
<body>
<div class=' header-logos text-center'>
<img src='headerimage/logo1.png' width='270' height='90' class=''>
<img src='headerimage/logo2.png' width='170' height='130' class='' >
<img src='headerimage/logo3.png' width='180' height='90' class=''>
</div>
<div class='container top-head'>
<p class='form-hrm'>FORM-HRM-R-003</p>
<hr>
<div class='col-lg-12 col-md-12 col-sm-12 col-xs-12'>
<div class='profile-pic'></div>
<p class='blackened-head'>APPLICANTS INFORMATION SHEET</p>
<form class='head-form'>
<span class='detail1'>Date</span><span class='user-texts'>:</span><span class='user-texts bold'> Nicky Jacobo</span><br>
<span class='detail2'>Position</span><span class='user-texts'>:</span> <span class='choice1 '>1st choice</span><span class='user-texts'>:</span> <span class='user-texts bold'>Information Technology</span><span class='choice2'> 2nd choice</span><span class='user-texts'>: </span><span class='user-texts bold'>Hotel Management</span><br>
<span class='detail3'>Salary Expectation</span><span class='user-texts'>:</span><span class='user-texts bold'>100,000</span><br>
<span class='detail4'>Availability to Start</span><span class='user-texts'>: </span><span class='user-texts bold'>Anytime</span><br>
</form>
<p class='blackened peros'>PERSONAL INFORMATION</p>
</div>
</div><!-- End of top-head -->
<!--==========================================
PERSONAL INFORMATION
============================================= -->
<div class='container personal-information'>
<table>
<tr class='zero-row'>
<th colspan='6' >NAME: <span class='outs'>
<span class='lastname ' style='font-weight: 900;'>JACOBO</span>
<span class='firstname' style='font-weight: 900;'>NICKY</span>
<span class='midname' style='font-weight: 800;'>CABALU</span>
</span><br>
<span class='lastnamedet'>(last name)</span>
<span class='firstnamedet'>(first name)</span>
<span class='midnamedet'>(middle name)</span>
</th>
</tr>
<tr class='first-row'>
<td>NICKNAME<br><span class='user-texts bold'>Nicks</span></td>
<td>BIRTHDATE (mm/dd/yyyy)<br><span class='user-texts bold'>10/25/1994</span></td>
<td>BIRTHPLACE<br><span class='user-texts bold'>Tokyo Japan</span></td>
<td>AGE<br><span class='user-texts bold'>18</span></td>
<td>HEIGHT<br><span class='user-texts bold'>5'7'</span></td>
<td>WEIGHT<br><span class='user-texts bold'>60kg</span></td>
</tr>
<tr class='second-row'>
<td colspan='6'>CITY ADDRESS: <span class='bold'>Plaridel Bulacan</span> </td>
</tr>
<tr class='third-row'>
<td colspan='6'>PROVINCIAL ADDRESS: <span class='bold'>Plaridel Bulacan</span> </td>
</tr>
<tr class='fourth-row'>
<td rowspan='2' ><span class='residentstatus'>RESIDENTIAL STATUS:</span>
<form>
<input type='checkbox' name='gender' value='own' checked='checked'> Own House<br>
<input type='checkbox' name='gender' value='rent'> Rent<br>
<input type='checkbox' name='gender' value='other' > Others (specify): <span class='bold'>Own Mansion</span>
</form>
</td>
<td rowspan='2'><span class='gender'>GENDER:</span>
<form>
<input type='checkbox' name='gender' value='male' checked='checked'> Male<br>
<input type='checkbox' name='gender' value='female' > Female<br>
</form>
</td>
<td colspan='2'>
MOBILE TEL. #: <span class='bold outs'>0926-107-4423</span><br><br>
RESIDENCE TEL. #: <span class='bold outs'>02-25429</span>
</td>
<td colspan='2' >EMAIL ADDRESS:<br><span class='bold outs'>yinkciworks#gmail.com</span></td>
</tr>
<tr class='fifth-row'>
<td colspan='4'>CIVIL STATUS:<br>
<input type='checkbox' name='civil-stat' value='single' checked='checked'> Single
<input type='checkbox' name='civil-stat' value='married' > Married
<input type='checkbox' name='civil-stat' value='single-parent' > Single Parent
<input type='checkbox' name='civil-stat' value='widow' > Widow
<input type='checkbox' name='civil-stat' value='other-status'> Others:
<span class='bold'>Complicated</span>
</td>
</tr>
<tr class='sixth-row'>
<td colspan='2' rowspan='2'>Nationality<br><br>
<input type='checkbox' name='filipino' value='filipino' checked='checked'> Filipino<br>
<input type='checkbox' name='othersnationalit' value='female' > Others (specify):
<span class='bold outs'>Alien Gender</span>
</td>
<td colspan='4'>SSS:
<span class='bold'>29-7098-7685-456</span>
       
TIN:
<span class='bold'>29-7098-7685-456</span>
</td>
</tr>
<tr class='seventh-row'>
<td colspan='4'>CURRENT ACTIVITIES:
<span class='bold'>Nandemonai</span>
</td>
</tr>
</table>
<!--==========================================
EMPLOYMENT HISTORY
============================================= -->
<p class='blackened'>EMPLOYMENT HISTORY</p>
<table class='table-two'>
<tr>
<th>COMPANY NAME</th>
<th>LAST POSITION</th>
<th>IMMEDIATE SUPERIOR</th>
<th>CONTACT NUMBER</th>
<th>INCLUSIVE DATES</th>
<th>REASON FOR LEAVING</th>
<th>SALARY</th>
</tr>
<tr class='table2-first-row'>
<td><span class='bold'>iConcept Global</span></td>
<td><span class='bold'>Web Developer</span></td>
<td><span class='bold'>Supervisor</span></td>
<td><span class='bold'>0926-107-4423</span></td>
<td><span class='bold'>Oct 25 1994</span></td>
<td><span class='bold'>Mayaman na</span></td>
<td><span class='bold'>100,000</span></td>
</tr>
<tr class='table2-first-row'>
<td><span class='bold'>iConcept Global</span></td>
<td><span class='bold'>Web Developer</span></td>
<td><span class='bold'>Supervisor</span></td>
<td><span class='bold'>0926-107-4423</span></td>
<td><span class='bold'>Oct 25 1994</span></td>
<td><span class='bold'>Mayaman na</span></td>
<td><span class='bold'>100,000</span></td>
</tr>
<tr class='table2-first-row'>
<td><span class='bold'>iConcept Global</span></td>
<td><span class='bold'>Web Developer</span></td>
<td><span class='bold'>Supervisor</span></td>
<td><span class='bold'>0926-107-4423</span></td>
<td><span class='bold'>Oct 25 1994</span></td>
<td><span class='bold'>Mayaman na</span></td>
<td><span class='bold'>100,000</span></td>
</tr>
<tr class='table2-first-row'>
<td><span class='bold'>iConcept Global</span></td>
<td><span class='bold'>Web Developer</span></td>
<td><span class='bold'>Supervisor</span></td>
<td><span class='bold'>0926-107-4423</span></td>
<td><span class='bold'>Oct 25 1994</span></td>
<td><span class='bold'>Mayaman na</span></td>
<td><span class='bold'>100,000</span></td>
</tr>
</table>
<!--==========================================
FAMILY BACKGROUND
============================================= -->
<p class='blackened'>FAMILY BACKGROUND</p>
<table class='table-three'>
<tr>
<th></th>
<th>NAME</th>
<th>AGE</th>
<th>OCCUPATION</th>
<th>COMPANY/SCHOOL</th>
</tr>
<tr>
<td>Father</td>
<td><span class='bold'>Nicky Jacobo</span></td>
<td><span class='bold'>18</span></td>
<td><span class='bold'>Web Developer</span></td>
<td><span class='bold'>Secret</span></td>
</tr>
<tr>
<td>Mother</td>
<td><span class='bold'>Nicky Jacobo</span></td>
<td><span class='bold'>18</span></td>
<td><span class='bold'>Web Developer</span></td>
<td><span class='bold'>Secret</span></td>
</tr>
<tr>
<td rowspan='4'>Brothers & Siters</td>
<td><span class='bold'>Nicky Jacobo</span></td>
<td><span class='bold'>18</span></td>
<td><span class='bold'>Web Developer</span></td>
<td><span class='bold'>Secret</span></td>
</tr>
<tr>
<td><span class='bold'>Nicky Jacobo</span></td>
<td><span class='bold'>18</span></td>
<td><span class='bold'>Web Developer</span></td>
<td><span class='bold'>Secret</span></td>
</tr>
<tr>
<td><span class='bold'>Nicky Jacobo</span></td>
<td><span class='bold'>18</span></td>
<td><span class='bold'>Web Developer</span></td>
<td><span class='bold'>Secret</span></td>
</tr>
<tr>
<td><span class='bold'>Nicky Jacobo</span></td>
<td><span class='bold'>18</span></td>
<td><span class='bold'>Web Developer</span></td>
<td><span class='bold'>Secret</span></td>
</tr>
<tr>
<td>Spouse</td>
<td><span class='bold'>Not available</span></td>
<td><span class='bold'>18</span></td>
<td><span class='bold'>Web Developer</span></td>
<td><span class='bold'>Secret</span></td>
</tr>
<tr>
<td>Children</td>
<td><span class='bold'>Not available</span></td>
<td><span class='bold'>18</span></td>
<td><span class='bold'>Web Developer</span></td>
<td><span class='bold'>Secret</span></td>
</tr>
</table>
<!--==========================================
REFERENCES
============================================= -->
<p class='blackened'>REFERENCES</p>
<table class='table-four'>
<tr>
<th>NAME</th>
<th>POSITION</th>
<th>COMPANY</th>
<th>ADDRESS</th>
<th>CONTACT NO.</th>
</tr>
<tr>
<td><span class='bold centerme'>Shana Hirai</span></td>
<td><span class='bold centerme'>Flame Haze</span></td>
<td><span class='bold centerme'>Shakugan no Shana</span></td>
<td><span class='bold centerme'>Anime</span></td>
<td><span class='bold centerme'>0926-107-4423</span></td>
</tr>
<tr>
<td rowspan='9' colspan='3' class='etu'>How did you know of the opening?<br>
<input type='checkbox' name='opening' value='news' checked> Newspaper Ad <br>
<input type='checkbox' name='opening' value='school'> School Placement <br>
<input type='checkbox' name='opening' value='walkin'> Walk-in<br>
<input type='checkbox' name='opening' value='referal' checked> Referral of: <span class='bold outs'>Friend</span> <br>
<input type='checkbox' name='opening' value='other-ads' checked> Others (specify): <span class='bold outs'>Facebook Ads</span><br><br>
</td>
<td rowspan='9' colspan='2'>
<span class='emergency italic'>In case of emergency please contact:</span><br>
Name: <span class='bold'> Sakai Yuji</span><br>
Contact No.: <span class='bold'>0926-107-4423</span><br>
Relation to you: <span class='bold'>Tomodachi</span><br><br>
</td>
</tr>
</table>
<p class='ihereby'>I hereby certify that the above information is true and correct and I hereby authorize Cabalen to verify the said information.</p>
<table class='last-part'>
<tr>
<th><span class=''>   signed already</span><br><br>
<span class='sign-details'> Applicant's Signature</span></th>
<th><span class=''>                          Oct 23 2017</span><br><br>
<span class='date-details'>                          Date</span></th>
</tr>
</table>
</div>
</body>
</html>
";
$mpdf=new mPDF('utf-8', 'Letter', 0, '', 2, 2, 12, 2, 2, 2);
$mpdf->WriteHTML($html);
$mpdf->SetDisplayMode('fullpage');
$mpdf->shrink_tables_to_fit = 1;
$mpdf->Output();
?>
The mPDF docs state that the first argument of Output() is the file path, second is the saving mode - you need to set it to 'F'.
$mpdf->Output('filename.pdf','F'); //Only save to File
Updated: You may need this too:
$mpdf->Output('filename.pdf','D');
I already found the cause, its the maxcdn bootstrap link, I only removed the link then everything went fine.

View SQL data by modal

Hello I'm not quite sure where i have gone wrong with this code i am very new to ajax and i have half an idea about php.
I have looked at other questions but everyones doing it in different ways then i am.
I am calling data via ajax to modal from SQL
index.php
<?php
$connect = mysqli_connect("localhost","root","","testing");
$query = "SELECT * FROM employee";
$result = mysqli_query($connect, $query);
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title> </title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
</head>
<body>
<div class="container" style="width:700px;">
<h3 align="center">Employee Onboarding</h3>
<br>
<div class="table-responsive">
<table class="table table-bordered">
<tr> <th width="70%">Employee Name</th> <th width="30%">View</th> </tr>
<?php
while($row = mysqli_fetch_array($result))
{
?>
<tr> <td> <?php echo $row['Name']; ?> </td> <td> <input type="button" name="view" value="view" id="<?php echo $row['EmployeeID']; ?>" class="btn btn-info btn-xs view_data"> </td> </tr>
<?php
}
?>
</table>
</div>
</div>
</body>
</html>
<!-- Modal -->
<div id="dataModal" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Employee Details</h4>
</div>
<div class="modal-body" id="employee_detail">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">close</button>
</div>
</div>
</div>
</div>
<!-- Modal -->
<script>
$(document).ready(function(){
$('.view_data').click(function(){
var employee_id = $(this).attr("EmployeeID");
$.ajax({
url:"modal.php",
method:"POST",
data:{employee_id:employee_id},
success:function(data){
$('#employee_detail').html(data);
$('#dataModal').modal("show");
}
});
});
});
</script>
modal.php
<?php
if(isset($_POST['employee_id']))
{
$output = '';
$connect = mysqli_connect("localhost","root","","testing");
$query = "SELECT * FROM employee WHERE EmployeeID = '".$_POST["employee_id"]."'";
$result = mysqli_query($connect, $query);
$output .= '
<div class="table-responsive">
<table class="table table-bordered">';
while($row = mysqli_fetch_array($result))
{
$output .= '
<tr> <td width="30%"> <label> Name </label> </td> <td width="70%"> '.$row['Name'].' </td> </tr>
<tr> <td width="30%"> <label> Adress </label> </td> <td width="70%"> '.$row['Address'].' </td> </tr>
<tr> <td width="30%"> <label> Gender </label> </td> <td width="70%"> '.$row['Gender'].' </td> </tr>
<tr> <td width="30%"> <label> Position </label> </td> <td width="70%"> '.$row['Position'].' </td> </tr>
<tr> <td width="30%"> <label> Age </label> </td> <td width="70%"> '.$row['Age'].' </td> </tr>
<tr> <td width="30%"> <label> Added Time </label> </td> <td width="70%"> '.$row['AddedTime'].' </td> </tr>
';
}
$output .= "</table></div>";
echo $output;
}
?>
Live/Testing Site
You should also post your ajax! You should append the result of your modal.php into the actual modal.
modal.php
$output .= '
<div class="table-responsive">
<table class="table table-bordered">';
while($row = mysqli_fetch_array($result))
{
$output .= '
<tr> <td width="30%"> <label> Name </label> </td> <td width="70%"> '.$row['Name'].' </td> </tr>
<tr> <td width="30%"> <label> Adress </label> </td> <td width="70%"> '.$row['Address'].' </td> </tr>
<tr> <td width="30%"> <label> Gender </label> </td> <td width="70%"> '.$row['Gender'].' </td> </tr>
<tr> <td width="30%"> <label> Position </label> </td> <td width="70%"> '.$row['Position'].' </td> </tr>
<tr> <td width="30%"> <label> Age </label> </td> <td width="70%"> '.$row['Age'].' </td> </tr>
<tr> <td width="30%"> <label> Added Time </label> </td> <td width="70%"> '.$row['AddedTime'].' </td> </tr>
';
}
$output .= "</table></div>";
echo $output;
}
In your ajax. Assuming you use jquery:
$.ajax({
type: 'POST',
url : 'modal.php',
cache: false,
success: function(data){
$('#target').html(data);
}
});
HTML
<div class="modal">
<div id="target"></div>
</div>

How to get a subtotal and total price ? Laravel foreach loop

I have this code right here:
#foreach($products as $p)
<tr>
<td class="col-md-6">
<div class="media">
<a class="thumbnail pull-left" href="#"> <img class="media-object" src="{{URL::to($p['image'])}}" style="width: 72px; height: 72px;"> </a>
<div class="media-body">
<span style="padding-left: 20px">Pavadinimas: </span><span class="text-warning"><strong>{{$p['title']}}</strong></span>
</div>
</div>
</td>
<td class="col-md-1" style="text-align: center">
<input type="number" class="form-control" id="quantity" value="{{$p['quantity']}}">
</td>
<td class="col-md-1 text-center">
<strong>{{$p['price']}} EUR</strong>
</td>
<td class="col-md-1 text-center">
<strong>{{$p['price']*$p['quantity']}} EUR</strong>
</td>
<td class="col-md-1">
<button type="button" class="btn btn-danger">
<span class="glyphicon glyphicon-remove"></span> Pašalinti
</button>
</td>
</tr>
#endforeach
the $products is in foreach loop and I don't know how to get the all price if there're two, three or more products because I don't know how to set variable outside foreach loop. Because if I add this code in foreach loop wich is not right now added in foreach loop:
<tr>
<td>   </td>
<td>   </td>
<td>   </td>
<td><h5>Subtotal</h5></td>
<td class="text-right"><h5><strong> EUR</strong></h5></td>
</tr>
<tr>
<td>   </td>
<td>   </td>
<td>   </td>
<td><h5>Another taxes</h5></td>
<td class="text-right"><h5><strong>1.44 EUR</strong></h5></td>
</tr>
<tr>
<td>   </td>
<td>   </td>
<td>   </td>
<td><h3>Total</h3></td>
<td class="text-right"><h3><strong> EUR</strong></h3></td>
</tr>
<tr>
<td>   </td>
<td>   </td>
<td>   </td>
<td>
<button type="button" class="btn btn-default">
<span class="glyphicon glyphicon-shopping-cart"></span> Žiūrėti kitas prekes
</button>
</td>
<td>
<button type="button" class="btn btn-success">Užsakyti
<span class="glyphicon glyphicon-play"></span>
</button>
</td>
</tr>
This code will just duplicate. So any suggestion how to get total price of all products in cart without adding this piece of code in foreach loop ?
If you are just trying the get the total of the $products collection, then try {{ $products->sum('amount'); }}
Alternatively, you could use JavaScript to dynamically update the total. If that value is then needed to be passed into a controller on form::submit, then you could store the value in a hidden input.

Why isn't this pregmatch not working?

I have this string and I am trying to find a match in which, a row has the port number, the field is always either an integer, or a link which contains the word port- in it. An advice of why my regex statement didn't work will be appreciated.
The php expression I am using is:
preg_match_all("/<td align=\"left\">\s*(<a href=\"http:\/\/www.proxynova.com\/proxy-server-list\/port-\d*|\d*)?\s*<\/td>/s", $input_lines, $output_array);
The Live Regex Site where I have my work:
http://www.phpliveregex.com/p/eX8
The String I am looking is as follows:
<table width="950" class="table" id="tbl_proxy_list">
<thead>
<tr>
<th>Proxy IP</th>
<th>Proxy Port</th>
<th>Last Check</th>
<th nowrap="nowrap"><span title="Proxy Speed in bytes per second">Proxy Speed</span></th>
<th>Uptime</th>
<th><span title="The location of that particular proxy.">Proxy Country</span></th>
<th>Anonymity </th>
</tr>
</thead>
<tbody>
<tr>
<td align="left">
<span class="row_proxy_ip">220.225.87.129</span>
</td>
<td align="left">
8080
</td>
<td align="left">
<time class="icon icon-check timeago" datetime="2016-03-14 12:58:53Z"></time>
</td>
<td align="left">
<div class="progress-bar" data-value="7.7100404" title="5855.0202"></div>
</td>
<td style="text-align:center !important;">
<span style="color:#009900;">59%</span>
</td>
<td align="left">
<img src="//www.proxynova.com/assets/images/blank.gif" class="flag flag-in" width="15" height="11" alt="IN" />
<a href="/proxy-server-list/country-in/">India
<span class="proxy-city"> - Chandannagar </span>
</a>
</td>
<td align="left">
<span class="proxy_transparent" style="font-weight:bold; font-size:10px;">Transparent</span>
</td>
</tr>
<tr>
<td align="left">
<span class="row_proxy_ip">220.225.87.129</span>
</td>
<td align="left">
8080
</td>
<td align="left">
<time class="icon icon-check timeago" datetime="2016-03-14 12:58:53Z"></time>
</td>
<td align="left">
<div class="progress-bar" data-value="7.7100404" title="5855.0202"></div>
</td>
<td style="text-align:center !important;">
<span style="color:#009900;">59%</span>
</td>
<td align="left">
<img src="//www.proxynova.com/assets/images/blank.gif" class="flag flag-in" width="15" height="11" alt="IN" />
<a href="/proxy-server-list/country-in/">India
<span class="proxy-city"> - Chandannagar </span>
</a>
</td>
<td align="left">
<span class="proxy_transparent" style="font-weight:bold; font-size:10px;">Transparent</span>
</td>
</tr>
<tr>
<td align="left">
<span class="row_proxy_ip">220.225.87.129</span>
</td>
<td align="left">
80
</td>
<td align="left">
<time class="icon icon-check timeago" datetime="2016-03-14 12:58:53Z"></time>
</td>
<td align="left">
<div class="progress-bar" data-value="7.7100404" title="5855.0202"></div>
</td>
<td style="text-align:center !important;">
<span style="color:#009900;">59%</span>
</td>
<td align="left">
<img src="//www.proxynova.com/assets/images/blank.gif" class="flag flag-in" width="15" height="11" alt="IN" />
<a href="/proxy-server-list/country-in/">India
<span class="proxy-city"> - Chandannagar </span>
</a>
</td>
<td align="left">
<span class="proxy_transparent" style="font-weight:bold; font-size:10px;">Transparent</span>
</td>
</tr>
</tbody>
</table>
Try this -
<td align=\"left\">\s*(<a href=\"http:\/\/www\.proxynova\.com\/proxy-server-list\/port-\d+|\d+).*?\s*<\/td>
Example here
So a couple of things you've missed -
* The \ delimiter at the end
* Ignoring the rest of the characters after the capturing group once your selection has been met.
Code sample -
preg_match_all(
"/<td align=\"left\">\s*(<a href=\"http:\/\/www.proxynova.com\/proxy-server-list\/port-\d+|\d+).*?\s*<\/td>/",
$str,
$output_array
);

Categories