i install a school management system and one time login but after logout and enter username and password show a box with this message:
A Database Error Occurred , You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE _id IS NULL' at line 2 . SELECT * WHERE _id IS NULL . Filename: views/backend/header.php . Line Number: 34 "
header.php code :
<div class="row">
<div class="col-md-12 col-sm-12 clearfix" style="text-align:center;">
<h2 style="font-weight:200; margin:0px;"><?php echo $system_name;?></h2>
</div>
<!-- Raw Links -->
<div class="col-md-12 col-sm-12 clearfix ">
<ul class="list-inline links-list pull-left">
<!-- Language Selector -->
<div id="session_static">
<li>
<h4>
<a href="#" style="color: #696969;"
<?php if($account_type == 'admin'):?>
onclick="get_session_changer()"
<?php endif;?>>
<?php echo get_phrase('running_session');?> : <?php echo $running_year.' ';?><i class="entypo-down-dir"></i>
</a>
</h4>
</li>
</div>
</ul>
<ul class="list-inline links-list pull-right">
<li class="dropdown language-selector">
<a href="<?php echo site_url('home');?>" target="_blank">
<i class="entypo-globe"></i> Website
</a>
<a href="#" class="dropdown-toggle" data-toggle="dropdown" data-close-others="true">
<i class="entypo-user"></i>
<?php
$name = $this->db->get_where($this->session->userdata('login_type'), array($this->session->userdata('login_type').'_id' => $this->session->userdata('login_user_id')))->row()->name;
echo $name;
?>
</a>
<?php if ($account_type != 'parent'):?>
<ul class="dropdown-menu <?php if ($text_align == 'right-to-left') echo 'pull-right'; else echo 'pull-left';?>">
<li>
<a href="<?php echo site_url($account_type . '/manage_profile');?>">
<i class="entypo-info"></i>
<span><?php echo get_phrase('edit_profile');?></span>
</a>
</li>
<li>
<a href="<?php echo site_url($account_type . '/manage_profile');?>">
<i class="entypo-key"></i>
<span><?php echo get_phrase('change_password');?></span>
</a>
</li>
</ul>
<?php endif;?>
<?php if ($account_type == 'parent'):?>
<ul class="dropdown-menu <?php if ($text_align == 'right-to-left') echo 'pull-right'; else echo 'pull-left';?>">
<li>
<a href="<?php echo site_url('parents/manage_profile');?>">
<i class="entypo-info"></i>
<span><?php echo get_phrase('edit_profile');?></span>
</a>
</li>
<li>
<a href="<?php echo site_url('parents/manage_profile');?>">
<i class="entypo-key"></i>
<span><?php echo get_phrase('change_password');?></span>
</a>
</li>
</ul>
<?php endif;?>
</li>
<li>
<a href="<?php echo site_url('login/logout');?>">
<?php echo get_phrase('log_out'); ?><i class="entypo-logout right"></i>
</a>
</li>
</ul>
</div>
</div>
<hr style="margin-top:0px;" />
<script type="text/javascript">
function get_session_changer()
{
$.ajax({
url: '<?php echo site_url('admin/get_session_changer');?>',
success: function(response)
{
jQuery('#session_static').html(response);
}
});
}
</script>
line 34 :
$name = $this->db->get_where($this->session->userdata('login_type'), array($this->session->userdata('login_type').'_id' => $this->session->userdata('login_user_id')))->row()->name;
I am beginner . please help me step by step
Related
<div class="row">
<?php
$sql=mysqli_query($conn,"select * from is_ilanlari");
while($oku=mysqli_fetch_object($sql))
{
?>
<div class="col-md-4">
<aside class="profile-nav alt">
<section class="card">
<div class="card-header user-header alt bg-dark" >
<div class="media">
<a href="#">
<img class="align-self-center rounded-circle mr-3" style="width:100px; height:100px;" alt="" src="images/korucanta.jpg">
</a>
<div class="media-body">
<h2 class="text-light display-6" style="size:10px;"><?php echo $oku->is_ilanlari_baslik; ?></h2>
<p>Görev süresi : <?php echo $oku->is_ilanlari_bekleme_suresi; ?></p>
<div class="h4 mb-0" style="float:right;"></div>
</div>
</div>
</div>
<ul class="list-group list-group-flush">
<li class="list-group-item">
<a href="#"> <i class="fa fa-money"></i><b> Para kazancı </b>
<span class="badge badge-primary pull-right"> <?php echo $oku->is_ilanlari_kazanc; ?></span></a>
</li>
<li class="list-group-item">
<a href="#"> <i class="fa fa-plus-circle"></i><b> XP kazancı </b>
<span class="badge badge-danger pull-right"><?php echo $oku->is_ilanlari_bp; ?></span></a>
</li>
<li class="list-group-item">
<a href="#"> <i class="fa fa-clock-o"></i><b> Görev süresi</b>
<span class="badge badge-danger pull-right" style="background-color:#35dccd; height:28px; text-color:white;">
<p id="kutu1"><?php echo number_format($oku->is_ilanlari_bekleme_suresi); ?></p></span></a>
</li>
<li class="list-group-item">
<form method="POST" id="degerler">
<button type="button" name="buton<?php echo $oku->is_ilanlari_id; ?>" value="<?php echo $oku->is_ilanlari_id; ?>" class="btn btn-secondary btn-lg btn-block">KORUMAYA BAŞLA </button>
</form>
<script>
$(document).ready(function() {
$('button').on('click', function() {
$("button").attr("disabled", "disabled");
var is_id = $(this).val();
if(is_id!=""){
$.ajax({
url: "isbaslat.php",
type: "POST",
data: {
is_id: is_id
},
cache: false,
success: function(dataResult){
var dataResult = JSON.parse(dataResult);
if(dataResult.statusCode==1){
//$("button").removeAttr("disabled");
$('#degerler').find('input:text').val('');
$("#success").show();
$('#success').html('İş Başladı !');
console.log("b");
}
else if(dataResult.statusCode==0){
alert("Error occured !");
}
}
});
}
else{
alert('Please fill all the field !');
}
});
});
</script>
</li>
</ul>
</section>
</aside>
</div>
<?php
}
?>
</div>
this is form create php and ajax
can you see ?
<?php
session_start();
include('baglanti.php');
include('fonksiyonlar.php');
$kid=$_SESSION['kullanici_adi'];
getir_kullanici($kid);
$k_id=$getir['kid'];
$is_id=$_POST['is_id'];
$sql = "insert into kullanici_is(is_ilan_id,kullanici_id,is_baslangic_tarih,is_durum)
values ('$is_id','$k_id','".date("Y-m-d H:i:s")."',1)";
if (mysqli_query($conn, $sql)) {
echo json_encode(array("statusCode"=>1));
}
else {
echo json_encode(array("statusCode"=>0));
}
mysqli_close($conn);
?>
this is insert php you can see
http://prntscr.com/rhrmp5
ı want to insert a line.But this buttons all of them click and inserted 8 line in database.
How ı can insert just clicked value.
ı tryed all things pls help me
ı try again but no ı can t do it pls help me ı need more help . ı am waiting for
issue: code inside loop
Solution: move js code outside loop to avoid multiple instances,
use a class for all buttons
$('.btn_class').on('click', function() {
// now only the specific btn is clicked
$(this).val(); // will be of the clicked btn
...
}
add btn class
<form method="POST" id="degerler">
<button type="button" name="buton<?php echo $oku->is_ilanlari_id; ?>" value="<?php echo $oku->is_ilanlari_id; ?>" class="btn btn-secondary btn-lg btn-block btn_class">KORUMAYA BAŞLA </button>
</form>
fixed :
<div class="row">
<?php
$sql=mysqli_query($conn,"select * from is_ilanlari");
while($oku=mysqli_fetch_object($sql))
{
?>
<div class="col-md-4">
<aside class="profile-nav alt">
<section class="card">
<div class="card-header user-header alt bg-dark" >
<div class="media">
<a href="#">
<img class="align-self-center rounded-circle mr-3" style="width:100px; height:100px;" alt="" src="images/korucanta.jpg">
</a>
<div class="media-body">
<h2 class="text-light display-6" style="size:10px;"><?php echo $oku->is_ilanlari_baslik; ?></h2>
<p>Görev süresi : <?php echo $oku->is_ilanlari_bekleme_suresi; ?></p>
<div class="h4 mb-0" style="float:right;"></div>
</div>
</div>
</div>
<ul class="list-group list-group-flush">
<li class="list-group-item">
<a href="#"> <i class="fa fa-money"></i><b> Para kazancı </b>
<span class="badge badge-primary pull-right"> <?php echo $oku->is_ilanlari_kazanc; ?></span></a>
</li>
<li class="list-group-item">
<a href="#"> <i class="fa fa-plus-circle"></i><b> XP kazancı </b>
<span class="badge badge-danger pull-right"><?php echo $oku->is_ilanlari_bp; ?></span></a>
</li>
<li class="list-group-item">
<a href="#"> <i class="fa fa-clock-o"></i><b> Görev süresi</b>
<span class="badge badge-danger pull-right" style="background-color:#35dccd; height:28px; text-color:white;">
<p id="kutu1"><?php echo number_format($oku->is_ilanlari_bekleme_suresi); ?></p></span></a>
</li>
<li class="list-group-item">
<form method="POST" id="degerler">
<button type="button" name="buton<?php echo $oku->is_ilanlari_id; ?>" value="<?php echo $oku->is_ilanlari_id; ?>" class="btn btn-secondary btn-lg btn-block">KORUMAYA BAŞLA </button>
</form>
</li>
</ul>
</section>
</aside>
</div>
<?php
}
?>
</div>
// move script outside the loop
<script>
$(document).ready(function() {
$('button').on('click', function() {
$("button").attr("disabled", "disabled");
var is_id = $(this).val();
if(is_id!=""){
$.ajax({
url: "isbaslat.php",
type: "POST",
data: {
is_id: is_id
},
cache: false,
success: function(dataResult){
var dataResult = JSON.parse(dataResult);
if(dataResult.statusCode==1){
//$("button").removeAttr("disabled");
$('#degerler').find('input:text').val('');
$("#success").show();
$('#success').html('İş Başladı !');
console.log("b");
}
else if(dataResult.statusCode==0){
alert("Error occured !");
}
}
});
}
else{
alert('Please fill all the field !');
}
});
});
</script>
I have some navbar with menu and submenu, I want to appear some <div> in that menu to appear the submenu just if this menu has submenu items
The div that I want to appear are div1, div2, div3, see comments and in this condition : <?php if ($men["titre"] == $sub["parentmenu"]) : ?>
I can't put them in this foreach : <?php foreach($submenu as $sub) :?> because I need that three div just ones for all the submenu <li>
Exemple of one menu who have submenus:
<li class="Menu1">
<a class="header-menu " href="#">Menu1 title</a> //Menu1
<div class="mobile-header-nav-submenu-container"> //div 1
<ul class="mobile-header-nav-submenu"> //div 2
<div class="mobile-header-nav-submenu-li-container"> //div3
<li class="submenu1">
<a class="" href="#">Submenu1</a>
</li>
<li class="submenu2">
<a class="" href="#">Submenu2</a>
</li>
<li class="submenu3">
<a class="" href="#">Submenu3</a>
</li>
</div>
</ul>
</div>
</li>
My code:
<div class="menu>
<?php foreach ($menu as $men): ?>
<li class="<?php echo $men["titre"]?>">
<a class="header-menu <?php echo $men["lien"]?>" href="<?php if($men["lien"]){echo $baseUrl.$men["lien"];}else{echo '#';}?>"><?php echo $men["titre"]?></a>
<div class="mobile-header-nav-submenu-container"> //div1
<ul class="mobile-header-nav-submenu"> //div2
<div class="mobile-header-nav-submenu-li-container"> //div3
<?php foreach($submenu as $sub) :?>
<?php if ($men["titre"] == $sub["parentmenu"]) : ?>
<li id="<?php echo $sub["titre"]?>" class="mobile-header-nav-submenu-li">
<a class="" href="<?php if($sub["lien"]){echo $baseUrl.$sub["lien"];}else{echo '#';}?>">
<?php echo $sub["titre"]?>
</a>
</li>
<?php endif; ?>
<?php endforeach; ?>
</div>
</ul>
</div>
</li>
<?php endforeach; ?>
</div>
I am trying to modify an existing carousel by loading data from an SQL instead of hardcoding it. But, after fetching the data from SQL using PHP the controls of the carousel is not working.
When I checked the source, the contents of all slides are added correctly obtained from the database.
FYI - I also have another carousel on the same page which is working fine. So, I think all the requirements will be loaded correctly.
Below is my code:
<!-- Wrapper for Slides -->
<div class="carousel-inner">
<!-- Query from db -->
<?php
$sql='SELECT * FROM Books LIMIT 6';
$result = mysqli_query($con, $sql); ?>
<!-- start of while loop -->
<?php while($row = mysqli_fetch_array($result)) { ?>
<?php if ($row[bookID] == 1) echo '<div class="item active">';
else echo '<div class="item">'; ?>
<div class="fill" style="background-image: url('<?php echo $row[thumb]; ?>');">
<a href="books.php?page=<?php echo $row[bookID]; ?>" class="portfolio-box">
<img src="<?php echo $row[thumb]; ?>" class="img-responsive"
alt="<?php echo $row[name_small]; ?>">
<div class="portfolio-box-caption portfolio1">
<div class="portfolio-box-caption-content">
<div class="project-name">
<h4><strong><?php echo $row[name_small]; ?></strong>
<small><?php echo $row[second_title]; ?></small>
</h4>
<hr>
<p><?php echo $row[mini_desc]; ?></p>
<p><strong>First Published :</strong>
<?php echo $row[first_published]; ?></p>
</div>
</div>
</div>
</a>
</div><?php } ?>
<!-- end of while loop -->
</div>
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
<li data-target="#myCarousel" data-slide-to="1"></li>
<li data-target="#myCarousel" data-slide-to="2"></li>
<li data-target="#myCarousel" data-slide-to="3"></li>
<li data-target="#myCarousel" data-slide-to="4"></li>
<li data-target="#myCarousel" data-slide-to="5"></li>
</ol>
<!-- Controls -->
<a class="left carousel-control" href="#myCarousel" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
</a>
<a class="right carousel-control" href="#myCarousel" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
</a>
</div>
</section>
I tried comparing the code to my old carousel and everything looks the same. Can anyone tell me what I am doing wrong here?
Try this end of your loop:
</div><!--portfolio-box-caption-->
</a>
</div><!--fill-->
</div><!--item-->
<?php } ?><!-- end of while loop -->
Your condition
if($row[bookID] == 1)
It can or not have bookID equal to 1 in your database data !
To prevent it, use this
<?php $i = 1; while($row = mysqli_fetch_array($result)): ?>
<div class="item <?= ($i == 1) ? 'active' : '' ?>">
<div class="fill" style="background-image: url('<?php echo $row[thumb]; ?>');">
<a href="books.php?page=<?php echo $row[bookID]; ?>" class="portfolio-box">
<img src="<?php echo $row[thumb]; ?>" class="img-responsive"
alt="<?php echo $row[name_small]; ?>">
<div class="portfolio-box-caption portfolio1">
<div class="portfolio-box-caption-content">
<div class="project-name">
<h4><strong><?php echo $row[name_small]; ?></strong>
<small><?php echo $row[second_title]; ?></small>
</h4>
<hr>
<p><?php echo $row[mini_desc]; ?></p>
<p><strong>First Published :</strong>
<?php echo $row[first_published]; ?></p>
</div>
</div>
</div>
</a>
</div>
<?php endwhile; ?>
I have a "Latest Staff Members" panel where it should display my recently added users. All I have is a static display of these users:
<div class="box box-danger <?= !User::isBizAdmin() ? 'hidden' : '' ?>">
<div class="box-header with-border">
<h3 class="box-title">Latest Staff Members</h3>
<div class="box-tools pull-right">
<span class="label label-danger">8 New Members</span>
<button class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
<button class="btn btn-box-tool" data-widget="remove"><i class="fa fa-times"></i></button>
</div>
</div><!-- /.box-header -->
<div class="box-body no-padding">
<ul class="users-list clearfix">
<li>
<img src="https://cdn2.iconfinder.com/data/icons/avatar-2/512/frank_man-128.png" alt="User Image"/>
<a class="users-list-name" href="#">Alexander Pierce</a>
<span class="users-list-date">Today</span>
</li>
<li>
<img src="https://cdn2.iconfinder.com/data/icons/avatar-2/512/Ben_man-128.png" alt="User Image"/>
<a class="users-list-name" href="#">Norman</a>
<span class="users-list-date">Yesterday</span>
</li>
<li>
<img src="https://cdn2.iconfinder.com/data/icons/avatar-2/512/iri_girl_face-128.png" alt="User Image"/>
<a class="users-list-name" href="#">Jane</a>
<span class="users-list-date">12 Jan</span>
</li>
<li>
<img src="https://cdn2.iconfinder.com/data/icons/avatar-2/512/Jay_man-128.png" alt="User Image"/>
<a class="users-list-name" href="#">John</a>
<span class="users-list-date">12 Jan</span>
</li>
<li>
<img src="https://cdn2.iconfinder.com/data/icons/avatar-2/512/Fred_man-128.png" alt="User Image"/>
<a class="users-list-name" href="#">Alexander</a>
<span class="users-list-date">13 Jan</span>
</li>
<li>
<img src="https://cdn2.iconfinder.com/data/icons/avatar-2/512/michela_face_young-128.png" alt="User Image"/>
<a class="users-list-name" href="#">Sarah</a>
<span class="users-list-date">14 Jan</span>
</li>
<li>
<img src="https://cdn2.iconfinder.com/data/icons/avatar-2/512/carla_girl-128.png" alt="User Image"/>
<a class="users-list-name" href="#">Nora</a>
<span class="users-list-date">15 Jan</span>
</li>
<li>
<img src="https://cdn2.iconfinder.com/data/icons/avatar-2/512/hena_woman_face-128.png" alt="User Image"/>
<a class="users-list-name" href="#">Nadia</a>
<span class="users-list-date">15 Jan</span>
</li>
</ul><!-- /.users-list -->
</div><!-- /.box-body -->
<div class="box-footer text-center">
View All Users
</div><!-- /.box-footer -->
</div>
Something like that. Now, in the user table in my database, I added a date_added column and I manually put dates in row.
Do I loop the data? Or use a widget? I don't know how else I should implement this.
EDIT
My controller:
public function actionIndex()
{
if(Yii::$app->user->isGuest){
return $this->render('../site/index');
}
else{
$latestStaffMembers = User::find()->orderBy(['date_added' => SORT_DESC])->limit(8);
return $this->render('dashboard', [
'latestStaffMembers' => $latestStaffMembers,
]);
}
}
In my view:
<?php foreach ($latestStaffMembers as $user) { ?>
<li>
<img src="<?php echo $user->avatar; ?>" alt="User Image"/>
<?= $user->username ?>
<span ><?= $user->date_added ?></span>
</li>
<?php } ?>
Then I get this error:
Trying to get property of non-object
I tried var-dumping $user and it says null.
I'm not sure if this is what you want. I hope it helps somehow.
In your controller action:
$latestStaffMembers = User::find()->orderBy(['date_added' => SORT_DESC])->limit(8)->all();
return $this->render('some-view-file', [
'latestStaffMembers' => $latestStaffMembers,
]);
In your view:
<?php foreach ($latestStaffMembers as $user) { ?>
<li>
<img src="<?= $user->imagePath ?>" alt="User Image"/>
<a class="users-list-name" href="#"><?= $user->name ?></a>
<span class="users-list-date"><?= Yii::$app->formatter->asDate($user->dateAdded, 'd m'); ?></span>
</li>
<?php } ?>
Btw: I saw !User::isBizAdmin() in your code. Is it yours? I would not just hide the list if it is important that only admins may see that. Just don't print it if user is not admin.
I'm having a little problem with bootstrap 3. I tried for the whole day to solve and searched everything in internet even used FireBug but didn't help.
The button of dropdown is higher than the menu and its going outside the menu.
<ul class="nav navbar-nav navbar-right">
<?php if(!is_array(session( 'thisUser'))): ?>
<span class="glyphicon glyphicon-user"></span> <?php echo T('Register') ?>
<span class="glyphicon glyphicon-log-in"></span> <?php echo T('Login') ?>
<?php else: ?>
<li class="dropdown">
<a class="dropdown-toggle text-notransform" data-toggle="dropdown" href="#">
<img src="<?php echo URL(session_get('preferences', 'avatar')) ?>" width="24px">
<?php echo session_get('thisUser', 'username') ?> <span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li>
<div class="navbar-login">
<div class="row">
<div class="col-lg-4">
<p class="text-center">
<img src="<?php echo URL(session_get('preferences', 'avatar')) ?>" width="200px">
</p>
</div>
<div class="col-lg-8">
<p class="text-left"><strong><?php echo session_get('thisUser', 'username') ?></strong>
</p>
<p class="text-left small">
<?php echo session_get( 'thisUser', 'email') ?>
</p>
<br />
<p class="text-left">
<a href="<?php echo URL(T('setting-slug', 'settings')) ?>" class="btn btn-primary btn-block btn-sm">
<?php echo T( 'Settings') ?>
</a>
<?php echo event( 'user_menu', '') ?>
</p>
</div>
</div>
</div>
</li>
<li class="divider"></li>
<li>
<div class="navbar-login navbar-login-session">
<div class="row">
<div class="col-lg-12">
<p>
<a href="<?php echo URL('logout') ?>" class="btn btn-danger btn-block">
<?php echo T( 'Logout') ?>
</a>
</p>
</div>
</div>
</div>
</li>
</ul>
</li>
</ul>
<?php endif; ?>
</ul>
My second problem is with the bootstrap search I want the button search to be next to the search text not bellow it. The code is PHP function:
function search_box($a){
$return .= Form::open(array('method'=>'GET', 'action'=>URL(T('directory'))));
$return .= Form::input('q', R('q'), array('class'=>'form-control input-md', 'style'=>'margin-bottom:5px','placeholder'=>T('Type smth to search')));
$return .= '<button type="submit" class="btn btn-block btn-md btn-primary"><i class="icon-find"></i> '.T('Search').'</button>';
$return .= Form::close();
$return .= '<div class="clearfix"><br /></div>';
return $return;
}
(For image of the search is the same as the above link)
Can someone tell me how to fix this. Thanks in advance.
On your searchbox($a) function, try removing btn-md class from button.