logo
down
shadow

Form Data to a Table With a Database


Form Data to a Table With a Database

By : user2955558
Date : November 22 2020, 10:40 AM
I wish this help you The general shape of your script could look like this (i didn't look precisely if smthg wrong in your code, just reorganized it a bit...
code :
<!DOCTYPE html>
<html>
<head>
    <title>LMCS CAD</title>
</head>
<body>
  <div align="center">
  <form action="" method="get">
 <table width="968" height="248" border="1" align="center" cellpadding="10" cellspacing="0"  rules="rows" id="incidents" style="color:#333333;border-collapse:collapse;text-align:left;">
  <tr style="color:White;background-color:#5D7B9D;font-weight:bold;font-style:italic;">
  <th scope="col">TOWN</th>
  <th scope="col">LOCATION</th>
  <th scope="col">INCIDENT TYPE</th>
  <th scope="col">TIME/DATE</th>
  <th scope="col">ADMIN</th>
  </tr>
  <tr style="color:#333333;background-color:#F7F6F3;font-weight:bold;">
    <?php
    $town = $_POST['town'];
    $location = $_POST['location'];
    $incident_type= $_POST['incident_type'];
    $time_date= $_POST['time_date'];
    $admin = $_POST['admin'];

    $db = mysqli_connect('localhost','root','') or die("Database error"); 
    mysqli_select_db($db, 'mydatabase');  
    $result= mysqli_query($db, "select * from cad"); 
    while($row = mysqli_fetch_array($result))
    {
        echo "<td>" .$row['town'] ."</td>"; 
        echo "<td>" .$row['location'] ."</td>"; 
        echo "<td>" .$row['incident_type'] ."</td>"; 
        echo "<td>" .$row['time_date'] ."</td>"; 
        echo "<td>" .$row['admin'] ."</td>"; 
    }
    ?>
  </tr>
    </table>
  </form>
  </body>
</html>


Share : facebook icon twitter icon
view data form database table to table tag in jsp page

view data form database table to table tag in jsp page


By : user2294945
Date : March 29 2020, 07:55 AM
this one helps. Just use the doGet() method of the Servlet and call the URL of the servlet instead.
E.g.
code :
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    List<User> users = userDAO.list();
    request.setAttribute("users", users);
    request.getRequestDispatcher("/WEB-INF/users.jsp").forward(request, response);
}
<servlet>
    <servlet-name>users</servlet-name>
    <servlet-class>com.example.UsersServlet</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>users</servlet-name>
    <url-pattern>/users</url-pattern>
</servlet-mapping>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
...
<table>
    <c:forEach items="${users}" var="user">
        <tr>
            <td>${user.name}</td>
            <td>${user.email}</td>
            <td>${user.age}</td>
        </tr>
    </c:forEach>
</table>
 <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
How do I use SESSION data to SELECT 1 database entry and then INSERT into another table with data from a form as well wi

How do I use SESSION data to SELECT 1 database entry and then INSERT into another table with data from a form as well wi


By : Akshit Jariwala
Date : March 29 2020, 07:55 AM
will help you All security issues aside. , Your SQL statement is incorrect, the variables require escaping.
code :
"...VALUES('". $_POST['bugname'] . "')";
How to edit retrieved data from database and return table's data to the form's text fields

How to edit retrieved data from database and return table's data to the form's text fields


By : Gary Mclean
Date : March 29 2020, 07:55 AM
it fixes the issue what i did finally is to add the following scripts marked in bold in my edit.scala.html template. and in each edit text value i added :
value="@data.id_of_this_filed"
code :
  @(data:Users,customerForm: Form[Users])

@main("edit") {

   <form ... >

.....

<div class="form-group row  ">
                                <label class="col-sm-2 form-control-label">Amount</label>
                                <div class="col-sm-10">
                                    <input
                                            name="amount"
                                            id=""
                                            **value="@data.amount"**
                                            class="form-control"
                                            type="number"
                                            placeholder="Rwfr">
                                </div>
                            </div>

.......

   </form>
        }
Inserting data from html form using php into data table in mysql database

Inserting data from html form using php into data table in mysql database


By : wwinters
Date : March 29 2020, 07:55 AM
wish of those help It seems like you've simply forgot to fetch the value from the form! That aside, your $Song Title isn't a variable, it's a variable, then a space, then the string "Title".
I recommend you don't use any names in a form or in the database that contains spaces, use underscore as a replacement (or choose simpler names). So for instance, your
code :
<input type="text" name="Song Title" id="Song Title">
<input type="text" name="Song_Title" id="Song_Title">
/* Attempt MySQL server connection.*/
$link = mysqli_connect("host", "user", "pass", "db");

/*Check connection*/
if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit();
}

if (isset($_POST['Artist'], $_POST['Song_Title'])) {
    if ($stmt = $link->prepare("INSERT INTO `rbn_setlist_small`(`Artist`, `Song Title`) VALUES (?, ?)")) {
        $stmt->bind_param("ss", $_POST['Artist'], $_POST['Song_Title']);
        if (!$stmt->execute()) {
            error_log("Execute failed ".$stmt->error);
        } else {
            echo "Data successfully inserted! Artist ".$_POST['Artist']." and song ".$_POST['Song_Title'];
        }
        $stmt->close();
    } else {
        error_log("Prepare failed ".$link->error);
    }
}
<?php 
error_reporting(E_ALL);
ini_set("display_errors", 1);
display data with number of week count in table and appending data form database php mysql

display data with number of week count in table and appending data form database php mysql


By : Emre Calisir
Date : March 29 2020, 07:55 AM
Hope this helps Try the following, There are many issues with your logic here, First you are creating new table each time its Monday so the first thing is to move the starting and ending tags of table out of the loop.
Now I don't have the databases but I hope it will fix the issue.
code :
<!-- language: lang-php -->
<!DOCTYPE html>
<html lang="en">

<head>
    <title>Bootstrap Example</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
    <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
</head>

<body>
<?php
$con = mysqli_connect('localhost','root','','test');
$startingDay = date('Y-m-d', strtotime("first sunday of this month -6 days"));
$numberOfDays = 35;
$dates = array();
$weekCounter = 1;
$meetingRow  = '';
$meetingRow   .= '<div class="container">';
$meetingRow   .= '<table class="table" border="1" cellpadding="2" cellspacing="2">';
$meetingRow   .= '<tbody>';




for ($i = 0; $i <= $numberOfDays - 1; $i++) {

    $date    = date('m/j/Y', strtotime("$startingDay +$i days"));
    $dates[] = $date;

    if (date('l', strtotime($date)) == "Monday") {

        $meetingRow   .= '<tr><td colspan="8"></td></tr>';
        $meetingRow   .= '<tr>';
        $meetingRow   .= '<th>Week ' .  $weekCounter++ . '</th>';
    }

    $meetingRow    .= '<th>';
    $meetingRow    .= '<p>' . $date. '</p>';
    $meetingRow    .= '<p>' . date('l', strtotime($date)). '</p>';
    $meetingRow    .= '</th>';

    if (date('l', strtotime($date)) == "Sunday") {

        $meeting_room_sql = "SELECT id , meeting_room_name  FROM meeting_room";
        $meeting_room_result = mysqli_query($con, $meeting_room_sql);
        // you are to use $meeting_room_result not $meeting_room_sql error occurs in fetching from meeting_room
        while ($meeting_room_row = mysqli_fetch_assoc($meeting_room_result)) {

            $meeting_room_id    = $meeting_room_row['id'];
            $meeting_room_name  = $meeting_room_row['meeting_room_name'];

            $meetingRow   .= '<tr> 
                                 <td> 
                                    <div>' . htmlentities($meeting_room_name, ENT_QUOTES, "UTF-8") . '</div>
                                    <button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#meetingModal">Reserve</button>
                                 </td>';

            $reserved_sql = "SELECT meeting_room_id, reserved_date FROM meeting WHERE meeting_room_id = {$meeting_room_row["id"]}";
            $reserved_result = mysqli_query($con, $reserved_sql);
            $total_number_of_rows = 7;//As we have 7 days in a week so we have 7 days column

            $RowCounter = 0;
            while ($reserved_row = mysqli_fetch_assoc($reserved_result)) {
                $RowCounter++;
                $reserved_room_id = $reserved_row['meeting_room_id'];
                $reserved_date    = $reserved_row['reserved_date'];

                if ($reserved_room_id == $meeting_room_id) {
                    $meetingRow   .= '<td>' . htmlentities('Meeting Reserved ' . date('m/j/Y', strtotime($reserved_date)), ENT_QUOTES, "UTF-8"). '</td>';
                } else {
                    $meetingRow   .= '<td><br /></td>';
                }
            }
            while ($RowCounter < $total_number_of_rows){
                    $meetingRow   .= '<td><br /></td>';
                    $RowCounter++;
            }

            $meetingRow   .= '<tr>';

        }
        $meetingRow   .= '</tr>';
    }



}
$meetingRow   .= '</tbody>';
$meetingRow   .= '</table>';
$meetingRow   .= '</div>';
echo $meetingRow;
?>
<script>
    $(function() {
        $("#meeting_date").datepicker();
    });
</script>
</body>

</html>
Related Posts Related Posts :
  • Dynamic image for user's ID
  • How to only upload specific parts of HTML form with PHP?
  • Dynamic PHP string as MySQL table name
  • What is the error in my query?
  • PHP Upstart on Amazon EC2 Linux (Elasticbeanstalk)
  • how to print dynamic variable value in php
  • php mysql insert values and select
  • uploading image in codeigniter controller
  • Converting htaccess to nginx for counter
  • how can I show my signal transaction data as project name
  • php raspberry pi trying to change pi date
  • PHP and mysql, SELECT query return null
  • Unable to store Date values in php mysql table that are existing in excel file
  • Can we include 2 Mail() functions in 1 Page?
  • Problems with chinese characters
  • How to apply a function to every foreach result?
  • Use of CONCAT in FROM clause
  • Tag endpoint combined with user endpoint with Instagram API
  • create dynamic time in php and mysql
  • How to break zero index comma separated value into individual string in php
  • PHP Login session and echoing username
  • PHP : Difference b/w new self and new object()
  • Turkish character issue while inserting into MySQL database with PHP
  • Insert data from one DB into another on a different server - servers not linked
  • Sorting an array of strings using values alphabetically and considering the cases of values in PHP
  • Unable to solve .htaccess url rewriterule, gives 404 for all pages
  • Dual URL Rewrite In PHP
  • How to change value of cdata inside a .xml file and then again save it using php
  • Using filters from other classes within rules method in Yii 2?
  • json_decode syntax error from valid json
  • PHP get directory of included file on Virtualhost
  • RSA in php is confusing
  • Order in order without using events
  • How do I download a batch of pictures from URLs stored in a MySQL database
  • How to find pattern matching and save to array with preg_match
  • laravel4 data is not inserting in a single field
  • How can i merge Rows of An HTML table fetched from Mysql
  • How to get the duplicate values in array?
  • Add "."(dot) in a Numbers
  • Zend 2 multiple layouts for 1 module setup
  • PHP - Codeigniter : Uncaught exception 'PHPExcel_Reader_Exception' with message 'Could not open for reading, File does n
  • PHP Form Troubles
  • How to use if condition in my wordpress shortcode
  • Amazon S3 Data retrieval in URL for all the images in bucket
  • Convert Bangla date to standard English date
  • In Jquery how to redirect to another page?
  • Building an ecommerce site using Laravel: How do I view/route products based on their ID?
  • My kg and lbs conversion is always off by significant amount
  • How to use loop in comment section
  • Jqgrid with Datepicker
  • How to prevent opening an authenticated php web page?
  • phpexcel - Making file to download rather than saving in the server
  • Send radio box value with $_POST
  • Volley: How to extract JSONObject from String Response? Is it possible?
  • Adding Image to the Excel in phpexcel in php
  • Pass an array to Redirect::action in laravel
  • display file name in while loop without url
  • Snow by date php
  • How to Replace a value in SQL only to a certain extent
  • How do I use HTML & PHP forms to insert data into a database?
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org