www.webdeveloper.com
Results 1 to 5 of 5

Thread: data does not display in textbox

  1. #1
    Join Date
    Apr 2014
    Posts
    10

    data does not display in textbox

    hey guys so im trying to display data into text boxes that are fetched from database according to checkbox with value id.

    processing is located before <!DOCTYPE html>
    Code:
    <?php
        if(isset($_POST['edit_event']) && isset($_POST['check']))
        {
            foreach($_POST['check'] as $edit_id)
            {
                require "connection.php";
                $edit_id = (int)$edit_id;
                $sqls = mysql_query("SELECT * FROM event WHERE event_id = '$edit_id' ");
                $z = mysql_fetch_array($sqls);
            }
        }       
    ?>
    button and form opens:
    Code:
    <form method="post" action="event.php">
    <input type="submit" name="edit_event" value="Edit Event">
    this is the html where the data will be echoed, underneath button and form:
    Code:
    <div id="doverlay" class="doverlay"></div>
    <div id="ddialog" class="ddialog">
        <table class="cevent">
        <thead><tr><th>Update Event</th></tr></thead>
        <tbody>
            <tr>
                <td>
                <input type="text" name="en_" value="<?php echo $z['event_name']; ?>">
                </td>
            </tr>
            <tr>
                <td>
                <input type="text" name="dates_" value="<?php echo $z['start_date']; ?>">
                <input type="text" name="times_"  value="<?php echo $z['start_time']; ?>">
                </td>
            </tr>
            <tr>
                <td><input type="text" name="datee_" value="<?php echo $z['end_date']; ?>">
                <input type="text"  name="time_" value="<?php echo $z['end_time']; ?>">
                </td>
            </tr>
            <tr>
                <td><input type="text" name="ev_" value="<?php echo $z['event_venue']; ?>">
                </td>
            </tr>
            <tr>
                <td><input type="submit" name="update" value="Update Event" id="update">
                <input type="submit" id="cancelupdate" name="cancel" value="Cancel" >
                </td>
            </tr>
        </tbody>
        </table>
    </div>
    this is part of table which is populated by data from database where isset($_POST['check'] gets the 'check' from:
    Code:
    echo 
        "<tr>
            <td><input type='checkbox' name='check[]' value='$id'>$name
          </td>
         </tr>";
    and form is closed down here

    </form>

    this "<br /><b>Notice</b>: Undefined variable: z in <b>D:\Xampp\htdocs\EMS2\event.php</b> on line <b>298</b><br />" appears in the text boxes.

    what am i doing wrong? thanks in advance!

  2. #2
    Join Date
    May 2014
    Posts
    24
    Try this one.
    from your codes..
    require "connection.php";
    $edit_id = (int)$edit_id;
    $sqls = mysql_query("SELECT * FROM event WHERE event_id = '$edit_id' ")
    try replacing this on your second line.
    $edit_id = intval($_GET['edit_id']);

  3. #3
    Join Date
    Apr 2014
    Posts
    10
    so it would be:
    Code:
    require "connection.php";
    $edit_id = intval($_GET['event_id']);
    $sqls = mysql_query("SELECT * FROM event WHERE event_id = '$edit_id' ")
    ?
    but it would be $_GET['event_id'] instead of $_GET['edit_id'] right?

  4. #4
    Join Date
    May 2014
    Posts
    24
    what do you get?
    what the browser displays?

  5. #5
    Join Date
    Apr 2014
    Posts
    10
    in the texbox <br /><b>Notice</b>: Undefined variable: z in <b>D:\Xampp\htdocs\EMS2\event.php</b> on line <b>274</b><br /> appears.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles