Page 2 of 2

Re: Populate field from database

Posted: Mon Oct 01, 2012 10:27 pm
by steve
Do you know how I can make the

Code: Select all

<div id='txtHint"></div>
fill a text box?

Code: Select all

  <tr>
    <td style="text-align:right" width="150">Recipients:</td>
      <td width="80%"><input type="text" name="custom18" size="40" maxlength="100" value="<?php echo txthint; ?>"<?php if (isset($_SESSION['as_custom18'])) {echo stripslashes(hesk_input($_SESSION['as_custom18']));} ?>" <?php if (in_array('custom18',$_SESSION['iserror'])) {echo ' class="isError" ';} elseif (in_array('email',$_SESSION['isnotice'])) {echo ' class="isNotice" ';} ?> /></td>
      </tr>

Re: Populate field from database

Posted: Tue Oct 02, 2012 5:33 pm
by inka
You can not echo txtHint since its not a variable and you probably get a big error :)

Unfortunately I do not know much JS, so I can`t help you much there...
But if you do not need an empty input box, you can echo out a complete input box with value :)

Code: Select all

<?php
$a=$_GET["q"];
function email($a){$dbc = @mysqli_connect('localhost', 'user', 'password', 'database');
$sql2="SELECT email FROM users WHERE id=$a";
$list2=mysqli_query($dbc,$sql2);
$row_list2=mysqli_fetch_assoc($list2);
$email=$row_list2['email'];
return $email;}
echo '<input type="text" value="' . email($a) . '"/>';
?>