How to fix the value from php to use bootstrap? - php

I am using bootstrap accordion style to show the list of speakers in our website.
For that, I have a list of speakers table in my database. And I am getting the fields using php. In the following way.
<?php
global $wpdb;
$result = $wpdb->get_results( "SELECT * FROM `Invited_Speakers`");
foreach ( $result as $print ) { ?>
<tr style="width:100%">
<div class="maindrop" style="float: left; text-align: justify;">
<a class="bar" style="text-decoration: none;" href="#<?php echo $print->Last_Name;?>"> <?php echo $print->First_Name; ?> <?php echo $print->Last_Name; ?>, <?php echo $print->Institue_Address; ?>
</a>
<div id="<?php echo $print->Last_Name;?>" class="dropbox">
<img style="border-radius: 10%; padding: 10px; float: left;" src="<?php echo $print->Image_link;?>" alt="" width="20%" align="left" />
<table style="width:79%;float: right;">
<tbody>
<td > <?php echo $print->Designation;?> </td>
</tr>
<tr>
<td ><?php echo $print->Department_Address;?></td>
</tr>
<tr>
<td> Email Id: <?php echo $print->Email_Id;?></td>
</tr>
</tbody>
</table>
<table>
<tbody>
<tr>
<td >Research Interests</td>
<td>:</td>
<td> <?php echo $print->Research_Interests;?> </td>
</tr>
<tr>
<td>
Achievements
</td>
<td> : </td>
<td><?php echo $print->Acheivements;?>
<button style="float:right;"><a style="color: white;" href="<?php echo $print->Home_page_Link;?>" target="_blank" rel="noopener"> More Info </a> </button>
</td>
</tr>
</tbody>
</table>
</div>
<?php }
?>
It has given me as expected, but the problem is,
when I click the bar, it should show me the dropbox which contains the details of the speaker. But it is not showing.
It seems like the link is not available.
How to rectify this??
I have around 60 speakers and for everybody, writing html code manually does not sound like good idea.
Link of the page is given here: Click here
In the above link, the problem is with the invited speakers list.
Thanks in advance
CSS:
.maindrop {
width: 100%;
}
.bar {
padding: 0px;
display: block;
border-bottom:1px solid #06394D;
text-decoration: none;
font-family: "Times New Roman", Times, serif;
font-size: 18px;
font-weight:300;
transition: .5s ease-out;
}
.bar:hover {
background: #F6F7F7;
padding: 15px;
text-decoration: none;
}
.dropbox {
max-height: 0;
transition: .2s ease-out;
overflow: hidden;
width: 100%;
}
.dropbox:target {
max-height: 5000px;
}

Assuming you're using Bootstrap 3, '.dropbox' does not exist as a class. What I believe you're looking for is an Accordion, which can be found under the Collapse documentation section.
Here is a little sample that should get you started in the right direction. The $count is there to make sure each row has a unique identifier to open it's associated accordion. I simplified the markup from which you have but you should be fine replacing with what you need.
<table style="width:100%">
<?php
$count = 0;
foreach($result as $print): ?>
<tr data-toggle="collapse" href="#collapseExample-<?php echo $count; ?>" aria-expanded="false" aria-controls="collapseExample-<?php echo $count; ?>">
<td>Speaker Name</td>
<td>Speaker Description</td>
</tr>
<tr class="collapse" id="collapseExample-<?php echo $count?>">
<td>This should be hidden</td>
</tr>
<?php $count++; endforeach; ?>
</table>

Related

Dynamically adding select2 to DOM which gets data from DB

I have a HTML table where user can choose products from MySql db.
I have a "add new row" possibility where new row is added to DOM.
Once I add new row, select-2 is no longer functioning in this new row - I beleive it is a problem, that it is searching for input only in first example of select-2 dropdown. How can I show dropdown for each instance?
Code:
<table id="add_new" style="width: 100%; margin-top:40px;" class="col-12 col-lg-12 col-md-12 col-sm-12 col-xl-12">
<thead>
<tr>
<th style="text-align:left; font-size: 10px; color:#8f8f8f; padding-bottom: 15px; width: 10%;">
Zap. št.: </th>
<th style="text-align:left; font-size: 10px; color:#8f8f8f; padding-bottom: 15px; width: 50%;">
Naziv artikla </th>
<th style="text-align:left; font-size: 10px; color:#8f8f8f; padding-bottom: 15px; width: 20%;">
Količina </th>
<th style="text-align:right; font-size: 10px; color:#8f8f8f; padding-bottom: 15px; width: 20%;">
EM (kos/m/colli,...) </th>
</tr>
</thead>
<tbody>
<tr id="mainsection">
<td> <p href="#" id="count" style="font-size: 13px; text-decoration: none; line-height: 1; color:#909090; margin-top:0px; margin-bottom:0;">
1</p> </td>
<td contenteditable style="padding-top:0px; padding-bottom:5px;">
<h4 style="font-size: 16px; line-height: 1; margin-bottom:0; color:#303030; font-weight:500; margin-top: 10px;">
<select class="form-control select2-multiple" id="dd_artikli" data-width="100%">
<option value="">Select country</option>
<?php
if (count($itemRecords_artikli) > 0) {
foreach ($itemRecords_artikli as $ct) {
?>
<option value="<?php echo $ct['id']; ?>">
<?php echo $ct['name']; ?>
</option>
<?php
}
}
?>
</select>
</h4>
</td>
<td contenteditable> <p href="#" style="font-size: 13px; text-decoration: none; line-height: 1; color:#909090; margin-top:0px; margin-bottom:0;"> </p> </td>
<td contenteditable style="padding-top:0px; padding-bottom:0; text-align: right;"> <p style="font-size: 13px; line-height: 1; color:#303030; margin-bottom:0; margin-top:0; vertical-align:top; white-space:nowrap;"> </p> </td>
</tr>
</tbody>
</table>
<script>
var number = 1;
document.getElementById("newsectionbtn").onclick = function() {
var container = document.getElementById("add_new");
var section = document.getElementById("mainsection");
var count = document.getElementById('count');
number++;
count.textContent = number.toString();
container.appendChild(section.cloneNode(true));
}
</script>
<
?php
/*
#Author: Sanjay Kumar
#Project: PHP MySQLi How To Use Select2 for Multiple Select Tutorial
#Email: onlinewebtutorhub#gmail.com
#Website: https://onlinewebtutorblog.com/
*/
// Include the database configuration file
require 'dbconfig.php';
$countrySelect = $conn->prepare("SELECT * FROM artikli");
$countrySelect->execute();
$countries = $countrySelect->get_result();
$itemRecords_artikli = array();
while ($item = $countries->fetch_assoc()) {
extract($item);
$itemDetails = array(
"id" => $id,
"name" => $naziv
);
array_push($itemRecords_artikli, $itemDetails);
}
?>
After drop-down bind run this command.
jQuery('#dd_artikli').select2();
Or use the jquery ready function.
$(document).ready(function() { jQuery('#dd_artikli').select2(); });

I added function to sort pics according to price they appeared in abnormal size

[enter image description here][1]
[1]: below is the code of sort by button i don't know why this happens while this is not the actually dimensions of the photos
https://i.stack.imgur.com/qxTt1.jpg
<center>
<table>
<?php
$opt=$_POST['sorting'];
if ($opt=="low") {
$qy="SELECT * FROM `men` order by `price` ASC";
$rt=mysqli_query($con,$qy);
while ($row1=mysqli_fetch_array($rt)) {
?>
<tr style="text-align: center; display: inline;">
<td style="border: thin solid lightgrey; width: 300px;
height: 200px;">
<pre>
<img src="<?php echo $row1['img']; ?>">
<b> <?php echo $row1['name']; ?> </b>
<span style="color: blue; font-weight: bold;">
<?php echo $row1['price']; ?>
</span>
</pre>
</td>
</tr>
<?php
}
}
else {
$qy="SELECT * FROM `men` order by `price` DESC";
$tt=mysqli_query($con,$qy);
while ($row1=mysqli_fetch_array($tt)) {
?>
<tr style="text-align: center; display: inline;">
<td style="border: thin solid lightgrey; width: 300px;
height: 300px;">
<pre>
<img src="<?php echo $row1 ['img']; ?>">
<b> <?php echo $row1['name']; ?></b>
<span style="color: blue; font-weight: bold;">
<?php echo $row1['price']; ?>
</span>
</pre>
</td>
</tr>
<?php
}
}
?>
</table>
</center>
<?php
}
?>

Two tables align in different ways with the same stylesheet

I have two tables. One is created with html (and a little bit of php) while the other is created by two php-loops.
First of all, the stylesheet:
.statistics {
font-family: Arial, monospace;
font-size: 36px;
margin-left: 5%;
width: 90%;
}
.statistics tr {
line-height: 50px;
}
.statistics th {
text-align: center;
}
.statistics td {
text-align: center;
}
button {
margin-left: 25%;
width: 50%;
height: 40px;
border: none;
border-radius: 20px;
font-family: Arial, monospace;
font-size: 20px;
}
The following table is aligned properly:
<table class="statistics">
<tr>
<th>Benutzer</th>
<th>Artikel</th>
<th>Reservierungen</th>
</tr>
<tr>
<td><?php echo $client->statistic_getAmount();?></td>
<td><?php echo $articles->statistic_getAmount();?></td>
<td><?php echo $reservations->statistic_getAmount();?></td>
</tr>
<tr>
<th>Seiten (.php)</th>
<th>Datenbankeinträge</th>
<th>Zeilen mit Code</th>
</tr>
<tr>
<td>18</td>
<td>27</td>
<td>4407+</td>
</tr>
</table>
While this one isn't aligned properly:
<form method="post" action="webinterface.php" class="perms">
<table class="statistics">
<tr>
<th>Benutzer</th>
<?php
foreach ($permgroupa as $group) {
echo "<th>".$group."<th>";
}
echo "</tr>";
$users = $client->getUsers();
while ($row = mysqli_fetch_assoc($users)) :?>
<tr>
<td><?php echo $row['username'];?></td>
<?php foreach ($permgroupa as $group) : ?>
<td><input type="checkbox" name="<?php echo $group;?>-<?php echo $row['username'];?>" <?php if ($perms->hasPermission($row['username'], $group)) {echo "checked";}?>></td>
<?php endforeach;?>
</tr>
<?php endwhile;?>
</table><button type="submit" class="btnalter" name="alterrights">Rechte aktualisieren</button></form>
The tables in action
Does someone know, why they align in different ways?
1 - don't put your table inside a form
2 - the number of columns is not the same for the first and the second table

dompdf page breakes not working

here is sample image
<!DOCTYPE html>
<html class="bg-black">
<head>
<meta charset="UTF-8">
<title><?php if(isset($title)) echo $title.' | '; ?> Sales agent management software (SAMS) </title>
<style>
body{
font-size: 9px;
margin: 20px;
}
th,td,p,div,table,h3{margin:0;padding:0}
#page { margin: 20px; }
.header{
border-bottom: 1px solid #dddddd;
text-align: center;
position: fixed; top: 0;
}
.footer { position: fixed; bottom: 0px; text-align: center }
.pagenum:before { content: counter(page); }
</style>
</head>
<body>
<div class="header">
<h2><?php echo get_option('company_name'); ?> Catalog</h2>
</div>
<br /><br />
<div class="footer">Page: <span class="pagenum"></span>, creation time : <?php echo date('l jS \of F Y h:i:s A') ?>, create by: <?php echo user_full_name(singleDbTableRow(loggedInUserData()['user_id'])); ?></div>
<br />
<div class="box-body">
<?php
$usd = get_option('lkr_per_usd', 134);
?>
<?php
$result = array_chunk($products->result_array(), 3);
foreach($result as $products){ ?>
<table style="width:100% style="page-break-after:always;" >
<tr>
<?php
foreach($products as $productArray){
$product = (object) $productArray;
echo '<td>';
?>
<div style="width: 100%; height: 210px; border: 1px solid #dddddd; margin: 10px; padding: 5px;">
<div class="box-header">
<p class="box-title"><FONT SIZE=12><?php echo $product->product_name; ?></FONT></p>
</div>
<div style="height: 80px; text-align: center;">
<?php echo '<img src="'.'uploads/'. $product->photo.'" class="img-responsive" style="height:80px !important; width: 150px !important" />'; ?>
</div>
<div style="clear: both"></div>
<table class="table table-responsive">
<tr>
<th><FONT SIZE=12>ID</FONT></th>
<td><FONT SIZE=14><?php echo $product->product_id; ?></FONT></td>
</tr>
<tr>
<th><FONT SIZE=12>LKR</FONT></th>
<td><FONT SIZE=14><?php $lkr = get_selling_price($product);
echo number_format(round($lkr, get_option('round_precision')) ); ?></FONT>
</td>
</tr>
<tr>
<th> <FONT SIZE=12>US $</FONT></th>
<td><FONT SIZE=14><?php echo number_format(round(lkr_to_usd($lkr), get_option('round_precision')) ); ?></FONT></td>
</tr>
</table>
</div>
</td>
<?php } ?>
</tr>
<?php } ?>
</table>
</div><!-- /.box-body -->
</body>
</body>
</html>
when i try to generate pdf it's always coming like this. i added my generate pdf code above .
2 nd page is not coming like 1st page.. i searched and found other dompdf solution for other peoples problem. but my problem is on 2nd page it's not coming as 1stpage.
There's some buggy behavior here on the part of dompdf. For some reason styling the DIV containing your product info with width: 100% is breaking the layout when the table row is paged. If you remove that styling from the DIV then the document should render as expected. The default DIV layout is full-width so you can leave the width styling on the DIV out

HTML, CSS & PHP cross browser styling

I'm a self taught coder and usually I can figure out problems for myself but this ones a stubborn one. I'm redesigning a website for my friend and I've successfully coded the mobile version of his site, but the desktop version is proving to be difficult.
The site is a database for a home bar, tracking; Drinkers, Shots, Units and Tabs. The index page is a leaderboard with Drinkers & Last Drink bought. My problem is positioning the Drinkers Ranks on the leaderboard to work across multiple web browsers.
It's meant to look like this: (screenshot)
http://giblets-grave.co.uk/previews/1400x900_GG-desktop_design_final.jpg
The alternating background is something I'm willing to scrap if it makes echoing results easier.
I've tried using tables, divs, ul/li's.. sample of what I used:
<table cellpadding="0" cellspacing="0">
<col width="85px" />
<col width="65px" />
<col width="65px" />
<tr>
<th colspan="3" align="left">Chris Clarkson</th>
</tr>
<tr>
<td>
<div class="crop round-five body-shadow" >
<img src="uploads/1.jpg" class="" />
</div>
</td>
<td>
<ul><h2>382.73</h2><li>units</li></ul><br />
</td>
<td>
<ul><h2>613</h2><li>shots</li></ul><br />
</td>
</tr>
</table>
but its just coming out as a big mess, can anyone help?
Definitely should be using table to do this in my opinion.
As for displaying the alternating colors, you would want to apply a background color to the tr's using nth-child() pseudo-class.
JSFIDDLE: http://jsfiddle.net/XYh7f/
HTML:
<div class="container">
<div class="leaderboard">
<table id="main">
<tr>
<td>Leaderboard</td>
</tr>
<tr>
<td>
<table class="client">
<tr>
<th colspan="3">Chris Clarkson</th>
</tr>
<tr>
<td>IMG</td>
<td>267.26 units</td>
<td>457 shots</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table class="client">
<tr>
<th colspan="3">Chris Clarkson</th>
</tr>
<tr>
<td>IMG</td>
<td>267.26 units</td>
<td>457 shots</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
<div class="drinks">
<table id="main-data">
<tr>
<td class="data-title"><h2>Last Drinks Served</h2></td>
</tr>
<tr>
<table class="data">
<tr>
<td class="data-time">Time</td>
<td class="data-shots">Shots</td>
<td class="data-drink">Drink</td>
<td class="data-drinker">Drinker</td>
<td class="data-date">Date</td>
</tr>
<tr>
<td class="data-time">Time</td>
<td class="data-shots">Shots</td>
<td class="data-drink">Drink</td>
<td class="data-drinker">Drinker</td>
<td class="data-date">Date</td>
</tr>
<tr>
<td class="data-time">Time</td>
<td class="data-shots">Shots</td>
<td class="data-drink">Drink</td>
<td class="data-drinker">Drinker</td>
<td class="data-date">Date</td>
</tr>
</table>
</tr>
</table>
</div>
</div><!-- END CONTAINER -->
CSS:
/* CONTAINER STYLES */
.container {
width: 960px;
}
.leaderboard {
float: left;
}
.drinks {
float: left;
}
/* LEADER BOARD STYLES */
table {
color: #eee;
width: 200px;
background: none;
}
tr { background: none; }
td { background: none; }
#main {
text-align: center;
}
#main tr:nth-child(odd) {
background: #444;
}
#main tr:nth-child(even) {
background: #555;
}
#main tr td .client tr {
background: none;
}
/* LAST DRINKS SERVED STYLES */
#main-data {
width: 740px;
}
#main-data tr:nth-child(odd) {
background: #444;
}
.data {
width: 740px;
}
.data tr:nth-child(odd) {
background: #222;
}
.data td {
border-right: 1px solid #000;
}
.data tr:nth-child(even) {
background: #333;
}
.data-title {
padding: 0 0 0 60px;
}
.data-time {
text-align: right;
width: 120px;
}
.data-shots {
text-align: right;
width: 60px;
}
.data-drink {
text-align: center;
width: 240px;
}
.data-drinker {
text-align: left;
width: 200px;
}
.data-date {
width: 140px;
}

Categories