Re: [PHP-DB] oddity with insert multiple input fields to multipletables

2002-08-18 Thread Joni Järvinen

> if (!isnull($date_am || $exercise_am || $reps_am)) then
> mysql_query($sql_am) or die
> ("Error in this query >>$sql<< : " .mysql_error());

Try:

if(!isnull($date_am) && !isnull($exercise_am) && !isnull($reps_am))

This should IMO work :)

-Joni-

--
// Joni Järvinen
// [EMAIL PROTECTED]
// http://www.reactorbox.org/~wandu



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




Re: [PHP-DB] oddity with insert multiple input fields to multipletables

2002-08-18 Thread Jason Wong

On Sunday 18 August 2002 13:40, Chip Wiegand wrote:

> Okay, so I tried this -
>
> if ($date_am || $exercise_am || $reps_am !== "")
>   {
>   $sql_am = "insert into absmachine (today,exercise,reps,comments)
> values ('$date_am','$exercise_am','$reps_am','$comments_am')";
>   mysql_query($sql_am) or die ("Error in this query >>$sql<< : "
> .mysql_error());
>   }

[snip]

> But I still get empty rows inserted into the tables.

   || means OR

You want to insert a value when:

  1) $date_am has a value AND
  2) $exercise_am has a value AND
  3) $reps_am is not an empty string

so use AND or && instead of ||.


-- 
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *


/*
A couch is as good as a chair.
*/


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




Re: [PHP-DB] oddity with insert multiple input fields to multipletables

2002-08-17 Thread Chip Wiegand

On Sat, 2002-08-17 at 19:49, John Coder wrote:
> 
> This may or may not work but what the h***. If you have multiple insets
> commands test for ! isnull() on each input field ,i.e. variable.
> 
> if (! isnull($input_field)) 
> then  "insert_query"
> 
> as I said this will only work with an insert query for each field.

I see how that would work with individual insert querys for individual
fields, but in my case there are four input fields per query, so it
won't work, even then it is possible for one field to be left empty in
each query (the comments field). And that is okay. If I try this -

if (!isnull($date_am || $exercise_am || $reps_am)) then
mysql_query($sql_am) or die 
("Error in this query >>$sql<< : " .mysql_error());

I get this error -

Parse error: parse error, unexpected T_STRING in
/usr/local/apache/htdocs/workout-abs.php on line 111

I have 4 fields, 3 will always be filled, 1 is optional. I thought I
would try to test for any of the 3 being empty but it didn't work.

--
Chip

> On Sat, 2002-08-17 at 17:08, Chip Wiegand wrote:
> > I have a web page interface to a mysql database. In this web page I have
> > about a dozen form input fields. On submit these are submitted to
> > multiple tables, a differant table for each input field. If I leave any
> > fields blank, and insert only some of the fields, the database will
> > insert an empty row to all the effected tables that didn't have any data
> > from the input fields. 
> > 
> > I have another page that generates graphs from the tables, the empty
> > rows show up as breaks in the graphs lines, if I manually delete all the
> > empty rows the graphs work fine.
> > 
> > 
> > What do I need to do to prevent these empty rows from being written to
> > the tables? 
> > 




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




Re: [PHP-DB] oddity with insert multiple input fields to multipletables

2002-08-17 Thread Jason Wong


> > -Original Message-
> > From: Chip Wiegand [mailto:[EMAIL PROTECTED]]
> > Sent: Sunday, 18 August 2002 7:08 AM
> > To: phpdb
> > Subject: [PHP-DB] oddity with insert multiple input fields to multiple
> > tables
> >
> >
> >
> > I have a web page interface to a mysql database. In this web page I have
> > about a dozen form input fields. On submit these are submitted to
> > multiple tables, a differant table for each input field. If I leave any
> > fields blank, and insert only some of the fields, the database will
> > insert an empty row to all the effected tables that didn't have any data
> > from the input fields.
> >
> >
> > I have another page that generates graphs from the tables, the empty
> > rows show up as breaks in the graphs lines, if I manually delete all the
> > empty rows the graphs work fine.
> >
> >
> >
> > What do I need to do to prevent these empty rows from being written to
> > the tables?

You have to check them before inserting.

  if ($value !== "") {
insert_value();
  }

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *


/*
Between grand theft and a legal fee, there only stands a law degree.
*/


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




Re: [PHP-DB] oddity with insert multiple input fields to multipletables

2002-08-17 Thread John Coder

On Sat, 2002-08-17 at 17:08, Chip Wiegand wrote:
> I have a web page interface to a mysql database. In this web page I have
> about a dozen form input fields. On submit these are submitted to
> multiple tables, a differant table for each input field. If I leave any
> fields blank, and insert only some of the fields, the database will
> insert an empty row to all the effected tables that didn't have any data
> from the input fields. 
> 
> I have another page that generates graphs from the tables, the empty
> rows show up as breaks in the graphs lines, if I manually delete all the
> empty rows the graphs work fine.
> 
> 
> What do I need to do to prevent these empty rows from being written to
> the tables? 
> 

This may or may not work but what the h***. If you have multiple insets
commands test for ! isnull() on each input field ,i.e. variable.

if (! isnull($input_field)) 
then  "insert_query"

as I said this will only work with an insert query for each field.


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




RE: [PHP-DB] oddity with insert multiple input fields to multipletables

2002-08-17 Thread Howard Picken

Hmmm... OK this may a long way around but if when you
are generating your graph, if the value returned is
then get the next value minus it from the last good
value and store it as a value.  Get the last the
last good, minus the calculated value and use that
as the missing value.

Put this all into an array then plot from that.

ie get array of values 3,4,5,3,0,3,0,1 etc
work through array checking values each side 
if a value is 0. Get the difference and replace
0 with the difference.

Hope that's makes sense.  I'm only a beginner 
is this area so someone else will probably 
have a better way.

Howard

On Sat, 2002-08-17 at 15:44, Howard Picken wrote:
> What about setting all fields have a default value, say 0, that
> way you won't have a null but still a zero value.
> 
> Howard

That would just make the graphs drop to zero for those dates, which
would not look so great. Idealy, pressing submit on the web form would
send only the field(s) with data, and not empty fields.

--
Chip

> -Original Message-
> From: Chip Wiegand [mailto:[EMAIL PROTECTED]]
> Sent: Sunday, 18 August 2002 7:08 AM
> To: phpdb
> Subject: [PHP-DB] oddity with insert multiple input fields to multiple
> tables
> 
> 
> I have a web page interface to a mysql database. In this web page I have
> about a dozen form input fields. On submit these are submitted to
> multiple tables, a differant table for each input field. If I leave any
> fields blank, and insert only some of the fields, the database will
> insert an empty row to all the effected tables that didn't have any data
> from the input fields. 
> 
> I have another page that generates graphs from the tables, the empty
> rows show up as breaks in the graphs lines, if I manually delete all the
> empty rows the graphs work fine.
> 
> 
> What do I need to do to prevent these empty rows from being written to
> the tables? 
> 
> --
> chip w
> www.wiegand.org
> [EMAIL PROTECTED]
> 
> (my web server died and the hard drive crashed hard, and is running from
> an incomplete backup on another machine, what a drag) :-(
> 
> 
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 
> 


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