sql - Result of SELECT statement as Input Value PHP -
i have query echos results of row...
<?php $sql = "select dba_name, contact_owner, phone, confirmation_code, physical_address, physical_city, physical_state, physical_zip, urep mpas"; $result = $conn->query($sql); ?>
later, echo results user see...
<?php if ($result->num_rows > 0) { while($row = $result->fetch_assoc()) { echo "<strong>confirmation code: " . $row["confirmation_code"]. "<br></strong>"; ..... ?>
further in code, want use same result value of hidden field. i've tried few things no success. value blank/empty. here's recent attempt.
<?php echo "<input hidden name='confc' value='".$row['confirmation_code']."'>" ; ?>
i'm sure it's simple not doing, hoping can me out. i've tried looking around web answer, having hard time coming answer applies specific issue.
i'm pretty you've done query in meantime (and if haven't, you're not looping anything). try this:
<?php $codes = array(); if ($result->num_rows > 0) { while($row = $result->fetch_assoc()) { $codes[] = $row['confirmation_code']; echo "<strong>confirmation code: " . $row["confirmation_code"]. "<br></strong>"; ..... foreach ($codes $c) { echo "<input type='hidden' name='confc' value='".$c."'>" ; } ?>
note if multiple rows back, you're going 1 confc
value (the last one). if that's want, great guess (although use string rather array). if not, you'll have put identifying number on name of hidden:
foreach ($codes $k=>$c) { echo "<input type='hidden' name='confc".$k."' value='".$c."'>" ; }
Comments
Post a Comment