Forum Moderators: coopster
His solution seems pretty smooth :
"foreach ($dd as $field=>$value)"
my thought was to do a case switch, but i don't know how to set that up, any ideas?
There's a way to get the type of the fields. Then for the text and blob fields you would put <textarea> Or just use the strlen and then case, or ifs.
However if you already know what structure the database has, then use a preformatted text and only add values dynamically.
That's my suggestion
Best regards
Michal Cibor
How about creating a data dictionary of sorts that keeps each column and it's related HTML <input> type in an associated row? Then when you read the column name in you link it to this *associate HTML <input> type* table and set the input type accordingly? A bit more complex than the loop you are currently using, but I'm not sure how else you might accomplish a similar task.
I'm trying to create a page that will let a user edit a mysql database. The fields I want to edit have mutliple lines and carriage returns.
I found some code that lets me fetch the fields ok, but I can't figure out how to have mulitple lines in the input box.
<form action="saveitem.php" method="get">
<input type="hidden" name="NewsID" value="<?php echo($NewsID)?>">
<table border="1" cellpadding="3" cellspacing="3">
<tr>
<td align="left">
<input name="NewsStory" type="text" value="<?php echo htmlspecialchars ($NewsStory)?>" />
</td>
</tr>
<tr>
<td align="left">
<input name="NewsDo" type="text" value="<?php echo htmlspecialchars ($NewsDo)?>" />
</td>
</tr>
</table>
<br>
<input type="submit" value="Save Entry">
<br>
<a href="delete.php?NewsID=<?php echo($NewsID)?>">Delete Entry</a>
</form>
<input name="NewsStory" type="textarea" value="<?php echo htmlspecialchars ($NewsStory)?>" />
With apologies for my previous example, it wasn't very complete. Also, keep in mind that the textarea does not expand till there is data in it. So if you define a textarea with 5 columns and 3 rows, it won't fill out that space until there is data in the space.