3 Replies - 986 Views - Last Post: 21 May 2014 - 03:43 AM Rate Topic: -----

#1 noobydoods   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 124
  • Joined: 21-May 14

Get data from database and display in text box

Posted 21 May 2014 - 03:25 AM

hi guys, i want to get data from database according to check box and display that data into text box.

process is done in same page as html above <!DOCTYPE html>:
if(isset($_POST['edit_event']) && isset($_POST['check']))
{
    require "connection.php";
    $user_id = $_SESSION['sess_user_id'];
    foreach ($_POST['check'] as $edit_id) 
    {
	$edit_id = (int)$edit_id;
	$sqls = "SELECT event_name,start_date,start_time,end_date,end_time,event_venue FROM event WHERE event_id IN $edit_id AND user_id = $user_id";
	$boo = mysqli_query($con, $sqls);
	
	$z = mysqli_fetch_array($boo, MYSQLI_ASSOC);
	$en_ = $z['event_name'];
        $esD = $z['start_date'];
	$esT = $z['start_time'];
	$eeD = $z['end_date'];
	$eeT = $z['end_time'];
	$ev_ = $z['event_venue'];	
	
    }
}



the form:
<form class="forms" method="post" action="event.php">	
<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 class="e"><input type="text" name="en_" value="<?php echo $en_; ?>" required></td></tr>
	<tr><td class="e"><p id="date"><input type="text" name="dates_" value="<?php echo $esD; ?>" required />&nbsp;&nbsp;&nbsp;<input type="text" name="times_" value="<?php echo $esT; ?>" required /></p></td></tr>
	<tr><td class="e"><p id="date"><input type="text" name="datee_" value="<?php echo $eeD; ?>" required />&nbsp;&nbsp;&nbsp;<input type="text"  name="time_" class="time end" value="<?php echo $eeT ?>" required /></p></td></tr>
	<tr><td class="e"><input type="text" name="ev_" class="ev_" value="<?php echo $ev_; ?>" required /></td></tr>
	<tr><td class="ef"><input type="submit" name="update" value="Update Event" id="update" />&nbsp;&nbsp;&nbsp;<input type="submit" id="cancelupdate" name="cancel" value="Cancel" /></td></tr>
      </tbody>
</table>
</div></form>



this warning appears in the text boxes respectively:
<br /><b>Notice</b>:  Undefined variable: en_ in <b>C:\Xampp\htdocs\EMS2\event.php</b> on line <b>296</b><br />


im wondering if the coding itself is wrong or is it because the
<div id="doverlay" class="doverlay"></div>
<div id="ddialog" class="ddialog">
hides the form and it only appears when edit_event button is clicked ?

Is This A Good Question/Topic? 0
  • +

Replies To: Get data from database and display in text box

#2 Dormilich   User is offline

  • 痛覚残留
  • member icon

Reputation: 4278
  • View blog
  • Posts: 13,563
  • Joined: 08-June 10

Re: Get data from database and display in text box

Posted 21 May 2014 - 03:37 AM

itís even more simple. you create the variable $en_ only if there is a (certain) POST request (when the form submits), but you use it on every request to that page (e.g. initial request via GET).
Was This Post Helpful? 0
  • +
  • -

#3 noobydoods   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 124
  • Joined: 21-May 14

Re: Get data from database and display in text box

Posted 21 May 2014 - 03:40 AM

im sorry i don't understand.
Was This Post Helpful? 0
  • +
  • -

#4 Dormilich   User is offline

  • 痛覚残留
  • member icon

Reputation: 4278
  • View blog
  • Posts: 13,563
  • Joined: 08-June 10

Re: Get data from database and display in text box

Posted 21 May 2014 - 03:43 AM

letís look at a simplified example:
// produces the same error
if (false) {
    $en_ = "foo";
}
echo $en_;


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1