/    Sign up×
Community /Pin to ProfileBookmark

Edit a MySQL Field in PHP not using textarea

Hi all

This seems relatively easy but the only way I can get it to work is using a text area.

Basically I display a query from the Customer table, then the user clicks ‘Update Account’ and this shows the same query this time with editable fields.

However I can only show editable fields using textarea rather then just a text box, and its making my form look hideous as the textareas have the scroll bars etc even though i tried specifying 1 row.

[code=php]<textarea name=”address1″ cols=”60″ type=”text” rows=”1″ size=”100″ maxlength=”100″><?PHP echo $address1; ?></textarea>[/code]

This isn’t a major issue, but im sure im missing something obvious.

Thanks

Im also trying to display the customers image from their record incase they want to change it – like a avatar…. does this have to be done specially?

to post a comment
PHP

9 Comments(s)

Copy linkTweet thisAlerts:
@Daniel_TOct 13.2005 — &lt;input type="text" name="address1" maxlength="100" value="&lt;?PHP echo $address1; ?&gt;" /&gt;Should be all there is to it...
Copy linkTweet thisAlerts:
@on_lookerauthorOct 13.2005 — Ahhhh ?

You don't want to know what I was trying!


Thanks a lot
Copy linkTweet thisAlerts:
@Daniel_TOct 13.2005 — Lol, I have a guess ?&lt;input type="text" name="address1" maxlength="100"&gt;&lt;?PHP echo $address1; ?&gt;&lt;/input&gt;Am I right? Hm? Hm?
Copy linkTweet thisAlerts:
@on_lookerauthorOct 13.2005 — :rolleyes:

Shhh everyone will hear you, I give myself 5 points for trying though.

That little text box is the least of my worries at the moment ?
Copy linkTweet thisAlerts:
@on_lookerauthorOct 13.2005 — I have a products form where I am trying to do the same thing, show editable fields for updating.

I used the previous code but its not showing anything like the other one is, is it because the while loop is a object? The query below is the same query I use to display the products table, so I know it works...
[code=php]
if ($_REQUEST['ModifyProduct']=='yes')
{
//request productid from the modify product link
$productid = $_REQUEST['productid'];

//Display record with editable fields
$resultmodify = mysql_query('SELECT * FROM product WHERE ProductID = ' . $productid)
or die("Can't perform query");

//while loop to show all results (objects)
While($row=mysql_fetch_object($resultmodify))
{
//table with input code as shown below
[/code]

Heres what im using, the output is just a text area, no data inside.

[code=php]<input name="name2" type="text" value="<?PHP echo $row->$ProductName2; ?>" size="60" maxlength="100" />[/code]
?

And when I do the following code, I can see the productID but not the name.... Which makes me wonder if the query is even working.... (i have a ProductName and a ProductName2).
[code=php]
<?php echo "Product ID: " . $productid . "Product Name: " . $productname; ?>
[/code]
Copy linkTweet thisAlerts:
@Daniel_TOct 13.2005 — I'm not sure how conditionals respond to objects, but it may be because you're using a variable sign ($) in front of an object's variable. It should look like this:[code=php]<input name="name2" type="text" value="<?PHP echo $row->ProductName2; ?>" size="60" maxlength="100" /> [/code](with no $ in front of ProductName2)
Copy linkTweet thisAlerts:
@on_lookerauthorOct 16.2005 — Ahh sorry, yes your right. Thanks!

Ive never done object querys before and didn't think to try that.

How do you show a image filename?
Copy linkTweet thisAlerts:
@LiLcRaZyFuZzYOct 16.2005 — do you have the image path in the database?
Copy linkTweet thisAlerts:
@on_lookerauthorOct 16.2005 — Im actually storing the files in the database (ive heard all the pro's and con's but this is the way im doing it).

I just want to show the file name, because at the moment when I echo it, it shows all the binary code.

I dont want to show the actual image either, this section displays all the information for modifying so I will proberly have a link next to the image name with the option to upload a new image.

I have looked at various scripts, but most of them are for uploading.... eg. [filetype][filename]....

This must be possible some how.
×

Success!

Help @on_looker spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...