PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
shab620
Forum Commoner
Posts: 48 Joined: Tue Jan 18, 2005 7:50 pm
Post
by shab620 » Mon Feb 28, 2005 10:59 am
Hye
I've got a table which contains orders which have been placed. These orders are then viewed by the staff.
What my question is that I want to flag an order as completed once it is done by maybe having a check box next to each record which i can select as completed
Currently the orders are displayed in table format
Does anyone know how i might go about doing this?
Shab
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Mon Feb 28, 2005 11:07 am
pseudocode only output form start
query database for data
start output of table
output each record as a new table row with an added cell that has the 'completed' checkbox. This checkbox should be named similar to done[record_id] so it's easier to know which records to mark (and unmark) as done. If the record is marked as done in the database, make sure to display the checkbox checked..
end the table and form (don't forget a submit button in there!)
shab620
Forum Commoner
Posts: 48 Joined: Tue Jan 18, 2005 7:50 pm
Post
by shab620 » Mon Feb 28, 2005 11:11 am
Hye
Sort of understand the theory.
I havn't got a clue how to embed the check box in the table
Could you maybe give me a pointer or sample code?
Would really appreciate this,
Shab
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Mon Feb 28, 2005 11:16 am
Code: Select all
echo '<input type="checkbox" name="doneї' . $rowї'record_id'] . ']"' . ($rowї'done'] == 1 ? ' checked="checked"' : '') . ' />';
shab620
Forum Commoner
Posts: 48 Joined: Tue Jan 18, 2005 7:50 pm
Post
by shab620 » Mon Feb 28, 2005 11:30 am
Hye
I'm not understanding this very well
I've put the code under the table output but it outputs it ontop of the table, there are four records in the table and four check boxes are displayed.
Plus i dont understand how i will update the record in the table?
the code is as follows
Code: Select all
<html>
<body>
<?
$hostname="localhost";
$mysql_login="root";
$mysql_password="*******";
$database="coachhouse";
$connect = mysql_connect("$hostname", "$mysql_login" , "$mysql_password");
$table_name = "emp_order";
mysql_select_db($database);
echo "<table width="700" height="85" cellpadding="0" border="1" cellspacing="0">";
echo "<tr><td> Order id</td><td> Item Description</td><td> Quantity</td><td> Comments</td><td> username</td>";
$result = mysql_query ("SELECT * FROM emp_order",$connect);
while ($row = mysql_fetch_assoc($result))
{
$id= $rowї'order_id'];
$item_description= $rowї'item_description'];
$quantity= $rowї'quantity'];
$comments= $rowї'comments'];
$user_name= $rowї'user_name'];
echo "<tr><td>". $id . " </td><td> " .$item_description. " </td><td>". $quantity . "</td><td>". $comments . "</td><td> " .$user_name. " </td>";
echo '<input type="checkbox" name="doneї' . $rowї'Order_id'] . ']"' . ($rowї'done'] == 1 ? ' checked="checked"' : '') . ' />';
}
echo "</table>";
mysql_close($connect);
?>
</table></body></HTML>
Do you have any ideas?????
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Mon Feb 28, 2005 11:32 am
you are echoing the checkboxes outside of a table cell.
shab620
Forum Commoner
Posts: 48 Joined: Tue Jan 18, 2005 7:50 pm
Post
by shab620 » Mon Feb 28, 2005 11:37 am
Hye
I've tried putting it in the table cells but have parse errors
Could you maybe just show me where it should go??
Would Really appreciate this, I am quite stuck with this now
Shab
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Mon Feb 28, 2005 11:43 am
I will not do it for you.
What did you try that created errors?
shab620
Forum Commoner
Posts: 48 Joined: Tue Jan 18, 2005 7:50 pm
Post
by shab620 » Mon Feb 28, 2005 11:45 am
I tried the following and had the following parsing errors:
Parse error: parse error, expecting `','' or `';'' in c:\web\currentorder.php on line 28
The code is as follows
Code: Select all
<html>
<body>
<?
$hostname="localhost";
$mysql_login="root";
$mysql_password="cavalier1";
$database="coachhouse";
$connect = mysql_connect("$hostname", "$mysql_login" , "$mysql_password");
$table_name = "emp_order";
mysql_select_db($database);
echo "<table width="700" height="85" cellpadding="0" border="1" cellspacing="0">";
echo "<tr><td> Order id</td><td> Item Description</td><td> Quantity</td><td> Comments</td><td> username</td>";
$result = mysql_query ("SELECT * FROM emp_order",$connect);
while ($row = mysql_fetch_assoc($result))
{
$id= $rowї'order_id'];
$item_description= $rowї'item_description'];
$quantity= $rowї'quantity'];
$comments= $rowї'comments'];
$user_name= $rowї'user_name'];
echo "<tr><td>". $id . " </td><td> " .$item_description. " </td><td>". $quantity . "</td><td>". $comments . "</td><td> " .$user_name. " </td>
<td>'<input type="checkbox" name="doneї' . $rowї'Order_id'] . ']"' . ($rowї'done'] == 1 ? ' checked="checked"' : '') . ' />'</td>";
}
echo "</table>";
mysql_close($connect);
?>
</table></body></HTML>
Line 28 is the chack box line code
Do you have any ideas why it is failing???
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Mon Feb 28, 2005 11:46 am
you placed a single quote string (that uses double quotes) inside a double quote string.
shab620
Forum Commoner
Posts: 48 Joined: Tue Jan 18, 2005 7:50 pm
Post
by shab620 » Mon Feb 28, 2005 1:12 pm
Hye
I'm not having much luck with this approach is.
Does anyone have any ideas why it won't format correctly????
Shab
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Mon Feb 28, 2005 1:14 pm
n00b Saibot
DevNet Resident
Posts: 1452 Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:
Post
by n00b Saibot » Tue Mar 01, 2005 12:17 am
Correct your echo...
Code: Select all
echo "<tr><td>".$id."</td><td>".$item_description."</td><td>". $quantity."</td><td>".$comments."</td><td>".$user_name."</td>
<td><input type="checkbox" name="doneї".$rowї'Order_id']."]"". ($rowї'done'] == 1 ? " checked="checked"" : "")."/></td>";
}
shab620
Forum Commoner
Posts: 48 Joined: Tue Jan 18, 2005 7:50 pm
Post
by shab620 » Tue Mar 01, 2005 12:41 pm
Hye nOOB Saibot
I'll try that and let you know what happens.
Thanks for the suggestion
Shab