needing some help reviewing some code a previous developer did. this code is on various sites and all seem to be working except for one. This company is expired and not showing up red when doing a search.
<?php
//$today = date ('Y-m-d');
//$expire_date = date ('Y-m-d', strtotime ( '-90 day' . $today));
if($result){
echo
'<table class="" style="margin:0 0 !important;">
<tr>
<th class="center hide" style="width:5px!important;">X2Pay</th>
<th class="header" > Company</th>
<th class="header"><a href="javascript:;" id="header_type">Type</th>
<th class="header"><a href="javascript:;" id="header_country">Country</th>
<th class="header"><a href="javascript:;" id="header_city">City</th>
<th class="header"><a href="javascript:;" id="header_quality">Quality<br />&Risk</th>
</tr>';
foreach ($result as $row) { //echo $row->x2paystatus.'<br />';
?>
<?php
//if($row->x2paystatus == 'Active (Y)'){
if($row->status == 'Active'){
//echo $row->x2paystatus;
$color = null;
}else{
$color = 'color:#dd2644;';
}
//echo $row->memberid;
?>
<tr style="<?php echo $color;?>" class="<?php echo $row->HQ_Br;?>">
<td class="center hide" style="vertical-align:middle;">
<?php if(trim($row->x2paystatus) == 'Active (Y)'){?>
<div style="border:0px solid red;">
<a href="http://x2payonline.com" target="_blank">
<img class="" style="width:25px;" src="<?php echo $wp_upload_dir.'/2015/10/x2pay.png';?>" alt="">
</a>
</div>
<?php } ?>
</td>
<td>
<a href="<?php echo site_url('member-area/view-company-profile?id='.$row->memberid);?>">
<?php echo $row->membername;?></a>
</td>
<td class="" ><?php echo $row->HQ_Br;?></td>
<td><?php echo $row->country;?></td>
<td><?php echo $row->city;?></td>
<td class="center hide">
<span class="tooltip tooltip-effect-5">
<a class="tooltiplink" href="<?php echo site_url('member-area/view-company-profile?id='.$row->memberid);?>"><span class="tooltip-item">View</span></a>
<span class="tooltip-content clearfix">
<span class="tooltip-text">
<p>Tier : <?php if($row->tierlevel){echo $row->tierlevel;}else{echo '-';}?></p>
<p>Risk level : <?php if($row->quality_risk_level){echo $row->quality_risk_level;}else{ echo '8'; }?></p>
<p class="img">
<?php
for($i=1;$i<=$row->quality_risk_startrating;$i++)
{
echo '<img style="width:16px!important;height:16px!important;margin:0;" src="'.$img_dir.'star-active.png" />';
}
?>
</p><br /><br />
<p>Since : <?php echo date('Y', strtotime($row->enrollment_date));?></p>
</span>
</span>
</span>
</td>
</tr>
<?php
}
echo '</table>';
}else{
//echo 'No result';
}
?>
Since it is rendering red on other sites that means this is clearly a css styling rule override which is preventing it from rendering red. I'd look into the style sheet for that site and see if background has tr css rule with the !important declaration. Many times when your dealing with tables people write css rules and accidentally override css on other tables unintentionally.
I would use F12 on table element and see what css rules are being applied to that element on the site in question.
Related
I want to hide image field when user not upload image.
<tr align="center">
<td><?php echo $result['id'] ?></td>
<td><?php echo $result['user_id']?></td>
<td><?php echo $result['username']?></td>
<td><?php echo $result['subject']?></td>
<td>
<?
if (file_exists(public_path("images/".$result['image'].""))){
unlink(public_path("images/".$result['image']."")); {?>
<a target="_blank" href="<?php echo "images/".$result['image']."" ?>">
<img src=<?php echo "images/".$result['image'].""?>
style="height: 150px; width: 150px" /></a>
<? } } else {
echo "Image not available";
}
?>
</td>
<td><?php echo $result['question']?></td>
<td><a href="#?id=<?=$result['id']?>">
<input type="Button" name="reply" value=Reply id="reply" onclick="togglePopup()" /></a></td>
</tr>
When I click on image it redirect me to my image directory.
When I click on image it open in new tab (if image is available) and if image is not available it not open.?
please anyone help me.
Use this code:
<?php if(file_exists("images/".$result['image'])){ ?>
<a target="_blank" href="<?php echo "images/".$result['image']."" ?>">
<img src=<?php echo "images/".$result['image']."" ?> style="height: 150px; width: 150px" />.
</a>
<?php } else {
//
} ?>
This code check image is available or no
First You have to check it there is a value in $result['image']
then check if the image exists in the server file_exists("images/".$result['image'])
<?php if(isset($result['image']) && file_exists("images/".$result['image'])){ ?>
<a target="_blank" href="<?php echo "images/".$result['image']."" ?>">
<img src=<?php echo "images/".$result['image']."" ?> style="height: 150px; width: 150px" />.
</a>
<?php } else {
//
} ?>
I am trying to align data list like this.
But I get output like this
I tried following code
$rawResult = unserialize($rawResult->sections);
$ans = array(0,1,2,3,4,5);
foreach ($rawResult as $questionKey => $questionArray) {
foreach ($questionArray['answers'] as $key => $value) {
if(in_array($value['given'][0], $ans)){
$answers[$key] = $value['given'][0];
}
}
foreach ($questionArray['questions'] as $id => $val) {
if (!preg_match("/How stressful has it been/i", $val['name'])) {
/*if($val['type'] == 'Single'){*/
$questions[$val['id']] = $val['name'];
}
}
}
ob_start();
global $csa_answers;
asort($answers);
$i=0;
$m=0;
$l=0;
$y=0;
global $pdf;
?>
<table class="progress-bar-container assessment-result" style="text-align:center;">
<tr>
<td><h3 style="font-weight: 700;font-size: 25px;line-height: 32px;color: #000;margin-bottom: 6px;font-family: 'Karla';">CSA Questions/Ratings</h3></td>
</tr>
<tr>
<td><span style="text-align: center;">Every CSA question and your response is listed below. Each question started out with the phrase,<br>
"How much have you been stressed by.....?"</span></td>
</tr>
</table>
<table class="table table-striped table-bordered" style="text-align:left;" width="620">
<tr>
<td><table width="310"><tr>
<td width="225" style="background-color: #EAE9E8;font-size:12px;">QUESTION</td>
<td width="80" style="background-color: #EAE9E8;font-size:12px;">RATING</td>
</tr>
<tr>
<?php foreach ($answers as $id => $ans) {
if(isset($questions[$id])){
$i++; ?>
<td style="<?php echo $c;?>"><span style="font-size:10px;"><?php echo str_replace('How much have you been stressed by ','',stripslashes($questions[$id]));?></span></td>
<td style="<?php echo $c;?>"><span style="font-size:10px;"><i><?php echo $csa_answers[$ans];?></i></span></td>
<?php
if ($l==0) {
$c= "background-color: #EAE9E8;";
$l++;
}
else{
$c="";
$l=0;
}
$i = 0;
$m++;
echo "</tr><tr >";
$y++;
if ($y==34) {
$l==0;
echo '<td></td><td></td></tr></table></td><td ><table width="310"><tr>
<td width="225" style="background-color: #EAE9E8;font-size:12px;">Question</td>
<td width="80" style="background-color: #EAE9E8;font-size:12px;">Rating</td>
</tr><tr>';
}
}
}
?>
<td></td><td></td></tr></table></td></tr><tr>
<?php echo '<td colspan="2" style="text-align:center;"><span class="score-desc" style="font-size:9px;">The choices for answering each question were:</span><br>
<span class="csmith-right-margin" style="font-size:9px;"> Not at all (Stress Free) </span>
<span class="csmith-right-margin" style="font-size:9px;"> A little bit </span>
<span class="csmith-right-margin" style="font-size:9px;"> Moderately </span>
<span class="csmith-right-margin" style="font-size:9px;"> Quite a bit </span>
<span class="csmith-right-margin" style="font-size:9px;"> Extremely </span>
<span class="csmith-right-margin" style="font-size:9px;"> Does not apply </span></td></tr>';
?>
</table>
<?php
$content = ob_get_clean();
return $content;
I tried many times to change the code but still get the wrong output. How can I fix this issue?
Table is not good for this, you can use:
1. <div style='display:inline-block'>Column 1</div> <div style='display:inline-block'>Column 2</div>
2. Use css flex box (prefer for responsive page reason).
3. Or if you familiar with table use <div style='display:table'></div> as css table not HTML table
I want to print binary tree (Below Image) in php from database value
And above is my database table structure
Here is what I tried, In this code I want to display binary tree of user id PX100
<?php
include 'db_connect.php';
$user_id = 'PX100';
$select_right_tree = $con->prepare("SELECT * FROM tbl_user_postion WHERE user_id=:user_id");
$select_right_tree->bindParam(":user_id", $user_id);
$select_right_tree->execute();
$fetch_right_tree = $select_right_tree->fetch(PDO::FETCH_ASSOC);
$ex_pos_right = $fetch_right_tree['pos_right'];
$ex_pos_left = $fetch_right_tree['pos_left'];
function right_part($pos_right) {
if(!empty($pos_right)) {
$select_left_tree = $con->prepare("SELECT pos_right, pos_left FROM tbl_user_postion WHERE user_id=:user_id");
$select_left_tree->bindParam(":user_id", $pos_right);
$select_left_tree->execute();
$fetch_left_tree = $select_left_tree->fetch(PDO::FETCH_ASSOC);
$user_right = $fetch_left_tree['pos_right'];
$user_left = $fetch_left_tree['pos_left'];
return array($user_right, $user_left);
if(!empty($user_right)) {
right_part($user_right);
}
if(!empty($user_left)) {
left_part($user_left);
}
}
}
function left_part($pos_left) {
if(!empty($pos_left)) {
$select_left_tree = $con->prepare("SELECT pos_right, pos_left FROM tbl_user_postion WHERE user_id=:user_id");
$select_left_tree->bindParam(":user_id", $pos_left);
$select_left_tree->execute();
$fetch_left_tree = $select_left_tree->fetch(PDO::FETCH_ASSOC);
$user_right = $fetch_left_tree['pos_right'];
$user_left = $fetch_left_tree['pos_left'];
return array($user_right, $user_left);
if(!empty($user_left)) {
left_part($user_left);
}
if(!empty($user_right)) {
right_part($user_right);
}
}
}
?>
<div class="tree">
<ul>
<li>
<img src="image/user.png" ><br/><?php echo $user_id; ?>
<ul>
<li>
<img src="image/user.png"><br/><?php echo $ex_pos_right; ?>
<?php
if(!empty($ex_pos_right))
{
list($pos_right1, $pos_left1) = right_part($ex_pos_right);
?>
<ul>
<li> <img src="image/user.png"><br/><?php echo $pos_right1; ?> </li>
<li> <img src="image/user.png"><br/><?php echo $pos_left1; ?> </li>
</ul>
<?php
}
?>
</li>
<li>
<img src="image/user.png"><br/><?php echo $ex_pos_left; ?>
<?php
if(!empty($ex_pos_left))
{
list($pos_right2, $pos_left2) = left_part($ex_pos_left);
?>
<ul>
<li> <img src="image/user.png"><br/><?php echo $pos_right2; ?> </li>
<li> <img src="image/user.png"><br/><?php echo $pos_left2; ?> </li>
</ul>
<?php
}
?>
</li>
</ul>
</li>
</ul>
</div>
Output of the above code is Here,
From database table, PX103 is a parent of PX108 and PX110, PX105 is parent of PX107 and PX111 , PX106 is parent of PX109. But PX108, PX110, PX107, PX111 and PX109 are not displaying in tree.
Please help me to sort out this problem.
Thankyou.
<table class="table table-bordered table-striped">
<tr>
<td width="950" >
<?php $m_id=NULL;$m_id=$_SESSION['id'];
$width=580;
for($lopp=0;$lopp<=3;$lopp++){
$tree=mysqli_query($sql,"select * from tree where distributer_id='".$m_id."'");
$m_id_fetch=mysqli_fetch_assoc($tree);
$left_m_id=$riggt_m_id="";
$tree_detaila=mysqli_query($sql,"select Name,yo_id from registration where yo_id='".$m_id."'");
if(!$tree_detaila) print mysqli_error($sql);
$detail=mysqli_fetch_assoc($tree_detaila);
if(!empty($m_id_fetch['pos_left'])) $left_m_id=$m_id_fetch['pos_left'];if(!empty($m_id_fetch['pos_right'])) $riggt_m_id=$m_id_fetch['pos_right'];
?> <table class="table-responsive" width="850" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td colspan="2" valign="top" align="center"> <table class="table-responsive" width="<?php print $width; ?>" border="0" align="<?php if(!empty($m_id_fetch['pos_left']) && $lopp>0) print "left"; elseif(!empty($m_id_fetch['pos_right']) && $lopp>0) print "right" ?> " cellpadding="0" cellspacing="0">
<?php if($lopp==0) { ?> <tr>
<td width="<?php print $width; ?>" align="center"> <img src="dashboard/images/user.jpg" width="45" height="50" class="img-circle" />
</td>
</tr>
<tr>
<td align="center"><?php print strtoupper($detail['Name']); ?></td>
</tr>
<tr>
<td align="center"><?php print $detail['yo_id']; ?></td>
</tr><?php } else { print ' <tr>
<td colspan="2" align="left"></td>
</tr>'; } ?>
<tr>
<td align="center">
<tr>
<td colspan="2" align="<?php if(!empty($m_id_fetch['pos_left']) && $lopp>0) print "left"; elseif(!empty($m_id_fetch['pos_right']) && $lopp>0) print "right" ?>"><img src="img/p.png" width="<?php print $width=$width-90; ?> " height="5" /></td>
</tr>
<?php
if($left_m_id!="" )
{
$tree_detaila_l=mysqli_query($sql,"select Name,yo_id from registration where yo_id='".$m_id_fetch['pos_left']."'");
$detail_l=mysqli_fetch_assoc($tree_detaila_l);
}
if($riggt_m_id!="")
{
$tree_detaila_r=mysqli_query($sql,"select Name,yo_id from registration where yo_id='".$m_id_fetch['pos_right']."'");
$detail_r=mysqli_fetch_assoc($tree_detaila_r);
}
?>
<tr>
<?php if($left_m_id!="" ){ ?> <td align="left">
<a href='#' class='tt'> <img src="dashboard/images/user.jpg" width="45" height="50" class="img-circle" /> </a></td><?php } ?>
<?php if($riggt_m_id!="" ){ ?> <td align="right">
<a href='#' class='tt'> <img src="dashboard/images/user.jpg" width="45" height="50" class="img-circle" /> </a></td><?php } ?>
</tr>
<tr>
<?php if($left_m_id!="") { ?><td align=" left"><?php print $detail_l['Name']; ?></td><?php } ?> <?php if($riggt_m_id!="") { ?><td align=" right"><?php print $detail_r['Name']; ?></td><?php } ?>
</tr>
<tr>
<?php if($left_m_id!="") { ?><td align=" left">
<?php print $detail_l['yo_id']; ?>
</td><?php } ?> <?php if($riggt_m_id!="") { ?><td align=" right">
<?php print $detail_r['yo_id']; ?>
</td><?php } ?>
</tr>
</table></td>
</tr>
</table><?php $width=$width-100;$m_id=$m_id_fetch['pos_right']; } ?>
</td>
</tr>
</table>`enter code here`
I am trying to make a user profile page system, but when I have a while, or foreach inside of a while, or foreach it doesn't execute any of the code inside, and after the loop.
foreach($db->query("SELECT * FROM `members` WHERE username = '$user'") as $row) {
echo "
<div class='page-header'>
<div class='row'>
<div class='span12'>
<div class='tabbable'>
<ul class='nav nav-tabs'>
<li class='active'>
<a data-toggle='tab' href='#about'>About $user</a>
</li>
<li>
<a data-toggle='tab' href='#infractions'>Infractions</a>
</li>
</ul>
<div class='tab-content' style='overflow: visible;'>
<div class='tab-pane active' id='about'>
<div class='row'>
<div class='span9'>
<div class='span4' style='float:left; width:25%'>
".$row['reputation']."
</div>
</div>
</div>
<div class='tab-pane' id='infractions'>
<div class='row'>
<div class='span12'>
<br>
<h3>Received Infractions</h3>
<table class='table table-bordered table-striped'>
<thead>
<tr>
<th width='13%'>Issuer</th>
<th width='13%'>Punished</th>
<th width='34%'>Reason</th>
<th width='7%'>Type</th>
<th width='7%'>Status</th>
<th width='9%'>Expires</th>
<th width='12%'>Date</th>
</tr>
</thead>
<tbody>
<tr class=''>";
//foreach($db->query("SELECT * FROM `infractions` WHERE reciver = '$user'") as $infraction) {
$stmt = $db->query("SELECT * FROM `infractions` WHERE reciver = '$user'");
while($infraction = $stmt->fetch(PDO::FETCH_ASSOC)) {
echo "<td><a href='/profiles/".$infraction['issuer']."' style='color: #F55'>".$infraction['issuer']."</a></td>
<td><a href='/profiles/".$infraction['reciver']."'>".$infraction['reciver']."</a></td>
<td>".$infraction['reason']."</td>
<td style='color:";
if($infraction['type']=="ban"){echo "red";}
elseif($infraction['type']=="tempban"){echo "orange";}
elseif($infraction['type']=="kick"){echo "yellow";}
elseif($infraction['type']=="mute"){echo "blue";}
echo "'>";
if($infraction['type']=="ban"){echo "Ban";}
elseif($infraction['type']=="tempban"){echo "Tempban";}
elseif($infraction['type']=="kick"){echo "Kick";}
elseif($infraction['type']=="mute"){echo "Mute";}
echo "</td><td><span style='color:";
if($infraction['appstatus']=="0"){echo "N/A";}
elseif($infraction['appstatus']=="1"){echo "black";}
elseif($infraction['appstatus']=="2"){echo "blue";}
elseif($infraction['appstatus']=="3"){echo "red";}
elseif($infraction['appstatus']=="4"){echo "green";}
echo "orange";
echo "'>";
if($infraction['appstatus']=="0"){echo "N/A";}
elseif($infraction['appstatus']=="1"){echo "Not Appealed";}
elseif($infraction['appstatus']=="2"){echo "Appeal Pending";}
elseif($infraction['appstatus']=="3"){echo "Appeal Rejected";}
elseif($infraction['appstatus']=="4"){echo "Appeal Accepted";}
echo"</span>
</td>
<td>
Never
</td>
<td data-container='body' data-placement='left' rel='tooltip' title='' data-original-title='January 4th, 2014 - 6:20 PM'>
<a href='/infractions/52c8a54fc8f2382195d7b3c4'>
17 minutes
ago
</a>";
}
echo "</td>
</tr>
</tbody>
</table>
</section>
</section>";
(ignore the unmatched {} errors, as I didn't spend a lot of time shortening it, also I can connect to the database, I just didn't include it.)
I don't get any errors, and everything before the second foreach works fine.
I have 2 tables named authors & books. Authors must have a logo. I have to display this like author name , logo,then all the books of that author and so on. books table contain a field (show_logo), if the show_logo is 0 for all the books of that author then the logo will display at the begining (ie after author name) else logo will display after that book(show_logo 1). If the show_logo is 1 for any book then it will display properly after that book, Otherwise won't..am using the code below
<?php
if ($author) {
foreach ($$author as $key => $val) {
?>
<tr style="background-color: #58353C;"><?php
if ($val['$author_image']) {
?>
<td><img src="<?= base_url(); ?>uploads/<?= $author; ?>" style="width: 90px;height: 90px;"/></td>
<td style="color: #F5E78F;" colspan="4"><b><?= $val['$author_name']; ?></td>
<?
foreach ($val['books'] as $key => $val1) {
?>
<tr style="background-color:<?= $color ?>">
<?php
if ($val1['author_image']) {
?>
<td style="padding-left: 20px;color: black; "><img src="<?= base_url(); ?>uploads/<?= $val1['author_image']; ?>" style="width: 75px;height: 75px;" /></td>
<?php } ?>
<td style="color: black;"><?= $val1['author_title']; ?></td>
<td width="150px" style="text-align: left;color: black;"><a class="more" style="color: black;font-size: 11px;" href="<?= site_url('author/author_view/' . $key); ?>" rel="facebox">More Details..</a></td>
<?
if ($val1['show_logo'] == '1') {
if ($val['author_logo']) {
?></tr>
<tr style="background-color:<?= $color; ?>" on>
<td colspan="5"><img src="<?= base_url(); ?>uploads/<?= $val['author_logo']; ?>" style="width: 998px;height: 175px;" /></td>
</tr>
<?
}
} else {
?></tr> <?
}
$counter++;
}
}
}
}
?>
why don't you use the HTML Table Library that CodeIgniter 2.x includes in default package? Just pre-format you arrays to reach proper structure.