Show all rows on PHP/sql - php

I'm doing a small app. The thing is that when I'm running it, it will only show 300 rows when I should have around 2000 that I inserted for the test. It just doesn't shows them. It shows 312 rows, and not the rest.
Here is the code:
<!-- page content -->
<div class="right_col" role="main">
<div class="page-title">
<div class="title_left">
<h3>Raw Inventory</h3>
</div>
<div class="title_right">
<div class="col-md-5 col-sm-5 col-xs-12 form-group pull-right top_search">
<div class="input-group">
<input type="text" class="form-control" placeholder="Search for...">
<span class="input-group-btn">
<button class="btn btn-default" type="button">Go!</button>
</span>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12 col-sm-12 col-xs-12">
<div class="x_panel">
<div class="x_title">
<h2>Assets List</h2>
<ul class="nav navbar-right panel_toolbox">
<li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
</li>
<li><a class="close-link"><i class="fa fa-close"></i></a>
</li>
</ul>
<div class="clearfix"></div>
</div>
<div class="x_content">
<div class="wrapper">
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<div class="page-header clearfix">
<h2 class="pull-left"></h2>
Add a new Asset
</div>
<?php
// Include config file
require_once 'config.php';
// Attempt select query execution
$sql = "SELECT * FROM t_assets";
if($result = mysqli_query($db, $sql)){
if(mysqli_num_rows($result) > 0){
echo "<table class='table table-bordered table-striped'>";
echo "<thead>";
echo "<tr>";
echo "<th>Asset</th>";
echo "<th>Model</th>";
echo "<th>Status</th>";
echo "<th>Location</th>";
echo "<th>Action</th>";
echo "</tr>";
echo "</thead>";
echo "<tbody>";
while($row = mysqli_fetch_array($result)){
echo "<tr>";
echo "<td>" . ucfirst ($row['a_asset']) . "</td>";
echo "<td>" . $row['a_model'] . "</td>";
echo "<td>" . ucfirst($row['a_status']) . "</td>";
echo "<td>" . ucfirst($row['a_location']) . "</td>";
echo "<td>";
echo "<a href='read.php?id=". $row['a_asset'] ."' title='View Record' data-toggle='tooltip'><span class='glyphicon glyphicon-eye-open'></span></a>  ";
echo "<a href='update.php?id=". $row['a_asset'] ."' title='Update Record' data-toggle='tooltip'><span class='glyphicon glyphicon-pencil'></span></a>  ";
echo "<a href='delete.php?id=". $row['a_asset'] ."' title='Delete Record' data-toggle='tooltip'><span class='glyphicon glyphicon-trash'></span></a>";
echo "</td>";
echo "</tr>";
}
echo "</tbody>";
echo "</table>";
// Free result set
mysqli_free_result($result);
} else{
echo "<p class='lead'><em>No records were found.</em></p>";
}
} else{
echo "ERROR: Could not able to execute $sql. " . mysqli_error($db);
}
// Close connection
mysqli_close($db);
?>
</div>
</div>
</div>
</div>
</body>
</html> </div>
</div>
</div>
</div>
</div>
</div>
Any idea what I can do about this?
This is really my only problem, and I just need to add more text right now.
Or well, if you guys want to give me tips to make a global search function that would also be nice. Like, being able to search for information on all columns. Though I'm quite sure that It's not that hard.
I wonder... I need to investigate how to sort the results by name or creation date too.
Thanks, everyone!

Related

Bootstrap card element stretching

So the problem is that the cards are really stretching and I have tried everything to fix it and still haven't achieved the fix. Any way to fix this since I'm out of the clues? And what is the problem and where?
My container that holds cards
<div class="container mt-5">
<div class="row align-items-center">
<div class="col-sm-12 mx-auto">
<div class="card-group">
<?php
$companies = new Companies();
$companies->showAllCompanies();
?>
</div>
</div>
</div>
</div>
My PHP showAllCompanies code
public function showAllCompanies(){
$datas = $this->getAllCompanies();
foreach ($datas as $data){
$name = $data['name'];
$orgnr = $data['organization_number'];
$notes = empty($data['notes']) ? "No notes" : $data['notes'];
$id = $data['id'];
echo "
<div class='card me-2 d-block' style='width: 18rem;'>
<div class='card-body'>
<h4 class='card-title'>$name</h4>
<p class='card-text'><i class='bi bi-stickies'></i> $notes</p>
</div>
<ul class='list-group list-group-flush'>
<li class='list-group-item'>Stores Owned <span class='badge text-bg-primary'>XX</span></li>
<li class='list-group-item'>Organization Number <span
class='badge text-bg-primary'>$orgnr</span></li>
</ul>
<div class='card-body'>
<a href='#' class='btn btn-primary'>Edit</a>
<a href='#' class='btn btn-danger'>Delete</a>
</div>
</div>
";
}
return;
}
You're squeezing all your cards onto one row.
If you limit the amount of cards you display to 6 per row you can update your function to this:
public function showAllCompanies(){
$cardsPerRow = 6;
$i = 0;
$datas = $this->getAllCompanies();
foreach ($datas as $data){
$name = $data['name'];
$orgnr = $data['organization_number'];
$notes = empty($data['notes']) ? "No notes" : $data['notes'];
$id = $data['id'];
if($i == 0){
echo '<div class="row">';
}
echo "
<div class='card me-2 d-block' style='width: 18rem;'>
<div class='card-body'>
<h4 class='card-title'>$name</h4>
<p class='card-text'><i class='bi bi-stickies'></i> $notes</p>
</div>
<ul class='list-group list-group-flush'>
<li class='list-group-item'>Stores Owned <span class='badge text-bg-primary'>XX</span></li>
<li class='list-group-item'>Organization Number <span
class='badge text-bg-primary'>$orgnr</span></li>
</ul>
<div class='card-body'>
<a href='#' class='btn btn-primary'>Edit</a>
<a href='#' class='btn btn-danger'>Delete</a>
</div>
</div>
";
if(++$i >= $cardsPerRow){
echo '</div>';
$i = 0;
}
}
return;
}

Column Bootstrap in while loop PHP

I have this problem
and that code is here
<div class="col-md-4 text-center animate-box">
<a href="work-single.html" class="work" style="background-image: url(images/portfolio-2.jpg);">
<div class="desc">
<h3>Project Name</h3>
<span>Brading</span>
</div>
</a>
</div>
<div class="col-md-4 text-center animate-box">
<a href="work-single.html" class="work" style="background-image: url(images/portfolio-2.jpg);">
<div class="desc">
<h3>Project Name</h3>
<span>Brading</span>
</div>
</a>
</div>
<div class="col-md-4 text-center animate-box">
<a href="work-single.html" class="work" style="background-image: url(images/portfolio-2.jpg);">
<div class="desc">
<h3>Project Name</h3>
<span>Brading</span>
</div>
</a>
</div>
now i tried to do a while loop for my php and did this code
<div class="row">
<?php
while ($userRow=$stmt2->fetch(PDO::FETCH_ASSOC))
{
echo "<div class='col-md-4 text-center animate-box'>";
echo "<a href='work-single.html' class='work' style='background-image:url(uploaded_files/uploaded_files_articles_images/" .$userRow['image']. ")';";
echo "<div class='desc'>";
echo "<h3>Project Name</h3>";
echo "<span>Illustration</span>";
echo "</div>";
echo "</a>";
echo"</div>";
}
?>
</div>
and it got me this
So what i tried so far is this
<?php
while ($userRow=$stmt2->fetch(PDO::FETCH_ASSOC))
{
<?
<div class='col-md-4 text-center animate-box'>
<?php
echo "<a href='work-single.html' class='work' style='background-image:url(uploaded_files/uploaded_files_articles_images/" .$userRow['image']. ")';";
echo "<div class='desc'>";
echo "<h3>Project Name</h3>";
echo "<span>Illustration</span>";
echo "</div>";
echo "</a>";
<?
</div>
<?php
}
?>
but still not working still the same layout . sorry for my bad english . Can someone help me to figure out what is the problem on my code. Thank you everyone in advance
echo "<a href='work-single.html' class='work' style='background-image:url(uploaded_files/uploaded_files_articles_images/" .$userRow['image']. ")';";
You are missing a > at the end.
You've missed a > in your anchor tag and also misplaced the semicolon of the CSS. Replace your code with the following one.
echo "<a href='work-single.html' class='work' style='background-image:url(uploaded_files/uploaded_files_articles_images/" .$userRow['image']. ");'>";

My echo is destroying my div container / row

So I want to show my posts with a variable and echo the html form out.
The problem is, that I need
<div class='container'>
<div class='row'>
cause I want it to be displayed in a row. But cause every post got that div classes, it doesnt work and displays the posts completely wrong...
Moreover it shows my buttons "Loeschen" and "Bearbeiten" on top but it should be right below the text field.
How it should look:
How it actually looks now:
<?php
$ort = 'Beiträge';
include ("head.php");
include("database.php");
include("navigation.php");
?>
<!--Beitrage auflisten-->
<?php
$sql = "SELECT * FROM beitrag ORDER BY beitrag_id DESC";
$res = mysqli_query($db, $sql) or die(mysqli_error());
$beitrag = "";
if(mysqli_num_rows($res) > 0) {
while($row = mysqli_fetch_assoc($res)) {
$beitrag_id = $row['beitrag_id'];
$titel = $row['titel'];
$leistung = $row['leistung'];
$bezugsort = $row['bezugsort'];
$kosten = $row['kosten'];
$p_text = $row['p_text'];
$beitrag .= "
<div class='album py-5 bg-light'>
<div class='container'>
<div class='row'>
<div class='col-md-4'>
<div class='card mb-4 box-shadow'>
<div class='card-header'>
<a href='siehe_beitrag.php?pid=$beitrag_id'><h4 class='my-0 font-weight-normal'>$titel</h4></a
<h4 class='my-0 font-weight-normal'>$kosten€</h4 >
</div>
<div class='card-body'>
<p class='card-text'>$p_text</p>
<div class='d-flex justify-content-between align-items-center'>
</div>
</div>
</div>
</div>";
if (isset($_SESSION["login"])){
if($_SESSION["login"] == 1){
echo "
<div class='btn-group' >
<a href='loeschen_beitrag.php?pid=$beitrag_id'>
<button type='button' class='btn btn-sm btn-outline-secondary'>Loeschen</button>
<a href='bearbeiten_beitrag.php?pid=$beitrag_id'>
<button type='button' class='btn btn-sm btn-outline-secondary'>Bearbeiten</button>
</div>";
}else{
echo "";
}
}
}
echo $beitrag;
} else {
echo "Keine Beiträge vorhanden ";
}
?>
<a href='neuer_beitrag.php' target='_blank'>Neuer Beitrag</a>
The final version:
Thanks to aynber and the others, now it works like I imagined it <3
You have two issues: 1) You aren't closing all of the div tags, and 2) you're creating a new container with a width of 4 columns for each row. You'll want to create a new container outside of the loop, and only close/reopen if there are more than 3 results:
if(mysqli_num_rows($res) > 0) {
$i = 0; // Create a counter to see when to start a new row
$beitrag .= "
<div class='album py-5 bg-light'>
<div class='container'>
<div class='row'>";
while($row = mysqli_fetch_assoc($res)) {
$beitrag_id = $row['beitrag_id'];
$titel = $row['titel'];
$leistung = $row['leistung'];
$bezugsort = $row['bezugsort'];
$kosten = $row['kosten'];
$p_text = $row['p_text'];
$beitrag .= "
<div class='col-md-4'>
<div class='card mb-4 box-shadow'>
<div class='card-header'>
<a href='siehe_beitrag.php?pid=$beitrag_id'><h4 class='my-0 font-weight-normal'>$titel</h4></a
<h4 class='my-0 font-weight-normal'>$kosten€</h4 >
</div>
<div class='card-body'>
<p class='card-text'>$p_text</p>
<div class='d-flex justify-content-between align-items-center'>
</div>
</div>";
if(isset($_SESSION["login"]) && $_SESSION["login"] == 1) {
$beitrag .= "
<div class='btn-group' >
<a href='loeschen_beitrag.php?pid=$beitrag_id'>
<button type='button' class='btn btn-sm btn-outline-secondary'>Loeschen</button>
<a href='bearbeiten_beitrag.php?pid=$beitrag_id'>
<button type='button' class='btn btn-sm btn-outline-secondary'>Bearbeiten</button>
</div>";
}
$beitrag .= " </div>
</div>";
$i++;
if($i % 3 == 0) { // 3 results in the div, start a new one
$beitrag .= "
</div>
</div>
</div>";
$beitrag .= "
<div class='album py-5 bg-light'>
<div class='container'>
<div class='row'>";
}
}
if(($i - 1) % 3 != 0) { // It would have been closed on the last loop
$beitrag .= "
</div>
</div>
</div>";
}
echo $beitrag;
}
You have an error in the html, you are not closing the link of the buttons.
<div class='btn-group' >
<a href='loeschen_beitrag.php?pid=$beitrag_id'>
<button type='button' class='btn btn-sm btn-outline-secondary'>Loeschen</button></a>
<a href='bearbeiten_beitrag.php?pid=$beitrag_id'>
<button type='button' class='btn btn-sm btn-outline-secondary'>Bearbeiten</button></a>
</div>

Bootstrap-table - Modify fields with bootstrap modal

I continue with my new website and I'm trying the bootstrap framework and I would like modify a row, its fields, from a bootstrap modal window. At moment I show a modal windows with fields but I don't know to include the data from the row of the table :(
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>AddCloud - Producció</title>
<!-- INCLUDES -->
<link rel="stylesheet" href="assets/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="assets/bootstrap-table/dist/bootstrap-table.css">
<link rel="stylesheet" href="assets/bootstrap-editable/css/bootstrap-editable.css">
<script src="assets/jquery/jquery.min.js"></script>
<script src="assets/bootstrap/js/bootstrap.min.js"></script>
<script src="assets/bootstrap-table/dist/bootstrap-table.js"></script>
<script src="assets/bootstrap-editable/js/bootstrap-editable.js"></script>
</head>
<body>
<!-- SESSION PHP OK -->
<?php
session_start();
if(isset($_SESSION['username']) and $_SESSION['username'] <> ''){
?>
<!-- NAVIGATION -->
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#defaultNavbar1"><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="http://www.addvantage.es"><font color=#8abe44>AddCloud</font></a></div>
<div class="collapse navbar-collapse" id="defaultNavbar1">
<ul class="nav navbar-nav">
<li class="active">Producció<span class="sr-only">(current)</span></li>
<li>Menu2</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li class="dropdown"><a href="#" class="dropdown-toggle"
data-toggle="dropdown" role="button" aria-expanded="false"><span class="glyphicon glyphicon-user"></span> <?php echo $_SESSION['username'] ?></a>
<ul class="dropdown-menu" role="menu">
<li><span class="glyphicon glyphicon-wrench"></span> preferències</li>
<li><span class="glyphicon glyphicon-lock"></span> canviar password</li>
<li class="divider"></li>
<li><span class="glyphicon glyphicon-log-out"></span> log out</li>
</ul>
</li>
</ul>
</div>
</div>
</nav>
<!-- TABLE -->
<div class="container-fluid">
<div class="row">
<div class="col-md-6 col-md-offset-3">
<h1 class="text-center">Miquel Alimentació</h1>
</div>
</div>
<hr>
</div>
<div class="container">
<div class="row text-center">
<div class="col-md-6 col-md-offset-3"><h3>Edició 12</h3></div>
</div>
<hr>
<div class="row">
<?php
// Conexió a la base de dades
include("connect.php");
$conn = Conectarse("localhost", "5432", "dbname", "dbuser", "dbpass");
//query
$query = "SELECT * FROM produccion.ma_origen ORDER BY id_articulo ASC";
$result = pg_query($conn, $query);
//se despliega el resultado
echo "<table id='tableprod'
data-toggle='table'
data-toolbar='#toolbar'
data-show-refresh='true'
data-show-toggle='true'
data-sort-name='name'
data-sort-order='desc'
data-show-columns='true'
data-pagination='true'
data-search='true'
data-click-to-select='true'>";
echo "<thead class='thead-inverse'>";
echo "<tr>";
echo "<th data id='seleccion' data-switchable='false' data-checkbox='true'></th>";
echo "<th data id='pagina' data-sortable='true'>pagina</th>";
echo "<th data id='codigo' data-sortable='true' data-switchable='false'>codigo</th>";
echo "<th data id='descripcion' data-sortable='true' data-switchable='false'>descripcion</th>";
echo "<th data id='pvp-cat' data-sortable='true'>pvp-cat</th>";
echo "<th data id='pvp-lev' data-sortable='true'>pvp-lev</th>";
echo "<th data id='pvp-and' data-sortable='true'>pvp-and</th>";
echo "<th data id='pvp-cen' data-sortable='true'>pvp-cen</th>";
echo "<th data id='pvp-nor' data-sortable='true'>pvp-nor</th>";
echo "<th data id='pvp-vas' data-sortable='true'>pvp-vas</th>";
echo "<th data id='fecha-mod' data-sortable='true'>fecha-mod</th>";
echo "<th data id='user' data-sortable='true' data-visible='false'>user</th>";
echo "<th data id='edit' data-sortable='false' data-switchable='false'>edit</th>";
echo "</tr>";
echo "</thead>";
echo "<tbody>";
while ($row = pg_fetch_row($result)){
echo "<tr>";
echo "<td></td>";
echo "<td>$row[2]></td>";
echo "<td>$row[3]</td>";
echo "<td>$row[4]</td>";
echo "<td>$row[5]</td>";
echo "<td>$row[6]</td>";
echo "<td>$row[7]></td>";
echo "<td>$row[8]</td>";
echo "<td>$row[9]</td>";
echo "<td>$row[10]</td>";
echo "<td>$row[11]</td>";
echo "<td>$row[12]</td>";
echo "<td><p data-placement='top' data-toggle='tooltip' title='Edit'><button class='btn btn-primary btn-xs' data-title='Edit' data-toggle='modal' data-target='#edit' ><span class='glyphicon glyphicon-pencil'></span></button></p></td>";
echo "</tr>";
}
echo "</tbody>";
echo "</table>";
?>
</div>
</div>
<hr>
<div class="row">
<div class="text-center col-md-6 col-md-offset-3">
<p>Copyright © 2016 · All Rights Reserved · <a href="http://www.addvantage.es/" >http://www.addvantage.es</a></p>
</div>
</div>
<hr>
</div>
<!-- MODAL MENU -->
<div class="modal fade" id="edit" tabindex="-1" role="dialog" aria-labelledby="edit" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></button>
<h4 class="modal-title custom_align" id="Heading">Editar registre</h4>
</div>
<div class="modal-body">
<div class="form-group">
<input class="form-control " type="text" placeholder="Pàgina">
</div>
<div class="form-group">
<input class="form-control " type="text" placeholder="Codi">
</div>
<div class="form-group">
<input class="form-control " type="text" placeholder="Descripció">
</div>
<div class="form-group">
<input class="form-control " type="text" placeholder="pvp-cat">
</div>
<div class="form-group">
<input class="form-control " type="text" placeholder="pvp-lev">
</div>
<div class="form-group">
<input class="form-control " type="text" placeholder="pvp-and">
</div>
<div class="form-group">
<input class="form-control " type="text" placeholder="pvp-cen">
</div>
<div class="form-group">
<input class="form-control " type="text" placeholder="pvp-nor">
</div>
<div class="form-group">
<input class="form-control " type="text" placeholder="pvp-vas">
</div>
</div>
<div class="modal-footer ">
<button type="button" class="btn btn-warning btn-lg" style="width: 100%;"><span class="glyphicon glyphicon-ok-sign"></span> Update</button>
</div>
</div>
</div>
</div>
<!-- SESSION PHP ERROR -->
<?php
} else{
?><p>La sesión no está activa, por favor ingrese aquí</p>
<?php
}?>
</body>
</html>
I use php to connect to database and add data into the table. My idea is from a edit button can modify this fields from a modal window. After that I would like to update database.
I'm not sure if this is the best way, I haven't a experience programming from web environment.
Please Could you help me to modify this data-fields from windows modal?
Thanks!
The way to try to do is correct. What you have to do is on clicking Edit link find the closest tr and find all the td that tr contain. Read td one by one the assign it to the text box.
Below is the code:
$('.edit').click(function(){
var $row = $(this).closest("tr"), $tds = $row.find("td"); //This will all the tds we need.
$.each($tds, function() {
$('#txtbox').val($(this).text()); //textbox in the modal window
});
});
The above code will fill all the values from the row to modal window after that you can modify and submit the form.
First step - identify row somehow. I'm working under assumption that $row[0] is the id of that row in the database. If it isn't change the code accordingly.
index.php
while ($row = pg_fetch_row($result)){
echo "<tr id="{$row[0]}">"; // assign id that corresponds to database id to each row
echo "<td></td>";
echo "<td class="pagina">$row[2]></td>";
echo "<td class="codigo">$row[3]</td>";
echo "<td class="descripcion">$row[4]</td>";
echo "<td class="pvp-cat">$row[5]</td>";
echo "<td class="pvp-lev">$row[6]</td>";
echo "<td class="pvp-and">$row[7]></td>";
echo "<td class="pvp-cen">$row[8]</td>";
echo "<td class="pvp-nor">$row[9]</td>";
echo "<td class="pvp-vas">$row[10]</td>";
echo "<td class="fecha-mod">$row[11]</td>";
echo "<td class="user">$row[12]</td>";
echo "<td>
<p data-placement='top' data-toggle='tooltip' title='Edit'>
<button class='edit' class='btn btn-primary btn-xs' data-title='Edit' data-toggle='modal' data-target='#edit'>
<span class='glyphicon glyphicon-pencil'></span>
</button>
</p>
</td>";
echo "</tr>";
}
Second, set jquery click event to copy values from rows and fill the modal input fields with correct values:
JQUERY
$('.edit').click(function(){
var row = $(this).closest("tr"), // edit button is in the same row as data you want to change
tds = row.find("td"); // get all table cells in that row
$.each(tds, function(index) {
if( $.inArray(index, [0, 10, 11, 12]) ) { // indexes of cells not to be used when getting data from table cells to edit
return; // skip to next loop iteration if one of these indexes
}
var input_name = $(this).attr("class"); // get name of cell we are evaluating (pagina, codigo, descripcion etc)
$([name='"' + input_name + '"']).val($(this).text()); //input name in the modal window
});
});
I've changed the modal to reflect changes in code above.
MODAL
<div class="modal fade" id="edit" tabindex="-1" role="dialog" aria-labelledby="edit" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></button>
<h4 class="modal-title custom_align" id="Heading">Editar registre</h4>
</div>
<form action="/store.php">
<div class="modal-body">
<input type="hidden" name="id" type="text"> <!-- hidden input for id -->
<div class="form-group">
<input class="form-control" name="pagina" type="text" placeholder="Pàgina">
</div>
<div class="form-group">
<input class="form-control" name="codigo" type="text" placeholder="Codi">
</div>
<div class="form-group">
<input class="form-control" name="descripcion" type="text" placeholder="Descripció">
</div>
<div class="form-group">
<input class="form-control" name="pvp-cat" type="text" placeholder="pvp-cat">
</div>
<div class="form-group">
<input class="form-control" name="pvp-lev" type="text" placeholder="pvp-lev">
</div>
<div class="form-group">
<input class="form-control" name="pvp-and" type="text" placeholder="pvp-and">
</div>
<div class="form-group">
<input class="form-control" name="pvp-cen" type="text" placeholder="pvp-cen">
</div>
<div class="form-group">
<input class="form-control" name="pvp-nor" type="text" placeholder="pvp-nor">
</div>
<div class="form-group">
<input class="form-control" name="pvp-vas" type="text" placeholder="pvp-vas">
</div>
</div>
<div class="modal-footer ">
<input type="submit" class="btn btn-warning btn-lg" style="width: 100%;" value="Update">
</div>
</form>
</div>
</div>
</div>
File for storing edited values to the database:
store.php
<?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "myDB";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$id = $_POST['id'];
$pagina = $_POST['pagina'];
$codigo = $_POST['codigo'];
$descripcion = $_POST['descripcion'];
$pvp-cat = $_POST['pvp-cat'];
$pvp-lev = $_POST['pvp-lev'];
$pvp-and = $_POST['pvp-and'];
$pvp-cen = $_POST['pvp-cen'];
$pvp-nor = $_POST['pvp-nor'];
$pvp-vas = $_POST['pvp-vas'];
$sql = "UPDATE produccion.ma_origen SET pagina='{$pagina}',codigo='{$codigo}',descripcion='{$descripcion}',
pvp-cat='{$pvp-cat}', pvp-lev='{$pvp-lev}',pvp-and='{$pvp-and}',
pvp-cen='{$pvp-cen}',pvp-nor='{$pvp-nor}',pvp-vas='{$pvp-vas}'
WHERE id={$id}";
if ($conn->query($sql) === TRUE) {
echo "Record updated successfully";
} else {
echo "Error updating record: " . $conn->error;
}
$conn->close();
?>
Since this was a lot of code to change and I don't have the time and all the data to test this properly you'll have to do it, but this is one of the ways you could solve your problem. Hope it helps.

display different image in same div in php

I want to display first image,title and description in col1 div, second in col3 and so on
but in this first image repeat in all div . how to solve this
<?php
include('connection.php');
$perPage=1;
$i=1;
if(isset($_REQUEST['act']) && trim($_REQUEST['act']=='load_data')){
$page=1;
if(!empty($_GET["page"])) {
$page = $_GET["page"];
}
$start = ($page-1)*$perPage;
if($start < 0) $start = 0;
$msg='';
$q="SELECT * FROM addimages order by id desc limit $start,$perPage ";
$res = mysql_query($q);
$row = mysql_fetch_array($res);
$id = $row['art_id'];
$qe="select banner from images where id=$id";
$rs=mysql_query($qe);
$name=mysql_fetch_array($rs);
//$id=$row['id'];
//$no=mysql_num_rows($res);
if(!$row==""){
$msg .= "<div class='article_index' id='".$row["art_id"]."'><div class='article banner_add'><a href='#'><img height='220' src='./uploads/" . $name['banner'] . "' /></a></div>";
$msg .=" <div class='post_main' >
<div class='col1'>
<div class='post_img'><a href='#'><img class='lazy' data-original='./uploads/" . $row['image'] . "' width='633' height='441' src='./uploads/" . $row['image'] . "' style='display: inline;' /></a>
</div>
<div class='post_contant_main'>
<div class='post_title'><h2><a href='#'>".$row['title']."</a></h2></div>
<div class='post_contant'>".$row['desc']."</div>
</div>
</div>";
$msg .=" <div class='col3'>
<div class='post_img'><a href='#'><img class='lazy' width='299' height='191' src='./uploads/" . $row['image'] . "' style='display: inline;' /></a>
</div>
<div class='post_contant_main'>
<div class='post_title post_rtitle'><h2><a href='#'>".$row['title']."</a></h2></div>
</div>
</div>
<div class='col3'>
<div class='post_img'><a href='#'><img class='lazy' width='299' height='191' src='./uploads/" . $row['image'] . "' style='display: inline;' /></a>
</div>
<div class='post_contant_main'>
<div class='post_title post_rtitle'><h2><a href='#'>".$row['title']."</a></h2></div>
</div>
</div>
<div class='col2'>
<div class='post_img'><a href='#'><img class='lazy' width='461' height='300' src='./uploads/" . $row['image'] . "' style='display: inline;' /></a>
</div>
<div class='post_contant_main'>
<div class='post_title'><h2><a href='#'>".$row['title']."</a></h2></div>
<div class='post_contant'>".$row['desc']."</div>
</div>
</div>
<div class='col2'>
<div class='post_img'><a href='#'><img class='lazy' width='461' height='300' src='./uploads/" . $row['image'] . "' style='display: inline;' /></a>
</div>
<div class='post_contant_main'>
<div class='post_title'><h2><a href='#'>".$row['title']."</a></h2></div>
<div class='post_contant'>".$row['desc']."</div>
</div>
</div>
</div>
</div>
";
}
$msg .="<a class='next' href='#'></a>
<input type='hidden' id='pageno' name='pageno' value=''>";
echo $msg;
}
?>
i want to increase row array to next id and display its content
i am using infinite scroll plugin
you fetch only one top row. If you want to get all rows, you need to loop it thought.
while ($row = $result->fetch_row()) {
$msg .=" <div class='post_main' >
<div class='col1'>
<div class='post_img'><a href='#'><img class='lazy' data-original='./uploads/" . $row['image'] . "' width='633' height='441' src='./uploads/" . $row['image'] . "' style='display: inline;' /></a>
</div>
<div class='post_contant_main'>
<div class='post_title'><h2><a href='#'>".$row['title']."</a></h2></div>
<div class='post_contant'>".$row['desc']."</div>
</div>
</div>";
}

Categories