php - textbox array only dispalying 1st word of a string from database -
i having subject table in mysql database value retrieving in php page textbox array. while retrieving showing 1st word of string in textbox. example -- subject name "intro c" in textbox showing "intro". pls see code reference --
<table width="400" border="1"> <tr> <td colspan="4" valign="top"><div align="center" class="style4">subject(s) details</div></td> </tr> <tr> <td width="87"><strong><span class="style1">select </span></strong></td> <td width="87"><strong><span class="style1">subject id </span></strong></td> <td width="270"><strong><span class="style1">subject name </span></strong></td> </tr> <?php $i=0; $result = mysql_query("select sub_id,sub_name subject crs_id='$cid' , sem_id='$smid' order sub_id asc") or die(mysql_error()); while($row = mysql_fetch_array($result)) { ?> <tr> <td><span class="style1"><?php echo "<input name=t1[] type=checkbox value=".$i." checked />"; ?></span></td> <td><span class="style1"><?php echo "<input name=t2[] size=15 type=text value=".$row['sub_id']." />"; ?></span></td> <td><span class="style1"><?php echo "<input name=t3[] size=30 type=text value=".$row['sub_name']." />"; ?></span></td> </tr> <?php $i++; } ?> <tr> <td colspan="4"><div align="center"><input name="submit" type="submit" value="update subject(s)" /> </div></td> </tr> </table>
if actual code, you'll need wrap database values inside of single quotes '
:
<?php echo "<input name=t3[] size=30 type=text value='".$row['sub_name']."' />"; ?>
if not, html interpreted as:
<input name=t3[] size=30 type=text value=intro c />
by way, best practice html attributes:
<?php echo "<input name='t3[]' size='30' type='text' value='".$row['sub_name']."' />"; ?>
results in:
<input name='t3[]' size='30' type='text' value='intro c' />
Comments
Post a Comment