bluedot Posted December 13, 2006 Share Posted December 13, 2006 Hey,Is it possable to have the contents of a database row be displayed as the initial value in a html form?somoething like:<input name="date" type="text" id="date" value="$row[date]" maxlength="30" />but of course html does not except $row[date] as a variable, it just prints "$row[date]"Thank you very much! Link to comment https://forums.phpfreaks.com/topic/30526-displaying-database-content-in-a-html-form/ Share on other sites More sharing options...
timmah1 Posted December 13, 2006 Share Posted December 13, 2006 depending on how your getting information, you can simply echo the variable[code]<? echo "$date"; ?>[/code] Link to comment https://forums.phpfreaks.com/topic/30526-displaying-database-content-in-a-html-form/#findComment-140520 Share on other sites More sharing options...
bluedot Posted December 13, 2006 Author Share Posted December 13, 2006 once agian... thank you.maybe i should like try taking a tutorial [i]before[/i] trying to program .... Link to comment https://forums.phpfreaks.com/topic/30526-displaying-database-content-in-a-html-form/#findComment-140523 Share on other sites More sharing options...
simcoweb Posted December 13, 2006 Share Posted December 13, 2006 I've used both methods and both work but i've had better success with this method coming from a 'while' loop:[code]<?phpwhile ($row = mysql_fetch_array($results)) { echo " [i](then place all your form fields here like in a table)[/i]<input type='text' size='40' name='URL' value='" . $row['URL'] . "'>?>[/code]Here's a full working example so you can see how the 'echo' displays everything:[code]<?phpecho "<form action='update.php' method='POST' name='updateProduct'><table width='780' border='0' bgcolor='#E1E1E1' padding='2'><tr><td> <table width='100%' border='0'> <tr> <td width='40%' bgcolor='#FFFFF'> <font class='bodytextbold'>Product URL: </td><td width='60%' bgcolor='#9AC5C5'><input type='text' size='40' name='URL' value='" . $row['URL'] . "'></td> </tr> <tr> <td width='40%' bgcolor='#FFFFF'> <font class='bodytextbold'>Product ID: </td><td width='60%' bgcolor='#9AC5C5'><input type='text' size='20' name='Product_ID' value='" . $row['Product_ID'] . "'></td> </tr> <tr> <td width='40%' bgcolor='#FFFFF'> <font class='bodytextbold'>Product Name: </td><td width='60%' bgcolor='#9AC5C5'><input type='text' size='20' name='Product_Name' value='" . $row['Product_Name'] . "'></td> </tr> <tr> <td width='40%' bgcolor='#FFFFF'> <font class='bodytextbold'>Price: </td><td width='60%' bgcolor='#9AC5C5'><input type='text' size='20' name='Price' value='" . $row['Price'] . "'></td> </tr> <tr> <td width='40%' bgcolor='#FFFFF'> <font class='bodytextbold'>Sale Price: </td><td width='60%' bgcolor='#9AC5C5'><input type='text' size='20' name='Sale_Price' value='" . $row['Sale_Price'] . "'></td> </tr> <tr> <td width='40%' bgcolor='#FFFFF'> <font class='bodytextbold'>Description: </td><td width='60%' bgcolor='#9AC5C5'><textarea cols='50' rows='5' name='Description' >" . $row['Description'] . "</textarea></td> </tr> <tr> <td width='40%' bgcolor='#FFFFF'> <font class='bodytextbold'>Category: </td><td width='60%' bgcolor='#9AC5C5'><input type='text' size='40' name='Category' value='" . $row['Category'] . "'></td> </tr> <tr> <td width='40%' bgcolor='#FFFFF'> <font class='bodytextbold'>Detail Image (full url): </td><td width='60%' bgcolor='#9AC5C5'><input type='text' size='60' name='Image' value='" . $row['Image'] . "'></td> </tr> <tr> <td width='40%' bgcolor='#FFFFF'> <font class='bodytextbold'>Postage: </td><td width='60%' bgcolor='#9AC5C5'><input type='text' size='20' name='Postage' value='" . $row['Postage'] . "'></td> </tr> <tr> <td width='40%' bgcolor='#FFFFF'> <font class='bodytextbold'>Brand: </td><td width='60%' bgcolor='#9AC5C5'><input type='text' size='20' name='Brand' value='" . $row['Brand'] . "'></td> </tr> <tr> <td width='40%' bgcolor='#FFFFF'> <font class='bodytextbold'>Availability: </td><td width='60%' bgcolor='#9AC5C5'><input type='text' size='20' name='Availability' value='" . $row['Availability'] . "'></td> </tr> <tr> <td width='40%' bgcolor='#FFFFF'> <font class='bodytextbold'>Thumbnail Image (full url): </td><td width='60%' bgcolor='#9AC5C5'><input type='text' size='60' name='Thumbnail' value='" . $row['Thumbnail'] . "'></td> </tr> <tr> <td width='40%' bgcolor='#FFFFF'> <font class='bodytextbold'>Thumbnail width: </td><td width='60%' bgcolor='#9AC5C5'><input type='text' size='20' name='ThumbnailWidth' value='" . $row['ThumbnailWidth'] . "'></td> </tr> <tr> <td width='40%' bgcolor='#FFFFF'> <font class='bodytextbold'>Thumbnail height: </td><td width='60%' bgcolor='#9AC5C5'><input type='text' size='20' name='ThumbnailHeight' value='" . $row['ThumbnailHeight'] . "'></td> </tr> <tr> <td><input type='submit' name='submit' value='Add Product'> <input type='reset' name='reset' value='Clear'></td> </tr> </table> </form> </p>";?>[/code] Link to comment https://forums.phpfreaks.com/topic/30526-displaying-database-content-in-a-html-form/#findComment-140529 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.