Hi, new to php and mySql, I have two issues when retriving data from a table.
1: I'm getting my data back into form fields to allow update (See Screen shot) where I have an empty cell in the row i get a back "/"?
2. Where i have more than one word in the cell "Adam Smith" I just get the first word returned?
Any help would be great
<?
$username="mydetails";
$password="mydetails";
$database="mydetails";
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM cbs WHERE orderNumber='$_POST[jobid]'";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
$i=0;
while ($i < $num) {
$name=mysql_result($result,$i,"name");
$orderNumber=mysql_result($result,$i,"orderNumber");
$dateReceived=mysql_result($result,$i,"dateReceived");
$dateRequired=mysql_result($result,$i,"dateRequired");
$jobNumber=mysql_result($result,$i,"jobNumber");
$description=mysql_result($result,$i,"description");
$quantity=mysql_result($result,$i,"quantity");
$size=mysql_result($result,$i,"size");
$artworkReceived=mysql_result($result,$i,"artworkReceived");
$artworkSent=mysql_result($result,$i,"artworkSent");
$artworkApproved=mysql_result($result,$i,"artworkApproved");
$despatched=mysql_result($result,$i,"despatched");
$delivered=mysql_result($result,$i,"delivered");
$status=mysql_result($result,$i,"status");
$comments=mysql_result($result,$i,"comments");
?>
<div id="Heading">
<p><span id="Heading">CBS PRODUCTION DATA<br />
</span></p>
<div id="Form">
<form id="form1" name="form1" method="post" action="update.php">
<div id="form">
<table width="376">
<tr>
<td>Name:</td>
<td> </td>
<td><input name="name" type="text" id="name" value=<? echo $name; ?> /></td>
</tr>
<tr>
<td>Order Number:</td>
<td> </td>
<td><input type="text" name="orderNumber" id="orderNumber" value=<? echo $orderNumber; ?> /></td>
</tr>
<tr>
<td>Date Received:</td>
<td> </td>
<td><input type="text" name="dateReceived" id="dateReceived" value=<? echo $dataReceived; ?> /></td>
</tr>
<tr>
<td>Date Required:</td>
<td> </td>
<td><input type="text" name="dateRequired" id="dateRequired" value=<? echo $dateRequired; ?> /></td>
</tr>
<tr>
<td>Fosco Job Number:</td>
<td> </td>
<td><input type="text" name="jobNumber" id="jobNumber" value=<? echo $jobNumber; ?> /></td>
</tr>
<tr>
<td>Description:<br /></td>
<td> </td>
<td><input type="text" name="description" id="description" value=<? echo $description; ?> /></td>
</tr>
<tr>
<td>Quantity:</td>
<td> </td>
<td><input type="text" name="quantity" id="quantity" value=<? echo $quantity; ?> /></td>
</tr>
<tr>
<td>Size:</td>
<td> </td>
<td><input type="text" name="size" id="size" value=<? echo $size; ?> /></td>
</tr>
<tr>
<td>Artwork Received:</td>
<td> </td>
<td><input type="text" name="artworkReceived" id="artworkReceived" value=<? echo $artworkReceived; ?> /></td>
</tr>
<tr>
<td>Artwork sent for Approval:</td>
<td> </td>
<td><input type="text" name="artworkSent" id="artworkSent" value=<? echo $artworkSent; ?> /></td>
</tr>
<tr>
<td>Artwork Approved:</td>
<td> </td>
<td><input type="text" name="artworkApproved" id="artworkApproved" value=<? echo $artworkApproved; ?> /></td>
</tr>
<tr>
<td>Job Despatched:</td>
<td> </td>
<td><input type="text" name="despatched" id="despatched" value=<? echo $despatched; ?> /></td>
</tr>
<tr>
<td>Job Delivered:</td>
<td> </td>
<td><input type="text" name="delivered" id="delivered" value=<? echo $delivered; ?> /></td>
</tr>
<tr>
<td>Status:</td>
<td> </td>
<td><input type="text" name="status" id="status" value=<? echo $status; ?> /></td>
</tr>
<tr>
<td>Comments:</td>
<td> </td>
<td><input type="text" name="comments" id="comments" value=<? echo $comments; ?> /></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><input type="submit" name="submit" id="submit" value="Submit" /></td>
</tr>
</table>
</div>
</form>
</div>
</div>
<?
$i++;
}
beginner Help
Moderator: General Moderators
-
honkmaster
- Forum Newbie
- Posts: 12
- Joined: Mon Feb 15, 2010 12:10 pm
beginner Help
- Attachments
-
- Screen shot 2010-02-15 at 18.15.01.png (31.96 KiB) Viewed 5178 times
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: beginner Help
Quote the values in your input tags.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Re: beginner Help
And you need to run `htmlentities()` on all the values before you echo them.
What does your source say? It might have some chars that need to be escaped.
What does your source say? It might have some chars that need to be escaped.
-
honkmaster
- Forum Newbie
- Posts: 12
- Joined: Mon Feb 15, 2010 12:10 pm
Re: beginner Help
Thanks for Help and sorry for Triple post.AbraCadaver wrote:Quote the values in your input tags.
Can you show me an example of "Quote the values in your input tags"
Cheers
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: beginner Help
Thought it was self explanatory, but notice the quotes around the value in the input tag:honkmaster wrote:Thanks for Help and sorry for Triple post.AbraCadaver wrote:Quote the values in your input tags.
Can you show me an example of "Quote the values in your input tags"
Cheers
Code: Select all
<input name="name" type="text" id="name" value="<? echo $name; ?>" />mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
-
honkmaster
- Forum Newbie
- Posts: 12
- Joined: Mon Feb 15, 2010 12:10 pm
Re: beginner Help
Thank you very much, worked perfectlyAbraCadaver wrote:Thought it was self explanatory, but notice the quotes around the value in the input tag:honkmaster wrote:Thanks for Help and sorry for Triple post.AbraCadaver wrote:Quote the values in your input tags.
Can you show me an example of "Quote the values in your input tags"
Cheers
Code: Select all
<input name="name" type="text" id="name" value="<? echo $name; ?>" />
Cheers Chris