Log in

View Full Version : updating data



SawnDiddle
03-05-2008, 02:28 AM
ok, i have a fairly simple program.
http://www.newsalesparadigm.com/expediter/clientlist.php

http://www.newsalesparadigm.com/expediter/updateclient.php?id=1

As you can see, if anything besides "Comments" is more than one word, they don't show but the first word.

<?php
include 'config.php';
include 'opendb.php';

$sID = $_GET['id'];
$sSTEP = $_GET['step'];
?>
Some html here.

<?php

if(isset($_POST['add']))
{

$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$business = $_POST['business'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$address = $_POST['address'];
$city = $_POST['city'];
$state = $_POST['state'];
$zip = $_POST['zip'];
$country = $_POST['country'];
$step = $_POST['step'];
$comments = $_POST['comments'];

$query = "UPDATE clients SET firstname='$firstname', lastname='$lastname', business='$business', phone='$phone', email='$email', address='$address', city='$city', state='$state', zip='$zip', country='$country', step='$step', comments='$comments' WHERE id=$sID";
mysql_query($query);
}

$query = "SELECT firstname, lastname, business, phone, email, address, city, state, zip, country, comments FROM clients WHERE id=$sID";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
include 'closedb.php';

?>
<form method=post>
<input name="firstname" type="text" id="firstname" value=<?php echo "{$row['firstname']}"; ?> size="13" />&nbsp;
<input name="lastname" type="text" id="lastname" value=<?php echo "{$row['lastname']}"; ?> size="13" />
<input name="business" type="text" id="business" value=<?php echo "{$row['business']}"; ?> size="33" />
<input name="phone" type="text" id="phone" value=<?php echo "{$row['phone']}"; ?> size="33" />
<input name="email" type="text" id="email" value=<?php echo "{$row['email']}"; ?> size="33" />
<input name="address" type="text" id="address" value=<?php echo "{$row['address']}"; ?> size="33" />
<input name="city" type="text" id="city" value=<?php echo "{$row['city']}"; ?> size="19" />&nbsp;
<input name="state" type="text" id="state" value=<?php echo "{$row['state']}"; ?> size="7" />
<input name="zip" type="text" id="zip" value=<?php echo "{$row['zip']}"; ?> size="13" />&nbsp;
<input name="country" type="text" id="country" value=<?php echo "{$row['country']}"; ?> size="13" />
<textarea name="comments" id="comments" cols="26" rows="4" wrap="virtual"><?php echo "{$row['comments']}"; ?></textarea>
<br />
<input name="add" id="add" type="submit" value="SAVE" />
<?php

if(isset($_POST['add']))
{
echo "Updated";
}
?>
</form>


MOD EDIT: Use [php] tags.

Jas
03-06-2008, 02:05 AM
It took me a second to under stand the problem, but I think I get it.

Change this:

<form method=post>
<input name="firstname" type="text" id="firstname" value=<?php echo "{$row['firstname']}"; ?> size="13" />&nbsp;
<input name="lastname" type="text" id="lastname" value=<?php echo "{$row['lastname']}"; ?> size="13" />
<input name="business" type="text" id="business" value=<?php echo "{$row['business']}"; ?> size="33" />
<input name="phone" type="text" id="phone" value=<?php echo "{$row['phone']}"; ?> size="33" />
<input name="email" type="text" id="email" value=<?php echo "{$row['email']}"; ?> size="33" />
<input name="address" type="text" id="address" value=<?php echo "{$row['address']}"; ?> size="33" />
<input name="city" type="text" id="city" value=<?php echo "{$row['city']}"; ?> size="19" />&nbsp;
<input name="state" type="text" id="state" value=<?php echo "{$row['state']}"; ?> size="7" />
<input name="zip" type="text" id="zip" value=<?php echo "{$row['zip']}"; ?> size="13" />&nbsp;
<input name="country" type="text" id="country" value=<?php echo "{$row['country']}"; ?> size="13" />
<textarea name="comments" id="comments" cols="26" rows="4" wrap="virtual"><?php echo "{$row['comments']}"; ?></textarea>
<br />
<input name="add" id="add" type="submit" value="SAVE" />
To this:

<form method="post">
<input name="firstname" type="text" id="firstname" value="<?php echo "{$row['firstname']}"; ?>" size="13" />&nbsp;
<input name="lastname" type="text" id="lastname" value="<?php echo "{$row['lastname']}"; ?>" size="13" />
<input name="business" type="text" id="business" value="<?php echo "{$row['business']}"; ?>" size="33" />
<input name="phone" type="text" id="phone" value="<?php echo "{$row['phone']}"; ?>" size="33" />
<input name="email" type="text" id="email" value="<?php echo "{$row['email']}"; ?>" size="33" />
<input name="address" type="text" id="address" value="<?php echo "{$row['address']}"; ?>" size="33" />
<input name="city" type="text" id="city" value="<?php echo "{$row['city']}"; ?>" size="19" />&nbsp;
<input name="state" type="text" id="state" value="<?php echo "{$row['state']}"; ?>" size="7" />
<input name="zip" type="text" id="zip" value="<?php echo "{$row['zip']}"; ?>" size="13" />&nbsp;
<input name="country" type="text" id="country" value="<?php echo "{$row['country']}"; ?>" size="13" />
<textarea name="comments" id="comments" cols="26" rows="4" wrap="virtual"><?php echo "{$row['comments']}"; ?></textarea>
<br />
<input name="add" id="add" type="submit" value="SAVE" />

The value needs to be placed in quotes (").

<input type="text" value=john smith>
<!--the value is john; the tag thinks smith is another property//-->

<input type="text" value="john smith">
<!--the value is john smith//-->

SawnDiddle
03-06-2008, 02:15 AM
thank you. This fixed it big time.