RE: [PHP-DB] Quarter question..

2002-11-04 Thread joakim . andersson
 $sql = select quarter($qdate) or die(not work #3);
change to
$sql = select quarter($qdate) as my_quarter; //Added an alias to
quarter($qdate). Easier to access that way...
And there's no need for an 'or die()' here. You're just assigning a variable
and most likely this will allways work!


 $yyy = mysql_query ($sql) or die(not work #4);
change to
$yyy = mysql_query ($sql) or die(not work #4:  . mysql_error());
//Standard MySQL trouble-shooting...


 printf(tda href=\%s?id=%sdelete=yes\Delete/a/td, 
 $PHP_SELF, 
 $myrow[id]);
 printf(tda 
 href=\%s?id=%ssubmit=yes\Update/tdtd%s/tdtd  
 %s/tdtd  %s/td/a/tr, 
   update-inv.php, $myrow[id], $myrow[name], 
 $myrow[details], $yyy);
and here you actually echo out the resource id instead of it's value...
change $yyy to $yyy[my_quarter]

HTH
Joakim

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




RE: [PHP-DB] Quarter question..

2002-11-04 Thread joakim . andersson
  printf(tda href=\%s?id=%sdelete=yes\Delete/a/td, 
  $PHP_SELF, 
  $myrow[id]);
  printf(tda 
  href=\%s?id=%ssubmit=yes\Update/tdtd%s/tdtd  
  %s/tdtd  %s/td/a/tr, 
  update-inv.php, $myrow[id], $myrow[name], 
  $myrow[details], $yyy);

My bad.
Before this printf statement you need
$my_var = mysql_fetch_array($yyy);

and then in the printf statement change $yyy to $my_var[my_quarter]

That should work...

Regards
Joakim

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




Re: [PHP-DB] Quarter question..

2002-11-04 Thread Jason Wong
On Monday 04 November 2002 19:58, [EMAIL PROTECTED] wrote:
  $sql = select quarter($qdate) or die(not work #3);

 change to
 $sql = select quarter($qdate) as my_quarter; //Added an alias to
 quarter($qdate). Easier to access that way...
 And there's no need for an 'or die()' here. You're just assigning a
 variable and most likely this will allways work!

On the contrary. If you've made a mistake in your query you wouldn't know 
what's happening. So having the below is a very good idea.

 $yyy = mysql_query ($sql) or die(not work #4:  . mysql_error());
 //Standard MySQL trouble-shooting...

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


/*
Ask not what's inside your head, but what your head's inside of.
-- J.J. Gibson
*/


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




RE: [PHP-DB] Quarter question..

2002-11-04 Thread joakim . andersson
 On Monday 04 November 2002 19:58, [EMAIL PROTECTED] wrote:
   $sql = select quarter($qdate) or die(not work #3);
 
  change to
  $sql = select quarter($qdate) as my_quarter; //Added an alias to
  quarter($qdate). Easier to access that way...
  And there's no need for an 'or die()' here. You're just assigning a
  variable and most likely this will allways work!
 
 On the contrary. If you've made a mistake in your query you 
 wouldn't know 
 what's happening. So having the below is a very good idea.
 
  $yyy = mysql_query ($sql) or die(not work #4:  . mysql_error());
  //Standard MySQL trouble-shooting...

Hi Jason,

I might have been unclear in my reply.
The original code had an 'or die()' on $sql = select... aswell and that
is, in my opinion, rather unnecessary.
Using 'or die(mysql_error())' on mysql_query should be mandatory. At least
during development.

Regards
Joakim

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




Re: [PHP-DB] Quarter question..

2002-11-04 Thread Jason Wong
On Monday 04 November 2002 22:56, [EMAIL PROTECTED] wrote:

 I might have been unclear in my reply.

Sorry, I was following this thread on and off and probably misinterpreted your 
post.

 The original code had an 'or die()' on $sql = select... aswell and that
 is, in my opinion, rather unnecessary.

Of course ;-)

 Using 'or die(mysql_error())' on mysql_query should be mandatory. At least
 during development.

That should be drummed into people's heads from the word go! I've made a 
request in the users' comment of the mysql section of the manual hoping that 
the example code is changed so that instead of just die(), it dies with a 
mysql_error().

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


/*
Maybe you can't buy happiness, but these days you can certainly charge it.
*/


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




[PHP-DB] Quarter question..

2002-11-01 Thread James Hatridge
HI all,

In the code below I'm trying to get the last column to show 1, 2, 3, or 4 
according to which quarter of the year it is. But all it shows in that column 
is  Resource ID # X. The X starts with #3 and goes to 18. There are (at the 
moment) 15 items in the table.  Any ideas what's wrong?

Thanks

JIM

#
?php
echo table border=1 \n;
$i=1;
while ($myrow = mysql_fetch_array($result)) {
if($i % 2) { //this means if there is a remainder
echo TR bgcolor=\yellow\\n;
} else { //if there isn't a remainder we will do the else
echo TR bgcolor=\white\\n;
}
$qdate=$myrow[date];
$sql = select quarter($qdate) or die(not work #3);
$yyy = mysql_query ($sql) or die(not work #4);

printf(tda href=\%s?id=%sdelete=yes\Delete/a/td, $PHP_SELF, 
$myrow[id]);
printf(tda href=\%s?id=%ssubmit=yes\Update/tdtd%s/tdtd  
%s/tdtd  %s/td/a/tr, 
update-inv.php, $myrow[id], $myrow[name], $myrow[details], $yyy);
$i=$i+1;
}
echo /table\n;
}
?
#

-- 
Jim Hatridge
Linux User #88484
--
 BayerWulf
   Linux System # 129656
 The Recycled Beowulf Project
  Looking for throw-away or obsolete computers and parts
   to recycle into a Linux super computer



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