Dynamic bootstrap tabs using php and mysql - php

I have Bootstrap modal tabs and it is works fine without data loop. I am trying to fill tabs using data from db(fetch), but it is not working when i am changing tabs, how can call my required tab data on press to my tab? I know that I have problem with looping or maybe "active"- class of tabs. Here is my code. What is wrong?
<div class="row">
<div class="col">
<div class="row">
<div class="col-sm-4">
<h4 class="mb-4">Ölkələr</h4>
</div>
</div>
<div class="row">
<?php
$conn = connect_to_bd();
mysqli_set_charset($conn,"utf8");
$selectolke = mysqli_query($conn, "Select t.ID as tid,t.text_az as textaz, c.textid as textid, c.olkeflag as olkeflag, c.id as cid, c.country_az as country_az from countries c, text t where t.id = c.textid");
while($selectolkerow = mysqli_fetch_array($selectolke))
{
$textid = $selectolkerow["textid"];
$country_az = $selectolkerow["country_az"];
$olkeflag = $selectolkerow["olkeflag"];
$olkeid = $selectolkerow["cid"];
?>
<div class="col-lg-4">
<div class="tabs tabs-vertical tabs-left tabs-navigation">
<ul class="nav nav-tabs col-sm-3">
<li class="nav-item active">
<a class="nav-link" href="#tabsNavigation<?php echo $textid; ?>" data-toggle="tab"><img src="lib/png/<?php echo $olkeflag; ?>.png"> <?php echo $country_az; ?></a>
</li>
</ul>
</div>
</div>
<div class="col-lg-8">
<div class="tab-pane tab-pane-navigation active" id="tabsNavigation<?php echo $textid; ?>">
<h4><?php echo header_subname_olke_select_az($olkeid); ?></h4>
<p class="notworkingcss" style="color: #fff;font-family:Verdana, sans-serifsans-serif;text-shadow: black 1px 1px 2px;font-size: 1.2em;">
<?php echo text_olke_select_az($textid, $olkeid); ?>
</p>
<div class="row portfolio-list lightbox m-0" data-plugin-options="{'delegate': 'a.lightbox-portfolio', 'type': 'image', 'gallery': {'enabled': true}}">
<div class="col-12 col-sm-6 col-lg-3">
<div class="portfolio-item">
<span class="thumb-info thumb-info-lighten thumb-info-centered-icons">
<span class="thumb-info-wrapper">
<img src="img/products/yerli/1.jpg" class="img-fluid" alt="Et mehsullari">
<span class="thumb-info-action">
<a href="img/products/yerli/1.jpg" class="lightbox-portfolio">
<span class="thumb-info-action-icon thumb-info-action-icon-light"><i class="fa fa-search-plus"></i></span>
</a>
</span>
</span>
</span>
</div>
</div>
<div class="col-12 col-sm-6 col-lg-3">
<div class="portfolio-item">
<span class="thumb-info thumb-info-lighten thumb-info-centered-icons">
<span class="thumb-info-wrapper">
<img src="img/products/yerli/2.jpg" class="img-fluid" alt="Et mehsullari">
<span class="thumb-info-action">
<a href="img/products/yerli/2.jpg" class="lightbox-portfolio">
<span class="thumb-info-action-icon thumb-info-action-icon-light"><i class="fa fa-search-plus"></i></span>
</a>
</span>
</span>
</span>
</div>
</div>
<div class="col-12 col-sm-6 col-lg-3">
<div class="portfolio-item">
<span class="thumb-info thumb-info-lighten thumb-info-centered-icons">
<span class="thumb-info-wrapper">
<img src="img/products/yerli/3.jpg" class="img-fluid" alt="Et mehsullari">
<span class="thumb-info-action">
<a href="img/products/yerli/3.jpg" class="lightbox-portfolio">
<span class="thumb-info-action-icon thumb-info-action-icon-light"><i class="fa fa-search-plus"></i></span>
</a>
</span>
</span>
</span>
</div>
</div>
</div>
</div>
</div>
<?php
}
?>
</div>
</div>
</div>

Related

How to access form element in while loop in PHP

i want to get acces to comment and get the value of it , i used $_POST but i get error
Undefined array key
the code create photo posts with while loop the post also contains the comment section.
here the Photo post code:
<!-- Photos section -->
<section>
<div class="container mt-5">
<div class="album py-5 bg-light">
<div class="row row-cols-1 row-cols-sm-1 row-cols-md-1 row-cols-lg-1">
<div class="container">
<?php
if (mysqli_num_rows($res_for_pics) > 0) {
while ($pics = mysqli_fetch_assoc($res_for_pics)) { ?>
<div class="col mb-3">
<div class="card shadow-sm">
<img src="images/user/<?= $pics['pic'] ?>" class="card-img-top img-fluid" alt="...">
<div class="card-body">
<h5 class="card-title" id="add-com"><?php echo $pics['pic_title'] ?></h5>
<p class="card-text"><?php echo $pics['pic_des'] ?></p>
<div class="d-flex justify-content-between align-items-center">
<small class="text-muted mb-3">by nithan</small>
</div>
<div class="accordion-item">
<h2 class="accordion-header" id="headingOne">
<button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
<h5 class="card-title"> Comments</h5>
</button>
</h2>
<div id="collapseOne" class="accordion-collapse collapse show" aria-labelledby="headingOne" data-bs-parent="#accordionExample">
<div class="accordion-body">
<ul class="list-group list-group-flush">
<li class="list-group-item">
howa
<p class="card-text"><small class="text-muted"></small></p>
</li>
</ul>
</div>
</div>
</div>
**I Want to get access to the value of textarea in the other php file**.
<form method="$_POST" action="../model/comment.php">
<div class="mb-3 mt-5">
<h5 for="message-text" class="col-form-label">add your comment</h5>
<textarea type="text" class="form-control" id="message-text" name="theComment"></textarea>
</div>
<button type="submit" class="btn btn-primary text-light" name="addComment">Comment</button>
</form>
</div>
</div>
</div>
<?php }
} ?>
</div>
</div>
</div>
</div>
</section>
and here comment.php
<?php
include('db_con.php');
$comment = $_POST["theComment"];
echo $comment;
So i try to get access to the 'theComment' value from the form .

Value are not storing in database

When i put the value from this page its not saving my value in database. The program stopped on this link www.mywebsite.com/index.php?admin/manage_language/update_phrase/english and show a blank page. whenever i run on my local machine its run successfully. update the record and come back to again on www.mywebsite.com/index.php?admin/manage_language/edit_phrase/english on this link. But on my cpanel its not working well.
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body">
<ul class="nav nav-tabs nav-bordered mb-3">
<?php if(isset($edit_profile)):?>
<li class="nav-item">
<a href="#edit" data-toggle="tab" aria-expanded="true" class="nav-link active">
<?php echo get_phrase('edit_phrase');?>
</a>
</li>
<?php endif;?>
<li class="nav-item">
<a href="#list" data-toggle="tab" aria-expanded="false" class="nav-link <?php if(!isset($edit_profile))echo 'active';?>">
<i class="mdi mdi-home-variant d-lg-none d-block mr-1"></i>
<span class="d-none d-lg-block"><?php echo get_phrase('language_list');?></span>
</a>
</li>
<li class="nav-item">
<a href="#add" data-toggle="tab" aria-expanded="true" class="nav-link">
<i class="mdi mdi-account-circle d-lg-none d-block mr-1"></i>
<span class="d-none d-lg-block"><?php echo get_phrase('add_phrase');?></span>
</a>
</li>
<li class="nav-item">
<a href="#add_lang" data-toggle="tab" aria-expanded="false" class="nav-link">
<i class="mdi mdi-settings-outline d-lg-none d-block mr-1"></i>
<span class="d-none d-lg-block"><?php echo get_phrase('add_language');?></span>
</a>
</li>
</ul>
<div class="tab-content">
<!----PHRASE EDITING TAB STARTS-->
<?php if (isset($edit_profile)):?>
<div class="tab-pane show active" id="edit" style="padding: 30px">
<div class="">
<div class="row">
<?php
$current_editing_language = $edit_profile;
echo form_open(base_url() . 'index.php?admin/manage_language/update_phrase/english' , array('id' => 'phrase_form'));
$count = 1;
$language_phrases = $this->db->query("SELECT `phrase_id` , `phrase` , `$current_editing_language` FROM `language`")->result_array();
foreach($language_phrases as $row)
{
$count++;
$phrase_id = $row['phrase_id']; //id number of phrase
$phrase = $row['phrase']; //basic phrase text
$phrase_language = $row[$current_editing_language]; //phrase of current editing language
?>
<!----phrase box starts-->
<div class="col-md-12">
<div class="tile-stats tile-gray">
<div class="icon"><i class="entypo-mail"></i></div>
<h5><?php echo $row['phrase'];?></h5>
<p>
<input type="text" name="phrase<?php echo $row['phrase_id'];?>"
value="<?php echo $phrase_language;?>" class="form-control"/>
</p>
</div>
</div>
<!----phrase box ends-->
<?php
}
?>
</div>
<input type="hidden" name="total_phrase" value="<?php echo $count;?>" />
<input type="submit" value="<?php echo get_phrase('update_phrase');?>" onClick="document.getElementById('phrase_form').submit();" class="btn btn-primary"/>
<?php
echo form_close();
?>
</div>
</div>
<?php endif;?>
<!----PHRASE EDITING TAB ENDS-->
<!----TABLE LISTING STARTS-->
<div class="tab-pane <?php if(!isset($edit_profile))echo 'show active';?>" id="list">
<div class="table-responsive-sm">
<table class="table table-bordered table-centered mb-0">
<thead>
<tr>
<th><?php echo get_phrase('language');?></th>
<th><?php echo get_phrase('option');?></th>
</tr>
</thead>
<tbody>
<?php
$fields = $this->db->list_fields('language');
foreach($fields as $field)
{
if($field == 'phrase_id' || $field == 'phrase')continue;
?>
<tr>
<td><?php echo ucwords($field);?></td>
<td>
<a href="<?php echo base_url();?>index.php?admin/manage_language/edit_phrase/<?php echo $field;?>"
class="btn btn-info">
<?php echo get_phrase('edit_phrase');?>
</a>
<a href="<?php echo base_url();?>index.php?admin/manage_language/delete_language/<?php echo $field;?>"
class="btn btn-danger">
<?php echo get_phrase('delete_language');?>
</a>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
</div>
<!----TABLE LISTING ENDS--->
<!----PHRASE CREATION FORM STARTS---->
<div class="tab-pane box" id="add" style="padding: 30px">
<div class="box-content">
<?php echo form_open(base_url() . 'index.php?admin/manage_language/add_phrase/' , array('class' => 'form-horizontal form-groups-bordered validate', 'style' => 'width:100%;'));?>
<div class="padded">
<div class="form-group justify-content-md-center">
<label class="col-3 control-label"><?php echo get_phrase('phrase');?></label>
<div class="col-5">
<input type="text" class="form-control" name="phrase" data-validate="required" data-message-required="<?php echo get_phrase('value_required');?>" placeholder="e.g. name, email"/>
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-3 col-sm-5">
<button type="submit" class="btn btn-info"><?php echo get_phrase('add_phrase');?></button>
</div>
</div>
<?php echo form_close();?>
</div>
</div>
<!----PHRASE CREATION FORM ENDS--->
<!----ADD NEW LANGUAGE---->
<div class="tab-pane box" id="add_lang" style="padding: 30px">
<div class="box-content">
<?php echo form_open(base_url() . 'index.php?admin/manage_language/add_language/' , array('class' => 'form-horizontal form-groups-bordered validate', 'style' => 'width:100%;'));?>
<div class="padded">
<div class="form-group">
<label class="col-sm-3 control-label"><?php echo get_phrase('language');?></label>
<div class="col-sm-5">
<input type="text" class="form-control" name="language" data-validate="required" data-message-required="<?php echo get_phrase('value_required');?>" placeholder="e.g. Spanish, Portugese"/>
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-3 col-sm-5">
<button type="submit" class="btn btn-info"><?php echo get_phrase('add_language');?></button>
</div>
</div>
<?php echo form_close();?>
</div>
</div>
<!----LANGUAGE ADDING FORM ENDS-->
</div>
</div>
</div>
</div>

Align items in 3's in PHP using HTML

Good Day All,
I am trying to align items in a row of 3. At the top of each row there is a div called "". The purpose of this div is to open a new and after every 3 items the div must be close and another one opened. I have tried the below code to my suprise it is not working. This is very weird as the MOD operand should work. Cna any of you see what I could be doing wrong?
The write picture should look like this
It is out of alignment and the blue colour fills the whole page. I do not know what I am doing wrong:
$currentRow = 1;
echo '<div class="top-box">';
while($Data=mysqli_fetch_array($Result))
{
echo '<div class="col_1_of_3 span_1_of_3">
<a href="Single.php?Query='.$Data[5].'">
<div class="inner_content clearfix">
<div class="product_image">
<img src="images/'.$Data[14].'" height="300" width="320" alt=""/>
</div>
<div class="price">
<div class="cart-left">
<p class="title">'.$Data[11].'</p>
<div class="price1">
<span class="actual">R'.$Data[13].'</span>
</div>
</div>
<div class="cart-right"> </div>
<div class="clear"></div>
</div>
</div>
</a>
</div>';
$currentRow++;
if($currentRow % 3 == 0)
{
echo '</div> ';
echo '<div class="top-box">';
}
}
When I manually repeat the items every 3 items like below, it works perfectly:
<div class="top-box">
<div class="col_1_of_3 span_1_of_3">
<a href="Single.php">
<div class="inner_content clearfix">
<div class="product_image">
<img src="images/1st_Party_Boy.jpg" height="300" width="320" alt=""/>
</div>
<div class="price">
<div class="cart-left">
<p class="title">His First Party</p>
<div class="price1">
<span class="actual">R350.00</span>
</div>
</div>
<div class="cart-right"> </div>
<div class="clear"></div>
</div>
</div>
</a>
</div>
<div class="col_1_of_3 span_1_of_3">
<a href="Single.php">
<div class="inner_content clearfix">
<div class="product_image">
<img src="images/Her_First_Party.jpg" height="300" width="320" alt=""/>
</div>
<div class="sale-box"><span class="on_sale title_shop">New</span></div>
<div class="price">
<div class="cart-left">
<p class="title">Her First of Many </p>
<div class="price1">
<span class="actual">R350.00</span>
</div>
</div>
<div class="cart-right"> </div>
<div class="clear"></div>
</div>
</div>
</a>
</div>
<div class="col_1_of_3 span_1_of_3">
<a href="Single.php">
<div class="inner_content clearfix">
<div class="product_image">
<img src="images/First_one_for_boys_and_girls.jpg" height="300" width="320" alt=""/>
</div>
<div class="price">
<div class="cart-left">
<p class="title">Their First Birthday</p>
<div class="price1">
<span class="actual">R350.00</span>
</div>
</div>
<div class="cart-right"> </div>
<div class="clear"></div>
</div>
</div>
</a>
</div>
<div class="clear"></div>
</div>
Hey change $currentRow to zero
$currentRow = 0;
echo '<div class="top-box">';
while($Data=mysqli_fetch_array($Result))
{
echo '<div class="col_1_of_3 span_1_of_3">
<a href="Single.php?Query='.$Data[5].'">
<div class="inner_content clearfix">
<div class="product_image">
<img src="images/'.$Data[14].'" height="300" width="320" alt=""/>
</div>
<div class="price">
<div class="cart-left">
<p class="title">'.$Data[11].'</p>
<div class="price1">
<span class="actual">R'.$Data[13].'</span>
</div>
</div>
<div class="cart-right"> </div>
<div class="clear"></div>
</div>
</div>
</a>
</div>';
$currentRow++;
if($currentRow % 3 == 0)
{
echo '</div> ';
echo '<div class="top-box">';
}
}

How to Exclude a selected and highlighted post from displaying among rest of the posts

I have custom post type of doctors. When the name is clicked it will take to the single page of the doctor. Below there is a small div which displays a number of posts. I dont want the post which is already displayed at the top to be at the bottom.
this is the code i have done:
<?php foreach($dr as $doc){ ?>
<div class="col-md-4">
<img src="<?php echo get_the_post_thumbnail_url($doc->ID);?>" class="img-reposive img-circle dc-img mb50" alt="" />
</div>
<div class="col-md-8">
<div class="dr-single-box">
<h3 class="dr-single-tile"><?php echo $doc->post_title; ?></h3>
<div class="sub-tile"><?php echo get_post_meta($doc->ID,'Department',true); ?></div>
<div class="dc-single-social">
<p><?php echo $doc->post_content; ?></p>
make an appointment
<div class="row">
<div class="col-md-4">
<h3 class="mb10">Qualifications</h3>
<p><?php echo get_post_meta($doc->ID,'Qualifications',true); ?></p>
</div>
the bottom portion looks like this :
<?php $arg=array('post_type'=>'doctors','post_status'=>'publish','posts_per_page'=>4,'offset'=>1) ;
$doctor_data=get_posts($arg);
/*var_dump($doctor_data);*/ ?>
<div class="lightbg ptb80">
<div class="container">
<div class="row">
<div class="col-lg-12 col-md-12">
<h1 class="heading-title">Doctors</h1>
</div>
</div>
<div class="row">
<?php foreach($doctor_data as $doctor) { ?>
<div class="col-lg-3 col-md-3">
<div class="dc-style-box">
<img src="<?php echo get_the_post_thumbnail_url($doctor->ID); ?>" class="img-responsive" alt="Doctor 1" />
<div class="dc-style-inner">
<ul>
<li><i class="fa fa-facebook"></i></li>
<li><i class="fa fa-twitter"></i></li>
<li><i class="fa fa-google-plus"></i></li>
</ul>
<h5><?php echo $doctor->post_title; ?></h5>
<span><?php echo get_post_meta($doctor->ID,'Department',true);?></span>
</div>
</div>
</div>
can anyone shed some light to guide me ? ?
<?php
$cur = get_the_ID();
$arg=array('post_type'=>'doctors','post_status'=>'publish','posts_per_page'=>4,'offset'=>1, 'post__not_in' => $cur) ;
$doctor_data=get_posts($arg);
/*var_dump($doctor_data);*/ ?>
<div class="lightbg ptb80">
<div class="container">
<div class="row">
<div class="col-lg-12 col-md-12">
<h1 class="heading-title">Doctors</h1>
</div>
</div>
<div class="row">
<?php foreach($doctor_data as $doctor) { ?>
<div class="col-lg-3 col-md-3">
<div class="dc-style-box">
<img src="<?php echo get_the_post_thumbnail_url($doctor->ID); ?>" class="img-responsive" alt="Doctor 1" />
<div class="dc-style-inner">
<ul>
<li><i class="fa fa-facebook"></i></li>
<li><i class="fa fa-twitter"></i></li>
<li><i class="fa fa-google-plus"></i></li>
</ul>
<h5><?php echo $doctor->post_title; ?></h5>
<span><?php echo get_post_meta($doctor->ID,'Department',true);?></span>
</div>
</div>
</div>
Hi, You should add 'post__not_in' to exclude current post to be fetched in second loop. Try this code. Let me know if you need any more assistance.
Thanks.
According to your comment you wish to display random posts therefore use below $arg instead of yours.
$arg = array('post_type'=>'doctors',
'post_status'=>'publish',
'posts_per_page'=>4,
'offset'=>1,
'orderby' => 'rand'
);

Zend - dynamic pages

I have a video as background so I want only the content of the page to load since everything else is the same. I tried using Ajax, but I couldn't get it to work. Is there a way to achieve that ?
Layout code:
/...
<body>
<video autoplay loop poster="/img/bg-still.png" preload="auto" id="bg">
<source src="/img/bg.webm" type="video/webm">
</video>
<div id="wrapper">
<header>
<div class="top_line">
<div class="container">
<div class="row">
<?php
if ($user = $this->identity()) {
?>
<div class="col-lg-6 pull-left">
<p>
<span class="welcome-show">Здравей, <?php echo $this->EscapeHtml($user->nick) ?></span>
<span class="rank">Ранк:
<?php
switch ($user->role) {
case 1:
?> <span class="rank-vip">VIP</span> <?php
break;
case 2:
?> <span class="rank-vipplus">VIP+</span> <?php
break;
default:
?> <span class="rank-none">Никакъв</span> <?php
break;
}
?>
</span>
<span class="credits-show">Кредити: <?php echo $this->EscapeHtml($user->credits) ?></span>
<img src="/img/ui-icon-credits" class="ui-icon-credits"/>Заредете кредити
<a href="/edit" class="register"><span
class="icon icon-settings ui-icon ui-icon-gear"></span>Настройки</a>
<a href="/logout" class="register"><span
class="icon icon-logout ui-icon ui-icon-close"></span>Излез</a>
</p>
</div>
<?php
} else {
?>
<div class="col-lg-6 pull-left">
<p>
<span class="icon icon-login ui-icon ui-icon-key"></span>Влез
<a href="/register" class="register"><span
class="icon icon-register ui-icon ui-icon-person"></span>Регистрирай се</a>
</p>
</div>
<?php
}
?>
</div>
</div>
</div>
</header>
<div class="page_head">
<div class="nav-container" style="height: auto;">
<nav>
<div class="container">
<div class="row">
<div class="col-lg-3 pull-left">
<a href="/">
<div class="logo"></div>
</a>
<div class="beta">BETA</div>
</div>
<div class="col-lg-9 pull-right">
<div class="menu">
<div id="dl-menu" class="dl-menuwrapper">
<button class="dl-trigger">Open Menu</button>
<?php
echo $this->navigation('navigation')->menu();
?>
</div>
</div>
</div>
</div>
</div>
</nav>
</div>
</div>
<div class="content" id="content">
<?php echo $this->content; ?>
</div>
<div class="footer">
/...

Categories