Jump to content

Problems setting value on a input type=text


Scrier

Recommended Posts

I have a problem with the following code:

		$getitemquery=mysql_query("SELECT * FROM tradeitems WHERE itemid='".$_GET['itemid']."'");		$getitem=mysql_fetch_array($getitemquery);		echo "			<div class=\"header\">				<h1>EDIT AN TRADEITEM</h1>		";		echo "				<form name=additem method=post action=addtradeitem.php?action=edit&itemid=".$_GET['itemid'].">					<table border=0>						<tr>							<td width=150>Item name:</td>							<td><input type=text name=itemname size=60 value=".$getitem['itemname']."></td>						</tr>

that if the name contains a space character (" "), it only shows the first part of the name, like George Bush only displays as George. I guess I need to replace space with some symbol but well, i'm kinda limited in my knowledge of html and why the value is not showing correctly.

Link to comment
Share on other sites

huh? No you dont... anyways, im guessing your talking selecting from the url or something? If you want spaces in things like tables or something the char. code is %20, so just use one of those for one space. But where are you getting this error at?, that code is only for spaces in the url.

Link to comment
Share on other sites

No it is not in the url but in the form.

	   $getitemquery=mysql_query("SELECT * FROM tradeitems WHERE itemid='".$_GET['itemid']."'");		$getitem=mysql_fetch_array($getitemquery);		  ...							<td><input type=text name=itemname size=60 value=".$getitem['itemname']."></td>						</tr>

Error.GIFThere is an example where it should say Lady Elizabeth... but it shops down the string to only the first word if I have spaces.nm.. I found out what it was. I forgot to put the string inside '' like this

							<td><input type=text name=itemname size=60 value='".$getitem['itemname']."'></td>

Link to comment
Share on other sites

	   $getitemquery=mysql_query("SELECT * FROM tradeitems WHERE itemid='".$_GET['itemid']."'");		$getitem=mysql_fetch_array($getitemquery);		echo "			<div class=\"header\">				<h1>EDIT AN TRADEITEM</h1>		";		echo "				<form name=additem method=post action=addtradeitem.php?action=edit&itemid=".$_GET['itemid'].">					<table border=0>						<tr>							<td width=150>Item name:</td>							<td><input type=\"text\" name=\"itemname\" size=\"60\" value=\"".$getitem['itemname']."\"></td>						</tr>

That should do it.

Link to comment
Share on other sites

Oh, forgot qoutes, lol I hate when that happens. FYI: you might want to try and always add quotes, 1. its valid html 2. If you dont it causes errors like this3. Its alot easier to read

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...