RE: [PHP-DB] SELECT statement problem

2002-08-15 Thread Miles Thompson

Assign the SELECT statement to a variable and then echo the variable. Does 
it contain values you expect? If the database is MySQL it can be  very 
silent about errors in the SELECT and simply returns no results.

Cheers - Miles

At 02:58 PM 8/15/2002 -0400, Evan S. Weiner wrote:
>It only outputs the first tech.  It worked fine until I tried to add the 
>end date ino it.
>
>Thanks for all teh help!
>
>// Get technician info
>$TECH_SQL = "SELECT * FROM employees";
>$TECH = MYSQL_QUERY( $TECH_SQL, $CONNECTION) OR DIE ( mysql_error() );
>
>while ( $row = mysql_fetch_array( $TECH ) )
>{
> $tech_id = $row["id"];
> $tech_name_last = $row["name_last"];
> $tech_name_first = $row["name_first"];
>
> $tech_initials_first = substr( $tech_name_first, 0, 1 );
> $tech_initials_last = substr( $tech_name_last, 0, 1);
> $tech_initials = "$tech_initials_first$tech_initials_last";
>
> $tech_name = "$tech_name_first $tech_name_last";
>
> echo "  \n";
> echo "   class=\"big\">$tech_name\n";
>
> // Reset counters for this tech
> $tech_hour = 0;
> $tech_cost = 0;
>
>
> // Start pulling ticket work
> $TICKET_WORK_SQL = "SELECT * FROM tickets_work
> WHERE employee_id = '$tech_id'
> AND start > '$start'
> AND end < '$end'
> ORDER BY start";
> $TICKET_WORK_INFO = MYSQL_QUERY( $TICKET_WORK_SQL, $CONNECTION ) 
> OR DIE ( mysql_error() );
>
> while ( $row = mysql_fetch_array( $TICKET_WORK_INFO ) )
> {
> $ticket_id = $row["ticket_id"];
> $start = $row["start"];
> $end = $row["end"];
>     $total_hours = $row["total_hours"];
> $total_billable = $row["total_billable"];
>
>-Original Message-
>From: Miles Thompson [mailto:[EMAIL PROTECTED]]
>Sent: Thursday, August 15, 2002 2:26 PM
>To: [EMAIL PROTECTED]
>Subject: Re: [PHP-DB] SELECT statement problem
>
>
>SELECT * FROM tickets_work
>WHERE employee_id = '$tech_id' AND
>  start > '$start' AND
>  end < '$end'
>ORDER BY start
>
>Which will select everything from tickets_work for a given employee between
>start and end. What is not working?
>
>Miles Thompson
>
>At 02:15 PM 8/15/2002 -0400, Evan S. Weiner wrote:
> >Hello all,
> >
> >I have this SQL statement I am trying to use and no matter what
> >combination I use, I cannot get it to work.  The start and end if clauses
> >need to be grouped together.
> >
> >SELECT * FROM tickets_work WHERE employee_id = '$tech_id' && ( start >
> >'$start' && end < '$end' ) ORDER BY start
> >
> >Anyone able to help me?
> >
> >Thanks!
> >
> >Evan
> >
> >
> >--
> >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
>
>
>--
>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




RE: [PHP-DB] SELECT statement problem

2002-08-15 Thread Evan S. Weiner

It only outputs the first tech.  It worked fine until I tried to add the end date ino 
it.

Thanks for all teh help!

// Get technician info
$TECH_SQL = "SELECT * FROM employees";
$TECH = MYSQL_QUERY( $TECH_SQL, $CONNECTION) OR DIE ( mysql_error() );

while ( $row = mysql_fetch_array( $TECH ) )
{
$tech_id = $row["id"];
$tech_name_last = $row["name_last"];
$tech_name_first = $row["name_first"];

$tech_initials_first = substr( $tech_name_first, 0, 1 );
$tech_initials_last = substr( $tech_name_last, 0, 1);
$tech_initials = "$tech_initials_first$tech_initials_last";

$tech_name = "$tech_name_first $tech_name_last";

echo "  \n";
echo "  $tech_name\n";

// Reset counters for this tech
$tech_hour = 0;
$tech_cost = 0;


// Start pulling ticket work
$TICKET_WORK_SQL = "SELECT * FROM tickets_work
WHERE employee_id = '$tech_id'
AND start > '$start'
AND end < '$end'
ORDER BY start";
$TICKET_WORK_INFO = MYSQL_QUERY( $TICKET_WORK_SQL, $CONNECTION ) OR DIE ( 
mysql_error() );

while ( $row = mysql_fetch_array( $TICKET_WORK_INFO ) )
{
$ticket_id = $row["ticket_id"];
$start = $row["start"];
$end = $row["end"];
$total_hours = $row["total_hours"];
$total_billable = $row["total_billable"];

-Original Message-
From: Miles Thompson [mailto:[EMAIL PROTECTED]]
Sent: Thursday, August 15, 2002 2:26 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP-DB] SELECT statement problem


SELECT * FROM tickets_work
WHERE employee_id = '$tech_id' AND
 start > '$start' AND
 end < '$end'
ORDER BY start

Which will select everything from tickets_work for a given employee between 
start and end. What is not working?

Miles Thompson

At 02:15 PM 8/15/2002 -0400, Evan S. Weiner wrote:
>Hello all,
>
>I have this SQL statement I am trying to use and no matter what 
>combination I use, I cannot get it to work.  The start and end if clauses 
>need to be grouped together.
>
>SELECT * FROM tickets_work WHERE employee_id = '$tech_id' && ( start > 
>'$start' && end < '$end' ) ORDER BY start
>
>Anyone able to help me?
>
>Thanks!
>
>Evan
>
>
>--
>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


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




RE: [PHP-DB] SELECT statement problem

2002-08-15 Thread Hutchins, Richard

Can you echo out the sql going in and any errors you're getting when the
query doesn't work then post that info to this list? It'll help both you and
us diagnose what might be going wrong. In addition, what datatype are the
columns named start and end in your database?

(Assuming database is MySQL)

Rich

-Original Message-
From: Evan S. Weiner [mailto:[EMAIL PROTECTED]]
Sent: Thursday, August 15, 2002 2:15 PM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] SELECT statement problem


Hello all,

I have this SQL statement I am trying to use and no matter what combination
I use, I cannot get it to work.  The start and end if clauses need to be
grouped together.

SELECT * FROM tickets_work WHERE employee_id = '$tech_id' && ( start >
'$start' && end < '$end' ) ORDER BY start

Anyone able to help me?

Thanks!

Evan


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




Re: [PHP-DB] SELECT statement problem

2002-08-15 Thread Miles Thompson

SELECT * FROM tickets_work
WHERE employee_id = '$tech_id' AND
 start > '$start' AND
 end < '$end'
ORDER BY start

Which will select everything from tickets_work for a given employee between 
start and end. What is not working?

Miles Thompson

At 02:15 PM 8/15/2002 -0400, Evan S. Weiner wrote:
>Hello all,
>
>I have this SQL statement I am trying to use and no matter what 
>combination I use, I cannot get it to work.  The start and end if clauses 
>need to be grouped together.
>
>SELECT * FROM tickets_work WHERE employee_id = '$tech_id' && ( start > 
>'$start' && end < '$end' ) ORDER BY start
>
>Anyone able to help me?
>
>Thanks!
>
>Evan
>
>
>--
>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