-1
EMP    |T_IN    |T_OUT    |ITEM    |NOTES
-----------------------------------------
Name 1 | time   | time    | break  | job1
Name 2 | time   | time    | break  | job2
Name 1 | time   | time    | office | 
Name 3 | time   | time    | fab    | job6

The above I need each item in each row column intersection to be displayed in an editable html textbox form for submission to the next step. Ive tried several things... all of which I have abandoned.

<!DOCTYPE html>
<html>
<body>

<form action="test.php" method="post">
Pay Range 
  <input type="date" name="start">
<input type="date" name="stop">
  <input type="submit">
</form>

</body>
</html>


<?php
if($_POST){
mysql_connect('localhost', 'user', 'Pass');
mysql_select_db('database');
$rt = mysql_query("SELECT * FROM TIME WHERE STAMP BETWEEN '". $_POST['start']."' AND '".$_POST['stop']."'");



while($data = mysql_fetch_array($rt)){

    $results .= $data['EMP'].", ".$data['T_IN'].", ".$_POST['T_OUT'].", ".$_POST['ITEM'].", ".$_POST['NOTE'];
echo $results."<br/>";
}
}




?>

UPDATED CODE:

<!DOCTYPE html>
<html>
<body>

<form action="test.php" method="post">
Pay Range 
  <input type="date" name="start">
<input type="date" name="stop">
  <input type="submit">
</form>

</body>
</html>

<?php
$servername = "localhost";
$username = "user";
$password = "Pass";
$dbname = "DB";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
} 

$sql = "SELECT * FROM TIME WHERE STAMP BETWEEN '". $_POST['start']."' AND '".$_POST['stop']."'";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
    // output data of each row
    while($row = $result->fetch_assoc()){
        echo "<input type="text" value=\"" . $row['EMP']. "\"> <br>";
    }
} else {
    echo "0 results";
}
$conn->close();
?>
7
  • Please Provide some code of what you have already done Commented Aug 31, 2015 at 15:23
  • @TomasK Ive deleted it all. But I ran it through a loop and tried several combinations... none of which worked. Commented Aug 31, 2015 at 15:26
  • @TomasK though, it may be my crummy scripting. Commented Aug 31, 2015 at 15:28
  • Have you tried modifying code of answers like stackoverflow.com/q/13549605/4229630 ? Commented Aug 31, 2015 at 15:30
  • @TomasK Ive added my code Commented Aug 31, 2015 at 15:32

1 Answer 1

1

This will output all data from your MySql query

    <?php
    $servername = "localhost";
    $username = "username";
    $password = "password";
    $dbname = "myDB";

    // Create connection
    $conn = new mysqli($servername, $username, $password, $dbname);
    // Check connection
    if ($conn->connect_error) {
        die("Connection failed: " . $conn->connect_error);
    } 

    $sql = "SELECT id, firstname, lastname FROM MyGuests";
    $result = $conn->query($sql);?>
      <form action="test.php" method="post">
   <?php if ($result->num_rows > 0) {
        // output data of each row
        while($row = $result->fetch_assoc()){
    echo '<input type="text" name="myinput" value="' . $row["id"]. '"> <br>'
        }
    } else {
        echo "0 results";
    }
    $conn->close();
    ?>
       </form>

Snippet & more information at w3schools

Sign up to request clarification or add additional context in comments.

5 Comments

How do I place that information into text boxes so it can be edited and the changes submitted?
Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error log.
I found the problem 'text' (T_STRING), expecting ',' or ';' in your code on line 20 echo "<input type="text" value=\"" . $row['EMP']. "\"> <br>";
I used \ to exit the "
if you will fix it arround type=\"text\" Ill give you the points :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.