Jump to content

Recommended Posts

Hi all...

 

as you can gather from posting in this forum... i am very new to this... (PHP & MySQL)

 

But what i have is a site... that displays what computers we have in stock and for sale...

 

When stock items need to be changed... i tried to do an UPDATE by loading the current values into a form field as the initial values from the data in a MySQL table...

So far... My Select, Insert, Delete and Update are all working...

But when i load the page containing the form to be populated... it only loads the first word of the data...

look like a space is getting in the way...

 

But as i said... noobe...

 

-------------------------------

Troubled Code

<?php
include('config.php');
$id=$_GET['id'];
$query = "SELECT * FROM desktops WHERE id='$id'"; 	 
$result = mysql_query($query) or die(mysql_error());
while(
$row = mysql_fetch_array($result))
{
echo "<form id=desktops_update name=desktops_update action=desktops_update.php method=\"POST\">";
echo "<table width=800 border=0 cellspacing=0 cellpadding=0>";
echo "<tr>";
echo "<td width=378 rowspan=13 align=center valign=middle><strong>Quick Add Item </strong><br>";
echo "<img src=../images/Qadd-desktop.jpg width=200 height=161></td>";
echo "<tr>";
echo "<td><strong>ID:</strong></td>";
echo "<td><input name=id type=text id=id size=25 value=".$row[id]."></td>";
echo "</tr>";
echo "<td width=176><strong>Make:</strong></td>";
echo "<td width=246>";
echo "<input name=make type=text id=make size=25 value=".$row[make]."></td>";
echo "</tr>";
echo "<tr>";
echo "<td><strong>Model:</strong></td>";
echo "<td><input name=model type=text id=model size=25 value=".$row[model]."></td>";
echo "</tr>";
echo "<tr>";
echo "<td><strong>Code:</strong></td>";
echo "<td><input name=code type=text id=code size=25 value=".$row[code]."></td>";
echo "</tr>";
echo "<tr>";
echo "<td><strong>Proc:</strong></td>";
echo "<td><input name=proc type=text id=proc size=25 value=".$row[proc]."></td>";
	echo "</tr>";
	echo "<tr>";
	echo "<td><strong>Ram:</strong></td>";
   	echo "<td><input name=ram type=text id=ram size=25 value=".$row[ram]."></td>";
  	echo "</tr>";
	echo "<tr>";
  	echo "<td><strong>Hard Drive : </strong></td>";
  	echo "<td><input name=hdd type=text id=hdd size=25 value=".$row[hdd]."></td>";
  	echo "</tr>";
	echo "<tr>";
  	echo "<td><strong>Optical:</strong></td>";
	echo "<td><input name=optical type=text id=optical size=25 value=".$row[optical]."></td>";
	echo "</tr>";
	echo "<tr>";
	echo "<td><strong>License:</strong></td>";
	echo "<td><input name=lic type=text id=li size=25 value=".$row[lic]."></td>";
	echo "</tr>";
echo "<tr>";
	echo "<td><strong>Other:</strong></td>";
	echo "<td><input name=other type=text id=other size=25 value=".$row[other]."></td>";
	echo "</tr>";
	echo "<tr>";
	echo "<td><strong>Price:</strong></td>";
  	echo "<td><input name=price type=text id=price size=25 value=".$row[price]."></td>";
	echo "</tr>";
	echo "<tr>";
	echo "<td><strong>Admin Notes : </strong></td>";
  	echo "<td><input name=adminnote cols=25 rows=2 id=adminnote value=".$row[adminnote]."></textarea></td>";
  	echo "</tr>";
	echo "<tr>";
	echo "<td> </td>";
	echo "<td><input type=submit name=Submit value=\"Update Entry\" /></td>";
  	echo "</tr>";
	echo "</table>";
	echo "</form>";
							}
							?>

 

Any advise would be much appreciated...

I am stuck on this...

 

Thanks[/code]

Hi,

 

I would say that you need to quote the results that are placed in the form. For example:

 

   echo "<tr>";
   echo "<td><strong>ID:</strong></td>";
   echo "<td><input name=id type=text id=id size=25 value=\"".$row[id]."\"></td>";
   echo "</tr>";

 

Add the \" around the values and see what that does.

Cheers,

Darren.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.