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>
Related
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;
}
I'm trying to create a categories list, where user will be able to choose item with certain category, but as soon as I'm opening any of the categories, where "soon = '2'", there is only one item coming up. Everything else works.
The code bellow is for categories, where user can chose which caegory s/he want to see.
//navbar.php
<!-- Categories -->
<div class="dropdown-item menu_cat" type="button" id="catMenuButton"><i class="fas fa-caret-left"></i> Categories</div>
<form method="POST" class="dropdown-menu dropleft categories_menu row" id="cat_dropdown">
<button class="dropdown-item" name="candle"> Candles</button>
<button class="dropdown-item" name="cloth"> Clothes</button>
<button type="submit"class="dropdown-item" name="tech"> Tech</button>
</form>
Than here is everything else, that is suppose to exectute commands that will show products from category that user choose. The issue comes upp where 'if($row["soon"] == "2")' is.
//products.php
<?php
if(isset($_POST['candle'])){
$sql = "SELECT * FROM products WHERE category = 'candle'";
}else if(isset($_POST['cloth'])){
$sql = "SELECT * FROM products WHERE category = 'cloth'";
}else if(isset($_POST['tech'])){
$sql = "SELECT * FROM products WHERE category = 'tech'";
}else{
$sql = "SELECT * FROM products";
}
$result = $conn->query($sql);
if (!empty($result) && $result->num_rows > 0) {
while ($row = $result->fetch_assoc()){
if($row["soon"] == "2"){
?>
<div class="product_card col-xl-3 col-lg-4 col-md-5 col-sm-12 box-shadow">
<div class="card-header">
<h3 class="product_name my-0 font-weight-normal"> <?php echo $row["productName"] ?> </h3>
</div>
<div class="card-body">
<h2 class="card-title pricing-card-title"> </h2>
<img class="pic" src="productsImages\<?php echo $row["productID"]; ?>.jpeg" height="150px" width="120px"></img>
<br>
<p>
<?php echo $row["productPrice"]; ?> SEK
</p>
<a class="toProduct" href="products_index.php?id=<?php echo $row['productID'] ?>">
<div class="row">
<button class="btn_to_product btn btn-lg btn-outline-dark col-lg-10 col-md-10"> Go to product <i type="button" class="fas fa-arrow-alt-circle-right"></i></button>
</div>
</a>
</div>
</div>
<?php }else if($row['soon'] == "1" && isset($_POST['tech']) || isset($_POST['candle'])){?>
<div class="product_card col-xl-3 col-lg-4 col-md-5 col-sm-12 box-shadow">
<div class="card-header">
<h3 class="product_name my-0 font-weight-normal"> <?php echo $row["productName"] ?> </h3>
</div>
<div class="card-body">
<h2 class="card-title pricing-card-title"> </h2>
<img class="pic_soon" src="productsImages/comingSoon.png" height="150px" width="120px"></img>
<style>
</style>
<br>
<p>
<?php echo $row["productPrice"]; ?> SEK
</p>
<a class="toProduct" href="products_index.php?id=<?php echo $row['productID'] ?>">
<div class="row">
<button class="btn_to_product btn btn-lg btn-outline-dark col-lg-10 col-md-10"> Go to product <i type="button" class="fas fa-arrow-alt-circle-right"></i></button>
</div>
</a>
</div>
</div>
<?php
}
}
}
else if(empty($result) || $result->num_rows == 0){
echo "<h2 class='col-12'> Sorry! </h2>";
echo "<h3 class='col-12'> There is not any product in this category yet! </h3>";
}
$conn->close();
?>
In the original post was duplicate $row = $result->fetch_assoc(); statement.
In updated post there is first condition out of the while loop.
Solution bellow is wrapping all the if($row['soon'] into the while loop:
<div class="card-deck col-lg-12 col-md-12 col-sm-12 justify-content-center text-center">
<?php
if(isset($_POST['candle'])){
$sql = "SELECT * FROM products WHERE category = 'candle'";
}else if(isset($_POST['cloth'])){
$sql = "SELECT * FROM products WHERE category = 'cloth'";
}else if(isset($_POST['tech'])){
$sql = "SELECT * FROM products WHERE category = 'tech'";
}else{
$sql = "SELECT * FROM products";
}
$result = $conn->query($sql);
if (!empty($result) && $result->num_rows > 0) {
while ($row = $result->fetch_assoc()){
if($row['soon'] == "1" && isset($_POST['tech']) || isset($_POST['candle'])){
echo "<h2 class='col-12'> Sorry! </h2>";
echo "<h3 class='col-12'> This product will be soon avaiable </h3>";
}
if($row["soon"] == "2"){
?>
<div class="product_card col-xl-3 col-lg-4 col-md-5 col-sm-12 box-shadow">
<div class="card-header">
<h3 class="product_name my-0 font-weight-normal"> <?php echo $row["productName"] ?> </h3>
</div>
<div class="card-body">
<h2 class="card-title pricing-card-title"> </h2>
<img class="pic" src="productsImages\<?php echo $row["productID"]; ?>.jpeg" height="150px" width="120px"></img>
<br>
<p>
<?php echo $row["productPrice"]; ?> SEK
</p>
<a class="toProduct" href="products_index.php?id=<?php echo $row['productID'] ?>">
<div class="row">
<button class="btn_to_product btn btn-lg btn-outline-dark col-lg-10 col-md-10"> Go to product <i type="button" class="fas fa-arrow-alt-circle-right"></i></button>
</div>
</a>
</div>
</div>
<?php
}
}
}else if($result->num_rows == 0){
echo "<h2 class='col-12'> Sorry! </h2>";
echo "<h3 class='col-12'> There is not any product in this category yet! </h3>";
}
$conn->close();
?>
</div>
}
}else if($result->num_rows == 0){
echo "<h2 class='col-12'> Sorry! </h2>";
echo "<h3 class='col-12'> There is not any product in this category yet! </h3>";
}
$conn->close();
?>
</div>
Recommendation: Always debug your scripts with enabled PHP Error Reporting!
products.php
<?php
if(isset($_POST['candle'])){
$sql = "SELECT * FROM products WHERE category = 'candle'";
}else if(isset($_POST['cloth'])){
$sql = "SELECT * FROM products WHERE category = 'cloth'";
}else if(isset($_POST['tech'])){
$sql = "SELECT * FROM products WHERE category = 'tech'";
}else{
$sql = "SELECT * FROM products";
}
$result = $conn->query($sql);
if (!empty($result) && $result->num_rows > 0) {
while ($row = $result->fetch_assoc()){
if($row["soon"] == "2"){
?>
<div class="product_card col-xl-3 col-lg-4 col-md-5 col-sm-12 box-shadow">
<div class="card-header">
<h3 class="product_name my-0 font-weight-normal"> <?php echo $row["productName"] ?> </h3>
</div>
<div class="card-body">
<h2 class="card-title pricing-card-title"> </h2>
<img class="pic" src="productsImages\<?php echo $row["productID"]; ?>.jpeg" height="150px" width="120px"></img>
<br>
<p>
<?php echo $row["productPrice"]; ?> SEK
</p>
<a class="toProduct" href="products_index.php?id=<?php echo $row['productID'] ?>">
<div class="row">
<button class="btn_to_product btn btn-lg btn-outline-dark col-lg-10 col-md-10"> Go to product <i type="button" class="fas fa-arrow-alt-circle-right"></i></button>
</div>
</a>
</div>
</div>
<?php }else if($row['soon'] == "1" && isset($_POST['tech']) || isset($_POST['candle'])){?>
<div class="product_card col-xl-3 col-lg-4 col-md-5 col-sm-12 box-shadow">
<div class="card-header">
<h3 class="product_name my-0 font-weight-normal"> <?php echo $row["productName"] ?> </h3>
</div>
<div class="card-body">
<h2 class="card-title pricing-card-title"> </h2>
<img class="pic_soon" src="productsImages/comingSoon.png" height="150px" width="120px"></img>
<style>
</style>
<br>
<p>
<?php echo $row["productPrice"]; ?> SEK
</p>
<a class="toProduct" href="products_index.php?id=<?php echo $row['productID'] ?>">
<div class="row">
<button class="btn_to_product btn btn-lg btn-outline-dark col-lg-10 col-md-10"> Go to product <i type="button" class="fas fa-arrow-alt-circle-right"></i></button>
</div>
</a>
</div>
</div>
<?php
}
}
}
else if(empty($result) || $result->num_rows == 0){
echo "<h2 class='col-12'> Sorry! </h2>";
echo "<h3 class='col-12'> There is not any product in this category yet! </h3>";
}
$conn->close();
?>
i want to set a limit in my card-text to like 200 words, so it does not display the whole text in the card box field.
Is there a way to do that without script? Or when there is only a solution with script, how would you implement that in my code?
Any help would be nice, thank you!
if(mysqli_num_rows($res) > 0) { $i = 0; // Ein Zähler um zusehen, wann eine neue Reihe erstellt werden soll $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']; $miete = $row['miete']; $einkauf = $row['einkauf']; $freizeit = $row['freizeit']; $sonstiges = $row['sonstiges']; $g_kosten = $row['g_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'>$g_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) { //Buttons loeschen und bearbeiten anzeigen, falls es ein angemeldeter Nutzer ist $beitrag .= "
<div class='btn-group'>
<a href='loeschen_beitrag.php?pid=$beitrag_id'>
<button type='button' class='btn btn-sm btn-outline-danger'>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) { // Drei Ergebnisse in der div -> Starte eine neue $beitrag .= "
</div>
</div>
</div>"; $beitrag .= "
<div class='album py-5 bg-light'>
<div class='container'>
<div class='row'>"; } } if(($i - 1) % 3 != 0) { // An der letzten Schleife schließen $beitrag .= "
</div>
</div>
</div>"; }
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!
I´m trying to delete and/or update data from form inside a modal window .For create it I haven´t problem but with the others actions (delete and update) I always have a problem,I think the key is the "id" it seems take the last value and not the value that I want to delete or update.
I know my code could be more nice.
<div class="container">
<div class="row espacio">
<p class="col-md-1"><a data-toggle="modal" href="#myModal" class="btn btn-default glyphicon glyphicon-plus"><span></span></a></p>
<p class="col-md-1 col-md-offset-10"><span class="btn btn-default glyphicon glyphicon-envelope"></span></p>
<table class="table table-bordered">
<caption>Bitácora</caption>
<thead>
<tr>
<th>Tecnico</th>
<th>Turno</th>
<th>Información</th>
<th>Estado</th>
<th>Creada</th>
<th>Modificada</th>
</tr>
</thead>
<tbody>
<?php
$txt ="";
$nombres =array();
$turnos = array('Mañana','Tarde','Noche');
$estados =array('Pendiente','Cerrado');
$db = new Db;
$sql = "SELECT * FROM tecnicos";
foreach ($db->consulta($sql) as $row) {
array_push($nombres,$row['Nombre']);
}
$sql = 'SELECT * FROM bitacora ORDER BY Estado DESC';
$consulta = $db->consulta($sql);
while ($row = mysqli_fetch_array($consulta)) {
$tecnico = $turno = $estado = "";
if ($row['Estado'] == "Pendiente"){
$txt .= "<tr class= 'bg-warning'>";
}else{
$txt .= "<tr class= 'bg-success'>";
}
$txt .= "
<td>". $row['Name'] . "</td>
<td>". $row['Turno'] . "</td>
<td>". $row['Info'] . "</td>
<td>". $row['Estado'] . "</td>
<td>". $row['RecordDate'] . "</td>
<td>". $row['ModiDate'] . "</td>
<td class='text-center'><a data-toggle='modal' href='#myModalUpdate".$row['Id']."''><span class='glyphicon glyphicon-pencil'></span></a>
<a data-toggle='modal' href='#myModalDelete".$row['Id']."''><span class='glyphicon glyphicon-remove'></span></a> </td>
</tr>";
//MODAL UPDATE
for ($i=0; $i <sizeof($nombres) ; $i++) {
if ($nombres[$i] == $row['Name'] ) {
$tecnico .= '<option value="'.$nombres[$i].'" selected="selected">'.$nombres[$i].'</option>';
}
else{
$tecnico .= '<option value="'.$nombres[$i].'" >'.$nombres[$i].'</option>';
}
}
for ($i=0; $i <sizeof($turnos) ; $i++) {
if ($turnos[$i] == $row['Turno']) {
$turno .= '<option value="'.$turnos[$i].'" selected="selected">'.$turnos[$i].'</option>';
}
else{
$turno .= '<option value="'.$turnos[$i].'" >'.$turnos[$i].'</option>';
}
}
for ($i=0; $i <sizeof($estados) ; $i++) {
if ($estados[$i] == $row['Estado']) {
$estado .= '<option value="'.$estados[$i].'" selected="selected">'.$estados[$i].'</option>';
}
else{
$estado .= '<option value="'.$estados[$i].'" >'.$estados[$i].'</option>';
}
}
$txt .= " <div class='modal fade' id='myModalUpdate".$row['Id']."' role='dialog'>
<div class='modal-dialog'>
<!-- Modal content-->
<div class='modal-content'>
<div class='modal-header'>
<button type='button' class='close' data-dismiss='modal'>×</button>
<h4 class='modal-title'>Modifica registro en Bitácora</h4>
</div>
<div class='modal-body'>
<form role='form' action='' method='post'>
<div class='form-group'>
<input type='text' name='id' value='".$row['Id']."'>
</div>
<div class='form-group'>
<label>Técnico</label>
<select class='form-control' name='modnombre'>
".$tecnico."
</select>
</div>
<div class='form-group'>
<label>Turno</label>
<select class='form-control' name='modturno'>
".$turno."
</select>
</div>
<div class='form-group'>
<label>Información</label>
<textarea class='form-control' name='modinformacion'>".$row['Info']."</textarea>
</div>
<div class='form-group'>
<label>Estado</label>
<select class='form-control' name='modestado'>
".$estado."
</select>
</div>
<div class='form-group text-center'>
<button type='submit' class='btn btn-warning' name='actualizar'>Actualiza</button>
</div>
</div><!--/modal body-->
<div class='modal-footer'>
<button type='button' class='btn btn-default' data-dismiss='modal'>Close</button>
</div>
</div><!--/modal content-->
</div><!--/modal dialog-->
</div><!--/modal-->";
//MODAL DELETE
$txt .= " <div class='modal fade' id='myModalDelete".$row['Id']."' role='dialog' >
<div class='modal-dialog'>
<!-- Modal content-->
<div class='modal-content'>
<div class='modal-header'>
<button type='button' class='close' data-dismiss='modal'>×</button>
<h4 class='modal-title'>Elemina registro en Bitácora</h4>
</div>
<div class='modal-body'>
<form role='form' action='' method='post'>
<div class='form-group'>
<input type='text' name='id' value='".$row['Id']."'>
</div>
<div class='form-group text-center'>
<button type='submit' class='btn btn-danger' name='eliminar'>Elimina</button>
</div>
</div><!--/modal body-->
<div class='modal-footer'>
<button type='button' class='btn btn-default' data-dismiss='modal'>Close</button>
</div>
</div><!--/modal content-->
</div><!--/modal dialog-->
</div><!--/modal-->";
}//end for principal
echo $txt;
?>
</tbody>
</table>
</div>
<!--MODAL CREATE-->
<div class="modal fade" id="myModal" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Añade registro en Bitácora</h4>
</div>
<div class="modal-body">
<form role="form" action="" method="post">
<div class="form-group">
<label>Técnico</label>
<select class="form-control" name="nombre">
<?php
$txt ="";
$db = new Db;
$sql = "SELECT * FROM tecnicos";
foreach ($db->consulta($sql) as $row) {
$txt.= "<option value='".$row['Nombre']."'>".$row['Nombre']."</option>";
}
echo $txt;
?>
</select>
</div>
<div class="form-group">
<label>Turno</label>
<select class="form-control" name="turno">
<option value="Mañana">Mañana</option>
<option value="Tarde">Tarde</option>
<option value="Noche">Noche</option>
</select>
</div>
<div class="form-group">
<label>Información</label>
<textarea class="form-control" name="informacion"></textarea>
</div>
<div class="form-group text-center">
<button type="submit" class="btn btn-success" name="crear">Crear</button>
</div>
</form>
</div><!--/modal body-->
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div><!--/modal content-->
</div><!--/modal dialog-->
</div><!--/modal-->
</div> <!-- /container -->
And these are the action´s form
enter code //formulario CREATE
if(isset($_POST["crear"])) {
$nombre = $_POST["nombre"];
$turno = $_POST["turno"];
$informacion = $_POST["informacion"];
$sql = "INSERT INTO bitacora (Name,Turno,Info,Estado,RecordDate,ModiDate) VALUES ('" . $nombre . "', '" . $turno . "', '" . $informacion . "','Pendiente',now(),now())";
$db->consulta($sql);
}
//formulario UPDATE
if(isset($_POST["actualizar"])) {
$sql = "UPDATE bitacora SET Name = '" . $_POST["modnombre"] . "', Turno = '" . $_POST["modturno"] . "', Info = '" .$_POST["modinformacion"]. "', Estado = '" . $_POST["modestado"] . "' , ModiDate =now() WHERE Id = '".$_POST["id"]."' ";
$db->consulta($sql);
}
//form DELETE
if(isset($_POST["eliminar"])) {
$id = $_POST["id"];
$sql = "DELETE FROM bitacora WHERE Id = $id";
$db->consulta($sql);
}here
It seems that your input named "id" is not taking the correct value of $row['Id']. Try to inspect it and see if his "value" is not empty.
If the value was empty, your problem is the value of $row['Id'].
Try to replace $row['Id'] by $row['id'] and see the results.