<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>
Related
I am retrieving values from the database into the form for update, on the press of the submit button, the values should get updated.
Here's the code:
PostUpdate.php:
<?php
session_start();
$username=$_SESSION['uname'];
$cn=mysqli_connect("localhost", "root", "", "imedtalks");
// Define variables and initialize with empty values
$course = $category = "";
$title = $descp = "";
// Processing form data when form is submitted
if(isset($_POST["pid"]) && !empty($_POST["pid"])){
// Get hidden input value
$pid = $_POST["pid"];
// Check input errors before inserting in database
if(!empty($course) && !empty($category) && !empty($title) && !empty($descp)){
// Prepare an update statement
$sql = "UPDATE posts SET course=?, category=?, title=?, descp=? WHERE pid=?";
if($stmt = mysqli_prepare($cn, $sql)){
// Bind variables to the prepared statement as parameters
mysqli_stmt_bind_param($stmt, "ssssi", $param_course, $param_category, $param_title, $param_descp, $param_pid);
// Set parameters
$param_course = $course;
$param_category = $category;
$param_title = $title;
$param_descp = $descp;
$param_pid = $pid;
// Attempt to execute the prepared statement
if(mysqli_stmt_execute($stmt)){
// Records updated successfully. Redirect to landing page
header("location: BCAposts.php");
exit();
} else{
echo "Something went wrong. Please try again later.";
}
// Close statement
mysqli_stmt_close($stmt);
}
}
// Close connection
mysqli_close($cn);
} else{
// Check existence of id parameter before processing further
if(isset($_GET["pid"]) && !empty(trim($_GET["pid"]))){
// Get URL parameter
$pid = trim($_GET["pid"]);
//echo $pid;
// Prepare a select statement
$sql = "SELECT pid,course,category,title,descp FROM posts WHERE pid = ?";
if($stmt = mysqli_prepare($cn, $sql)){
// Bind variables to the prepared statement as parameters
mysqli_stmt_bind_param($stmt, "i", $param_pid);
// Set parameters
$param_pid = $pid;
//echo $param_pid;
// Attempt to execute the prepared statement
if(mysqli_stmt_execute($stmt)){
$result = mysqli_stmt_get_result($stmt);
if(mysqli_num_rows($result) == 1){
/* Fetch result row as an associative array. Since the result set contains only one row, we don't need to use while loop */
$row = mysqli_fetch_array($result, MYSQLI_ASSOC);
//echo '<pre>', var_dump($row) ,'</pre>';
// Retrieve individual field value
$pid = $row['pid'];
$course = $row['course'];
$category = $row['category'];
$title = $row['title'];
$descp = $row['descp'];
} else{
// URL doesn't contain valid id. Redirect to error page
header("location: BCAposts.php");
exit();
}
} else{
echo "Oops! Something went wrong. Please try again later.";
}
}
// Close statement
mysqli_stmt_close($stmt);
// Close connection
mysqli_close($cn);
} else{
// URL doesn't contain id parameter. Redirect to error page
header("location: BCAposts.php");
exit();
}
}
?>
<html>
<head>
<title>IMEDTalks-Post-
<?php echo $title;?>
</title>
<link href="./css/bootstrap.min.css" rel="stylesheet" />
<script src="./scripts/jquery-3.3.1.min.js"></script>
<script src="./scripts/bootstrap.min.js"></script>
<style>
/* Make the image fully responsive */
.carousel-inner img {
width: 100%;
height: 30%;
}
</style>
</head>
<body>
<div id="mycarousel" class="carousel slide" data-ride="carousel">
<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>
</ol>
<div class="carousel-inner">
<div class="carousel-item active">
<img src="./images/banner1.jpg" alt="First slide">
</div>
<div class="carousel-item">
<img src="http://placehold.it/1200x675&text=Second+slide" alt="Second slide">
</div>
<div class="carousel-item">
<img src="http://placehold.it/1200x675&text=Third+slide" alt="Third slide">
</div>
</div>
<a class="carousel-control-prev" href="#mycarousel" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#mycarousel" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
<nav class="navbar navbar-expand-sm navbar-light bg-light">
<a class="navbar-brand" href="UserHomePage.html"><img src="./images/brand.png" alt="logo" style="width:40px;"></a>
<button class="navbar-toggler d-lg-none" type="button" data-toggle="collapse" data-target="#collapsibleNavId" aria-controls="collapsibleNavId" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="collapsibleNavId">
<ul class="navbar-nav mr-auto mt-2 mt-lg-0">
<li class="nav-item active">
<a class="nav-link" href="UserHomePage.html">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Official Announcements</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="dropdownId" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Discussion Forum</a>
<div class="dropdown-menu" aria-labelledby="dropdownId">
<a class="dropdown-item" href="#">BCA</a>
<a class="dropdown-item" href="MCAposts.php">MCA</a>
</div>
</li>
<li class="nav-item">
<a class="nav-link" href="Post.php">Quick Post</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="dropdownId" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Fun Zone</a>
<div class="dropdown-menu" aria-labelledby="dropdownId">
<a class="dropdown-item" href="Articles.html">Articles</a>
<a class="dropdown-item" href="ChitChat.html">Chit Chat</a>
</div>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="dropdownId" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Resource Contents</a>
<div class="dropdown-menu" aria-labelledby="dropdownId">
<a class="dropdown-item" href="#">Course Syllabus</a>
<a class="dropdown-item" href="#">Study Materials</a>
<a class="dropdown-item" href="#">Previous Year Question Papers</a>
<a class="dropdown-item" href="#">Reference Books</a>
</div>
</li>
<li class="nav-item">
<a class="nav-link" href="FAQ.html">FAQ</a>
</li>
<li class="nav-item">
<a class="nav-link" href="AboutUs.html">About Us</a>
</li>
<li class="nav-item">
<a class="nav-link" href="ContactUs.html">Contact Us</a>
</li>
</ul>
<div>
<ul class="navbar-nav mr-auto mt-2 mt-lg-0">
<li class="nav-item dropdown btn-primary">
<a class="nav-link dropdown-toggle" href="#" id="dropdownId" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Welcome!
<?php echo $_SESSION['uname']; ?>
</a>
<div class="dropdown-menu" aria-labelledby="dropdownId">
<a class="dropdown-item" href="#">Profile</a>
<a class="dropdown-item" href="HomePage.php">Sign Out</a>
</div>
</li>
</ul>
</div>
</div>
</nav>
<br>
<div class="wrapper">
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<div class="page-header">
<h2 class="text-center">Update Post</h2>
</div>
<p class="text-center">Please edit the input values and submit to update the post.</p>
<form action="<?php echo htmlspecialchars(basename($_SERVER['REQUEST_URI'])); ?>" method="post">
<div class="form-group">
<div class="row">
<label class="col-form-label col-md-1 offset-3" for="course">Course:</label>
<div class="col-md-2">
<select name="course" class="form-control" required>
<option value="<?php echo $course;?>" selected>
<?php echo $course;?>
</option>
<option value="">Choose any:</option>
<option value="bca">BCA</option>
<option value="mca">MCA</option>
</select>
</div>
<label class="col-form-label col-md-1" for="category">Category:</label>
<div class="col-md-3">
<select name="category" class="form-control" required>
<option value="<?php echo $category;?>" selected>
<?php echo $category;?>
</option>
<option value="">Choose any:</option>
<option value="plang">Programming Language</option>
<option value="web">Web Technologies</option>
<option value="maths">Mathematics and Statistics</option>
<option value="db">Database</option>
<option value="ds">Data Structures</option>
<option value="os">Operating Systems</option>
<option value="mngmt">Management</option>
<option value="pro">Project</option>
<option value="skills">Soft Skills</option>
<option value="intern">Internships</option>
<option value="plcmnt">Placements</option>
<option value="others">Others</option>
</select>
</div>
</div>
</div>
<div class="form-group row">
<label for="title" class="col-form-label col-md-2">Title:
</label>
<div class="col-md-10">
<input type="text" class="form-control" value="<?php echo $title;?>" name="title" required>
</div>
</div>
<div class="form-group row">
<label for="desc" class="col-form-label col-md-12">Description:
</label>
<div class="col-md-12">
<textarea class="form-control" name="descp" rows="20" required><?php echo $descp;?></textarea>
</div>
</div>
<input type="hidden" name="pid" value="<?php echo $pid;?>" />
<div class="form-group row">
<div class="col-md-4 offset-4">
<a href="MCAposts.php"><button type="button" name="cancel"
class="btn-lg btn-danger">Cancel</button></a>
</div>
<div class="col-md-4">
<button type="submit" name="update" class="btn-lg btn-success">Submit</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</body>
</html>
Here, i am using pid which is being bought from the previous page where the data is listed in table format, and on the click of a button there, that data/post gets loaded into the form for editing and updating the same using the pid(primary key in my database table) Iam using bootstrap 4.
Problem i am facing:
The update operation is not performed.
No changes in the database table values.
No error shown.
I can't figure out whats going wrong here.
my file upload code
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Lumino - Dashboard</title>
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/font-awesome.min.css" rel="stylesheet">
<link href="css/datepicker3.css" rel="stylesheet">
<link href="css/styles.css" rel="stylesheet">
<link href="css/admin.css" rel="stylesheet">
<!--Custom Font-->
<link href="https://fonts.googleapis.com/css?family=Montserrat:300,300i,400,400i,500,500i,600,600i,700,700i" rel="stylesheet">
<!--[if lt IE 9]>
<script src="js/html5shiv.js"></script>
<script src="js/respond.min.js"></script>
<![endif]-->
<style>
.import {
right: -430px !important;
padding: 25px!important;
}
#media (max-width: 768px) {
.import {
right: 0px !important;
}
.navbar-fixed-bottom,
.navbar-fixed-top {
right: 86px!important;
left: 0;
z-index: 1030;
}
}
</style>
</head>
<body>
<?php include('dbc.php');?>
<nav class="navbar navbar-custom navbar-fixed-top" role="navigation">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#sidebar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#"> <span>Lumino</span>Admin</a>
<ul class="nav navbar-top-links navbar-right">
<li class="dropdown">
<a class="dropdown-toggle count-info" data-toggle="dropdown" href="#">
<em class="fa fa-envelope"></em>
</a>
<ul class="dropdown-menu dropdown-messages">
<li>
<div class="dropdown-messages-box">
<a href="profile.html" class="pull-left">
<img alt="image" class="img-circle" src="http://placehold.it/40/30a5ff/fff">
</a>
<div class="message-body">
<small class="pull-right">3 mins ago</small>
<strong>John Doe</strong> commented on <strong>your photo</strong>.
<br/>
<small class="text-muted">1:24 pm - 25/03/2015</small>
</div>
</div>
</li>
<li class="divider"></li>
<li>
<div class="dropdown-messages-box">
<a href="profile.html" class="pull-left">
<img alt="image" class="img-circle" src="http://placehold.it/40/30a5ff/fff">
</a>
<div class="message-body">
<small class="pull-right">1 hour ago</small>
New message from <strong>Jane Doe</strong>.
<br/>
<small class="text-muted">12:27 pm - 25/03/2015</small>
</div>
</div>
</li>
<li class="divider"></li>
<li>
<div class="all-button">
<em class="fa fa-inbox"></em> <strong>All Messages</strong>
</div>
</li>
</ul>
</li>
<li class="dropdown">
<a class="dropdown-toggle count-info" data-toggle="dropdown" href="#">
<em class="fa fa-bell"></em>
</a>
<ul class="dropdown-menu dropdown-alerts">
<li>
<a href="#">
<div><em class="fa fa-envelope"></em> 1 New Message
<span class="pull-right text-muted small">3 mins ago</span></div>
</a>
</li>
<li class="divider"></li>
<li>
<a href="#">
<div>
<em class="fa fa-heart"></em> 12 New Likes <span class="pull-right ext-muted small">4 mins ago</span>
</div>
</a>
</li>
<li class="divider"></li>
<li>
<a href="#">
<div>
<em class="fa fa-user"></em> 5 New Followers <span class="pull-right text-muted small">4 mins ago</span>
</div>
</a>
</li>
</ul>
</li>
</ul>
</div>
</div>
<!-- /.container-fluid -->
</nav>
<div id="sidebar-collapse" class="col-sm-3 col-lg-2 sidebar">
<div class="profile-sidebar">
<div class="profile-userpic">
<img src="http://placehold.it/50/30a5ff/fff" class="img-responsive" alt="">
</div>
<div class="profile-usertitle">
<div class="profile-usertitle-name">Username</div>
<div class="profile-usertitle-status"><span class="indicator label-success"></span>Online</div>
</div>
<div class="clear"></div>
</div>
<div class="divider"></div>
<form role="search">
<div class="form-group">
<input type="text" class="form-control" placeholder="Search">
</div>
</form>
<ul class="nav menu">
<li class="active"><em class="fa fa-dashboard"> </em> Dashboard</li>
<li><em class="fa fa-calendar"> </em> Widgets</li>
<li><em class="fa fa-bar-chart"> </em> Charts</li>
<li><em class="fa fa-toggle-off"> </em> UI Elements</li>
<li><em class="fa fa-clone"> </em> Alerts & Panels</li>
<li class="parent ">
<a data-toggle="collapse" href="#sub-item-1">
<em class="fa fa-navicon"> </em> Multilevel
<span data-toggle="collapse" href="#sub-item-1" class="icon pull-right"><em class="fa fa-plus"></em></span>
</a>
<ul class="children collapse" id="sub-item-1">
<li>
<a class="" href="#">
<span class="fa fa-arrow-right"> </span> Sub Item 1
</a>
</li>
<li>
<a class="" href="#">
<span class="fa fa-arrow-right"> </span> Sub Item 2
</a>
</li>
<li>
<a class="" href="#">
<span class="fa fa-arrow-right"> </span> Sub Item 3
</a>
</li>
</ul>
</li>
<li><em class="fa fa-power-off"> </em> Logout</li>
</ul>
</div>
<!--/.sidebar-->
<div class="col-sm-9 col-sm-offset-3 col-lg-10 col-lg-offset-2
main">
<div class="row">
<ol class="breadcrumb">
<li>
<a href="#">
<em class="fa fa-home"></em>
</a>
</li>
<li class="active">Dashboard</li>
</ol>
</div>
<!--/.row-->
</div>
<div class="container">
<form method="post" role="form" class="impfile">
<h1 class="text-center">IMPORT FILE</h1>
<p class="search_input col-sm-12 import">
<input type="file" placeholder="From Date" id="file" name="file" required class="input-control" />
<br>
<input type="submit" name="import" value="import" id="import" class="btn btn-primary pull-center">
</p>
</form>
</div>
<?php error_reporting(E_ALL & ~E_WARNING & ~E_NOTICE) ?>
<?php
if(isset($_POST["import"])) {
ini_set('max_execution_time', 120); //300 seconds = 5 minutes
//$filename = $_FILES['file']['name'];
$file = $_FILES['file']['tmp_name'];
//$ext=substr($file,strrpos($file,"."),(strlen($file)-
strrpos($file,".");
//if($ext=="csv")
$handle = fopen($file, "r");
//$c = 0;
while(($filesop = fgetcsv($handle,",")) !== false)
{
$category = mysqli_real_escape_string($conn,$filesop[0]);
$tags = mysqli_real_escape_string($conn,$filesop[1]);
$title = mysqli_real_escape_string($conn,$filesop[2]);
$url =mysqli_real_escape_string($conn,$filesop[3]);
$description = mysqli_real_escape_string($conn,$filesop[4]);
$date = mysqli_real_escape_string($conn,$filesop[5]);
//print_r($filesop[0]);
var_dump($filesop);
//echo $filesop[0];
$sql = "insert into report(category,tags,title,url,description,date) values ('$category','$tags','$title','$url','$description','$date')";
//$c = $c + 1;
$result=mysqli_query($conn,$sql)or die($sql."<br/><br/>".mysql_error());
//echo $sql;
//echo $filesop[1];
//echo "success";
exit();
}
//if($result){
//echo " upload success";
//ini_set('auto_detect_line_endings',FALSE);
fclose($handle);
// }
//else
// echo "cannot upload csv file";
}
mysqli_close($conn);
?>
<!--/.main-->
<script src="js/jquery-1.11.1.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/chart.min.js"></script>
<script src="js/chart-data.js"></script>
<script src="js/easypiechart.js"></script>
<script src="js/easypiechart-data.js"></script>
<script src="js/bootstrap-datepicker.js"></script>
<script src="js/custom.js"></script>
<script>
window.onload = function() {
var chart1 = document.getElementById("line-
chart ").getContext("
2 d ");
window.myLine = new Chart(chart1).Line(lineChartData, {
responsive: true,
scaleLineColor: "rgba(0,0,0,.2)",
scaleGridLineColor: "rgba(0,0,0,.05)",
scaleFontColor: "#c5c7cc"
});
};
</script>
</body>
</html>
Below is my csv file data.
Marketing & Customer Analytics,Trends & Product Updates,Segment Launches Segment Select,https://martechseries.com/analytics/customer-data-platforms/segment-launches-segment-select-new-program-help-companies-leverage-first-party-data-certified-partners/,"Segment, the customer data infrastructure company, launched Segment Select, a new program designed to help Channel and Technology Partners easily build and implement solutions for their customers that leverage Segment’s Customer Data Infrastructure (CDI).",2/24/2019
My database table screenshort
You have missed form attribute enctype.
You need to update in form attribute enctype in the form tag.
Your current syntax is:- <form method="post" role="form" class="impfile">
Need to update with :- <form method="post" role="form" class="impfile" enctype="multipart/form-data">
Please check below code:
<form method="post" role="form" class="impfile" enctype="multipart/form-data">
<h1 class="text-center">IMPORT FILE</h1>
<p class="search_input col-sm-12 import">
<input type="file" placeholder="From Date" id="file" name="file" required class="input-control" />
<br>
<input type="submit" name="import" value="import" id="import" class="btn btn-primary pull-center">
</p>
</form>
Updated
Update for If CSV file contains 2 or more rows. Please check below code
while (($row = fgetcsv($handle, ",")) !== false)
{
if (empty($fields)){
$fields = $row;
continue;
}
foreach ($row as $k=>$value)
{
$results[$col][$k] = $value;
}
$col++;
unset($row);
}
if (!feof($handle))
{
echo "Error: unexpected fgets() failn";
}
fclose($handle);
foreach ($results as $key => $value) {
$category = mysqli_real_escape_string($conn,$value[0]);
$tags = mysqli_real_escape_string($conn,$value[1]);
$title = mysqli_real_escape_string($conn,$value[2]);
$url =mysqli_real_escape_string($conn,$value[3]);
$description = mysqli_real_escape_string($conn,$value[4]);
$date = mysqli_real_escape_string($conn,$value[5]);
$sql = "insert into report(category,tags,title,url,description,date) values ('$category','$tags','$title','$url','$description','$date')";
$result=mysqli_query($conn,$sql)or die($sql."<br/><br/>".mysqli_error());
}
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
I don't understand why, the error says :
Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\twitter\core\ajax\popuptweets.php on line 134 , and I don't see any error or maybe I'm blind !!
popuptweets.php code
<?php
include '../init.php';
if (isset($_POST['showpopup']) && !empty($_POST['showpopup'])) {
$tweetID = $_POST['showpopup'];
$user_id = $_SESSION['user_id'];
$tweet = $getFromT->getPopupTweet($tweetID);
$user = $getFromU->userData($user_id);
$likes = $getFromT->likes($user_id, $tweetID);
$retweet = $getFromT->checkRetweet($tweetID, $user_id);
$comments = $getFromT->comments($tweetID);
?>
<div class="tweet-show-popup-wrap">
<input type="checkbox" id="tweet-show-popup-wrap">
<div class="wrap4">
<label for="tweet-show-popup-wrap">
<div class="tweet-show-popup-box-cut">
<i class="fa fa-times" aria-hidden="true"></i>
</div>
</label>
<div class="tweet-show-popup-box">
<div class="tweet-show-popup-inner">
<div class="tweet-show-popup-head">
<div class="tweet-show-popup-head-left">
<div class="tweet-show-popup-img">
<img src="<?php echo BASE_URL.$tweet->profileImage;?>"/>
</div>
<div class="tweet-show-popup-name">
<div class="t-s-p-n">
<a href="<?php echo BASE_URL.$tweet->username;?>">
<?php echo $tweet->screenName;?>
</a>
</div>
<div class="t-s-p-n-b">
<a href="<?php echo BASE_URL.$tweet->username;?>">
#<?php echo $tweet->username;?>
</a>
</div>
</div>
</div>
<div class="tweet-show-popup-head-right">
<button class="f-btn"><i class="fa fa-user-plus"></i> Follow </button>
</div>
</div>
<div class="tweet-show-popup-tweet-wrap">
<div class="tweet-show-popup-tweet">
<?php echo $getFromT->getTweetLinks($tweet->status);?>
</div>
<div class="tweet-show-popup-tweet-ifram">
<?php if(!empty($tweet->tweetImage)){?>
<img src="<?php echo BASE_URL.$tweet->tweetImage;?>"/>
<?php }?>
</div>
</div>
<div class="tweet-show-popup-footer-wrap">
<div class="tweet-show-popup-retweet-like">
<div class="tweet-show-popup-retweet-left">
<div class="tweet-retweet-count-wrap">
<div class="tweet-retweet-count-head">
RETWEET
</div>
<div class="tweet-retweet-count-body">
<?php echo $tweet->retweetCount;?>
</div>
</div>
<div class="tweet-like-count-wrap">
<div class="tweet-like-count-head">
LIKES
</div>
<div class="tweet-like-count-body">
<?php echo $tweet->likesCount;?>
</div>
</div>
</div>
<div class="tweet-show-popup-retweet-right">
</div>
</div>
<div class="tweet-show-popup-time">
<span><?php echo $tweet->postedOn;?></span>
</div>
<div class="tweet-show-popup-footer-menu">
<ul>
<?php if($getFromU->loggedIn() === true){
echo '<li><i class="fa fa-share" aria-hidden="true"></i></a></button></li>
<li>'.(($tweet->tweetID === $retweet['retweetID']) ? '<button class="retweeted" data-tweet="'.$tweet->tweetID.'" data-user="'.$tweet->tweetBy.'"><a href="#"><i class="fa fa-retweet" aria-hidden="true"></i><span class="retweetsCount">'.$tweet->retweetCount.'</span></button>' : '<button class="retweet" data-tweet="'.$tweet->tweetID.'" data-user="'.$tweet->tweetBy.'"><a href="#"><i class="fa fa-retweet" aria-hidden="true"></i><span class="retweetsCount">'.(($tweet->retweetCount > 0) ? $tweet->retweetCount : '').'</span></button>').'</li>
<li>'.(($likes['likeOn'] === $tweet->tweetID) ? '<button class="unlike-btn" data-tweet="'.$tweet->tweetID.'" data-user="'.$tweet->tweetBy.'"><i class="fa fa-heart-o" aria-hidden="true"></i><span class="likesCounter">'.$tweet->likesCount.'</span></button>' : '<button class="like-btn" data-tweet="'.$tweet->tweetID.'" data-user="'.$tweet->tweetBy.'"><i class="fa fa-heart" aria-hidden="true"></i><span class="likesCounter">'.(($tweet->likesCount > 0) ? $tweet->likesCount : '').'</span></button>').'</li>
<li>
<i class="fa fa-ellipsis-h" aria-hidden="true"></i>
<ul>
<li><label class="deleteTweet">Delete Tweet</label></li>
</ul>
</li>';
}else{
?>
<li><button type="buttton"><i class="fa fa-share" aria-hidden="true"></i></button></li>
<li><button type="button"><i class="fa fa-retweet" aria-hidden="true"></i><span class="retweetsCount">RETWEET-COUNT</span></button></li>
<li><button type="button"><i class="fa fa-heart" aria-hidden="true"></i><span class="likesCount">LIKES-COUNT</span></button></button></li>
<?php }?>
</ul>
</div>
</div>
</div><!--tweet-show-popup-inner end-->
<?php if($getFromU->loggedIn() === true){?>
<div class="tweet-show-popup-footer-input-wrap">
<div class="tweet-show-popup-footer-input-inner">
<div class="tweet-show-popup-footer-input-left">
<img src="<?php echo BASE_URL.$user->profileImage?>"/>
</div>
<div class="tweet-show-popup-footer-input-right">
<input id="commentField" type="text" name="comment" placeholder="Reply to #<?php echo $tweet->username;?>">
</div>
</div>
<div class="tweet-footer">
<div class="t-fo-left">
<ul>
<li>
<label for="t-show-file"><i class="fa fa-camera" aria-hidden="true"></i></label>
<input type="file" id="t-show-file">
</li>
<li class="error-li">
</li>
</ul>
</div>
<div class="t-fo-right">
<span id="count">140</span>
<input type="submit" id="postComment">
</div>
</div>
</div><!--tweet-show-popup-footer-input-wrap end-->
<?php }?>
<div class="tweet-show-popup-comment-wrap">
<div id="comments">
<?php
foreach ($comments as $comment) {
echo '<div class="tweet-show-popup-comment-box">
<div class="tweet-show-popup-comment-inner">
<div class="tweet-show-popup-comment-head">
<div class="tweet-show-popup-comment-head-left">
<div class="tweet-show-popup-comment-img">
<img src="'.BASE_URL.$comment->profileImage.'">
</div>
</div>
<div class="tweet-show-popup-comment-head-right">
<div class="tweet-show-popup-comment-name-box">
<div class="tweet-show-popup-comment-name-box-name">
'.$comment->screenName.'
</div>
<div class="tweet-show-popup-comment-name-box-tname">
#'.$comment->username.' - '.$comment->commentAt.'
</div>
</div>
<div class="tweet-show-popup-comment-right-tweet">
<p>#'.$tweet->username.' '.$comment->comment.'</p>
</div>
<div class="tweet-show-popup-footer-menu">
<ul>
<li><button><i class="fa fa-share" aria-hidden="true"></i></button></li>
<li><i class="fa fa-heart-o" aria-hidden="true"></i></li>
<li>
<i class="fa fa-ellipsis-h" aria-hidden="true"></i>
<ul>
<li><label class="deleteTweet">Delete Tweet</label></li>
</ul>
</li>
</ul>
</div>
</div>
</div>
</div>
<!--TWEET SHOW POPUP COMMENT inner END-->
</div>
';
}
?>
</div>
</div>
<!--tweet-show-popup-box ends-->
</div>
</div>
<?php
}
?>
and the error on foreach that's means on this code
foreach ($comments as $comment) {
echo '<div class="tweet-show-popup-comment-box">
<div class="tweet-show-popup-comment-inner">
<div class="tweet-show-popup-comment-head">
<div class="tweet-show-popup-comment-head-left">
<div class="tweet-show-popup-comment-img">
<img src="'.BASE_URL.$comment->profileImage.'">
</div>
</div>
<div class="tweet-show-popup-comment-head-right">
<div class="tweet-show-popup-comment-name-box">
<div class="tweet-show-popup-comment-name-box-name">
'.$comment->screenName.'
</div>
<div class="tweet-show-popup-comment-name-box-tname">
#'.$comment->username.' - '.$comment->commentAt.'
</div>
</div>
<div class="tweet-show-popup-comment-right-tweet">
<p>#'.$tweet->username.' '.$comment->comment.'</p>
</div>
<div class="tweet-show-popup-footer-menu">
<ul>
<li><button><i class="fa fa-share" aria-hidden="true"></i></button></li>
<li><i class="fa fa-heart-o" aria-hidden="true"></i></li>
<li>
<i class="fa fa-ellipsis-h" aria-hidden="true"></i>
<ul>
<li><label class="deleteTweet">Delete Tweet</label></li>
</ul>
</li>
</ul>
</div>
</div>
</div>
</div>
<!--TWEET SHOW POPUP COMMENT inner END-->
</div>
';
}
where is the error here ?
Arguments for foreach must be an array, you need to var_dump($comments) to see whether it's an array or not. In your case, returning result may be null so it returns warning for foreach. To ensure the foreach working, you may use this:
foreach ((array)$comments as $comment) {
}
I compared your code with mine and found a difference in this line: Do not worry, the error is there.
<li>
'.(($tweet->tweetID ===$retweet['retweetID']) ?
'<button class="retweeted" data-tweet="'.$tweet->tweetID.'" data-user="'.$tweet->tweetBy.'"><a href="#"><i class="fa fa-retweet" aria-hidden="true"></i><span class="retweetsCount">'.$tweet->retweetCount.'</span></button>'
:
'<button class="retweet" data-tweet="'.$tweet->tweetID.'" data-user="'.$tweet->tweetBy.'"><a href="#"><i class="fa fa-retweet" aria-hidden="true"></i><span class="retweetsCount">'.(($tweet->retweetCount > 0) ? $tweet->retweetCount : '') .'</span></button>' ).'<button class="retweet" data-tweet="'.$tweet->tweetID.'" data-user="'.$tweet->tweetBy.'"><a href="#"><i class="fa fa-retweet" aria-hidden="true"></i><span class="retweetsCount"></span></button>
</li>
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.