Page 1 of 1
Want to flag an order as completed-How do i do this?????
Posted: Mon Feb 28, 2005 10:59 am
by shab620
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

Posted: Mon Feb 28, 2005 11:07 am
by feyd
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!)
Posted: Mon Feb 28, 2005 11:11 am
by shab620
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

Posted: Mon Feb 28, 2005 11:16 am
by feyd
Code: Select all
echo '<input type="checkbox" name="doneї' . $rowї'record_id'] . ']"' . ($rowї'done'] == 1 ? ' checked="checked"' : '') . ' />';
Posted: Mon Feb 28, 2005 11:30 am
by shab620
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?????
Posted: Mon Feb 28, 2005 11:32 am
by feyd
you are echoing the checkboxes outside of a table cell.
Posted: Mon Feb 28, 2005 11:37 am
by shab620
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

Posted: Mon Feb 28, 2005 11:43 am
by feyd
I will not do it for you.
What did you try that created errors?
Posted: Mon Feb 28, 2005 11:45 am
by shab620
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???

Posted: Mon Feb 28, 2005 11:46 am
by feyd
you placed a single quote string (that uses double quotes) inside a double quote string.
Posted: Mon Feb 28, 2005 1:12 pm
by shab620
Hye
I'm not having much luck with this approach is.
Does anyone have any ideas why it won't format correctly????
Shab
Posted: Mon Feb 28, 2005 1:14 pm
by feyd
Posted: Tue Mar 01, 2005 12:17 am
by n00b Saibot
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>";
}
Posted: Tue Mar 01, 2005 12:41 pm
by shab620
Hye nOOB Saibot
I'll try that and let you know what happens.
Thanks for the suggestion
Shab
