Want to flag an order as completed-How do i do this?????

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

Post Reply
shab620
Forum Commoner
Posts: 48
Joined: Tue Jan 18, 2005 7:50 pm

Want to flag an order as completed-How do i do this?????

Post 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

:) :)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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!)
shab620
Forum Commoner
Posts: 48
Joined: Tue Jan 18, 2005 7:50 pm

Post 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
:? :?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Code: Select all

echo '<input type="checkbox" name="done&#1111;' . $row&#1111;'record_id'] . ']"' . ($row&#1111;'done'] == 1 ? ' checked="checked"' : '') . ' />';
shab620
Forum Commoner
Posts: 48
Joined: Tue Jan 18, 2005 7:50 pm

Post 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))

&#123;

$id= $row&#1111;'order_id'];
$item_description= $row&#1111;'item_description'];
$quantity= $row&#1111;'quantity'];
$comments= $row&#1111;'comments'];
$user_name= $row&#1111;'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&#1111;' . $row&#1111;'Order_id'] . ']"' . ($row&#1111;'done'] == 1 ? ' checked="checked"' : '') . ' />'; 
&#125; 

echo "</table>"; 

mysql_close($connect);
?> 
</table></body></HTML>
Do you have any ideas?????
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

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 »

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
:?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

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 »

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))

&#123;

$id= $row&#1111;'order_id'];
$item_description= $row&#1111;'item_description'];
$quantity= $row&#1111;'quantity'];
$comments= $row&#1111;'comments'];
$user_name= $row&#1111;'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&#1111;' . $row&#1111;'Order_id'] . ']"' . ($row&#1111;'done'] == 1 ? ' checked="checked"' : '') . ' />'</td>"; 
&#125; 

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???

:?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

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 »

Hye

I'm not having much luck with this approach is.

Does anyone have any ideas why it won't format correctly????

Shab
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post 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&#1111;".$row&#1111;'Order_id']."]"". ($row&#1111;'done'] == 1 ? " checked="checked"" : "")."/></td>"; 
&#125;
shab620
Forum Commoner
Posts: 48
Joined: Tue Jan 18, 2005 7:50 pm

Post by shab620 »

Hye nOOB Saibot

I'll try that and let you know what happens.

Thanks for the suggestion

Shab :D :D
Post Reply