Frank Miller wrote:

>          I'm working on a project here at our university and need a little.  We 
>installed a wireless network and bought 5 ipaq's to use and experiment with.  I wrote 
>a work order system that we are still using. Basically the tech guys want to be able 
>to check WO from the ipaq's and if they finish them fill in a check box and have it 
>be updated in the WO database and not be displayed on the open or uncompleted work 
>order page. I can do everything except when the completed box is filled I can't get 
>it to fill in the database. Below is the code I'm using. Keep in mind it is being 
>displayed on a ipaq so the headings are brief. Also I'm working on my local computer 
>before it is put in production. Any help would be appreciated.
>
>

Frank,

I can't see anything obviously wrong with your code, but it's a bit hard to follow.

In general I tend to do all processing in a script first before writing any output so 
you get something like:

if (isset($submit))
{
   ... sql updates ....
}
... sql selects .... e.g. $cursor=mysql_query("....");

<HTML>
<BODY>
.... header....

...form start....

while ($row = mysql_fetch_array($cursor))
{
   print ' per row html '.$row[value1] etc.
}

...form end...
... footer stuff....
</HTML>

A big advantage of this is that if you do hit an error during your SQL stuff, then
you can redirect straight to an error page without having to worry about
"headers already sent" messages.  A secondary advantage is that if you do
your updates first, you can just let the normal select code run so after every
update the form just returns with the new values of data without another stage
of selection.

Anyway, back to the problem, it looks as if you'll need some traces to find out
what is actually happening.  First of all I'd suggest you just print your query
string before executing it, then you can have a look and see what it's actually
trying to do.  Most likely it either is never getting to the query or no value set
in $checkbox[0].

I guess (!$HTTP_POST_VARS['submit']) works, but I always
go for a named submit e.g. type=submit name=update, and an explicit isset check
if isset($update) etc.  I also wonder why you look for submit in HTTP_POST_VARS
but pick up $checkbox[0] directly.

As your code stands I guess they can only check one box at once.  Have you
considered a foreach($checkbox as $orderno) loop for the updates?  Personally,
after very unpleasant experiences with early Internet Explorers I still name each
form field individually instead of trusing arrays e.g. checkbox0, checkbox1 etc. Of
course if you do that you need to have a hidden field with the number of records
displayed to know how many checkboxes to check which is a bit of a pain.

Sorry I couldn't help more.


Good Luck,

George




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to