[PHP-DB] Determine last quarter

2002-03-19 Thread Rankin, Randy

Hello all,

Does anyone know how I might determine the start date and end date of the
previous calendar quarter based on today's date. For example, today is
2002-03-19, so the previous quarter start date would return 2001-10-01 and
the previous quarter end date would return 2001-12-31. I am trying to
determine these dates for a report that generates previous quarter sales
based on today (whatever 'today' might be). Hope that's clear. 

Thanks in advance,

Randy Rankin



[PHP-DB] Filesystem functions and mysql

2002-03-19 Thread tom hilton

Hi, I'm working on a website for a local tennis group, and we are raising
money to offset website costs through sponsorships.  I have created some 15
and 30 second GIF's for the sponsors, and would like to create a function
that loads the files in random order when the page is opened.  I am creating
a mysql table with file number, file location, file name info, that will be
pulled when the page loads.  I know there are random number functions I can
use, but I haven't ever worked with the filesystem functions.  What
functions would I need to first open the selected file, then move on to the
next file  in the array, once the previous one has closed, and then continue
looping through this array of files until the page is closed?  Any
suggestions or help would be greatly appreciated.



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




RE: [PHP-DB] Filesystem functions and mysql

2002-03-19 Thread Gurhan Ozen

  Hello Tom,
 First of all, since you are keeping the filepaths and filenames you don't
need to worry about any of the filesystem functions.. You just need to
replace variables in the right places in your output HTML code.
 As for how to implement what you need, I will give you a different tip.
Write a php script to randomly select and display images. You can either use
PHP's random functions to accomplish this or if you will store filepath,
filename info in a MySQL database then you can accomplish this by issuing:
SELECT ... FROM ... ORDER BY RAND() LIMIT 1; Then you can just stick in
meta refresh tag in your html output and set the value to 15 or 30 seconds..
  So now you have a php page that randomly selects an image and displays it
and refreshes for every 30 or 15 seconds..
  Then in your main HTML page where you want this to be displayed , use
iframe/iframe tags to stick that PHP page in And you have it on
whereever you want to have:)
  Hope this helps..

  PS. You may wanna stick all filenames into an array and use shuffle()
function as an alternative it thats easy for you..

Gurhan


-Original Message-
From: tom hilton [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, March 19, 2002 10:36 AM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Filesystem functions and mysql


Hi, I'm working on a website for a local tennis group, and we are raising
money to offset website costs through sponsorships.  I have created some 15
and 30 second GIF's for the sponsors, and would like to create a function
that loads the files in random order when the page is opened.  I am creating
a mysql table with file number, file location, file name info, that will be
pulled when the page loads.  I know there are random number functions I can
use, but I haven't ever worked with the filesystem functions.  What
functions would I need to first open the selected file, then move on to the
next file  in the array, once the previous one has closed, and then continue
looping through this array of files until the page is closed?  Any
suggestions or help would be greatly appreciated.



--
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-DB] Need Help with returning new id's

2002-03-19 Thread Jason McCormack

Hello All,

I am trying to return the largest id for a table and then print the value to
a page. My query works fine in MySQL, the problem is getting the value to
show in a web page with php. This is what I am trying to process.

TABLEID | VALUE
1   | Test
2   | Test 2
3   | Test 3

In the sample table above I am trying to pull back a value of 3 and print to
a web page via php.

$maxid = select max(tableid) from table as largestid;
// db_connect is my database connection. I know this works because I have
other pages that return
// results based on my queries without any problems
$run_query  = ($maxid,$db_connect);

This is were I get a bit lost. I have tried using all sorts of various mysql
functions without success

$row = mysql_fetch_row($run_query);
$mymaxidvalue = $row[0];
echo $mymaxidvalue;

As I stated above I have tried many different ways to get the desired
results but have been unsuccessful. Any help would be greatly appreciated.

Thanks,
Jason



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




[PHP-DB] Output of curl to an array.

2002-03-19 Thread Keith Posehn

Ok, lets say I have some code here:

$result = array();

$ch = curl_init (https://www.myverificationplace.com/verify.asp;);

curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $args);
curl_setopt ($ch, CURLOPT_TIMEOUT, 120); // Set the timeout, in seconds.
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec ($ch);

curl_close ($ch);

Now that we see that, how can I make it so that the output from curl, which
is in the variable $result, will be an array, for each line of output?

Some of the line of output looks like this:

ssl_result_message=APPROVED
ssl_txn_id=----
ssl_approval_code=00

I need each of the lines to be turned into a variable. Any ideas as to how I
might go about this?

Thanks,

Keith Posehn



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




RE: [PHP-DB] Need Help with returning new id's

2002-03-19 Thread Rick Emery

first, it helps if you show us your REAL code.  The query statement you
showed below would obviously not work (it's missing the mysql_query part.
Second, when executing mysql_query() ALWAYS include the or
die(mysql_error()) part to aid diagnostics.
Third, your query could not possibly work at the mysql command line; you've
misplaced the AS construct at the end of the query.

$maxid = select max(tableid) as largestid from table;
$result = mysql_query($maxid) or die(Error: .mysql_error());
list($mymaxidvalue) = mysql_fetch_array($result);
echo $mymaxidvalue;


-Original Message-
From: Jason McCormack [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, March 19, 2002 12:31 AM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Need Help with returning new id's


Hello All,

I am trying to return the largest id for a table and then print the value to
a page. My query works fine in MySQL, the problem is getting the value to
show in a web page with php. This is what I am trying to process.

TABLEID | VALUE
1   | Test
2   | Test 2
3   | Test 3

In the sample table above I am trying to pull back a value of 3 and print to
a web page via php.

$maxid = select max(tableid) from table as largestid;
// db_connect is my database connection. I know this works because I have
other pages that return
// results based on my queries without any problems
$run_query  = ($maxid,$db_connect);

This is were I get a bit lost. I have tried using all sorts of various mysql
functions without success

$row = mysql_fetch_row($run_query);
$mymaxidvalue = $row[0];
echo $mymaxidvalue;

As I stated above I have tried many different ways to get the desired
results but have been unsuccessful. Any help would be greatly appreciated.

Thanks,
Jason



-- 
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] SQL statement - PHP/mySQL - brain fart

2002-03-19 Thread Steve Fry

Gurhan:

snip

 I was wondering if you'd wanna use temporary tables to accomplish it..

Actually, another person on this list came up with the following:

  SELECT  s1.site_id
FROM  site_category AS s1
JOIN  site_category AS s2
   WHERE  s1.category_id=10
 AND  s2.category_id=12
 AND  s1.site_id=s2.site_id

It worked like a charm!  

Thanks to all who replied!

Steve
 
 You may wanna do:
 
 CREATE TEMPORARY TABLE tmp1 SELECT * FROM site_category WHERE
 category_id=$category_id_1;
 
 ok this will give us the records that matches $category_id_1 in category_id
 field put them into a temporary table called tmp1 Then do:
 
 CREATE TEMPORARY TABLE tmp2 SELECT * FROM site_category WHERE
 category_id=$category_id_2;
 
 and this will give us the records matching $category_id_2 in category_id
 field and put them into a temporary table called tmp2..
 
 Now you have 2 temporary tables, tmp1 and tmp2 as shown below:
 
 tmp1:
 +--+--+--+
 | sci  | si   | ci   |
 +--+--+--+
 |1 |2 |   10 |
 |4 |4 |   10 |
 +--+--+--+
 
 tmp2:
 +--+--+--+
 | sci  | si   | ci   |
 +--+--+--+
 |3 |4 |   12 |
 |5 |5 |   12 |
 +--+--+--+
 
 Now you can use use join syntax to find the si value thats common to the
 both tables...
 
 select * from tmp1, tmp2 where tmp1.si=tmp2.si;
 
 Does this work for you??
 
 Gurhan
 
 -Original Message-
 From: Summit [mailto:[EMAIL PROTECTED]]
 Sent: Monday, March 18, 2002 9:22 PM
 To: [EMAIL PROTECTED]
 Subject: [PHP-DB] SQL statement - PHP/mySQL - brain fart
 
 For some reason I keep thinking that this should be simple - but I just
 can't seem to figure it out.  Help???  Please???  [I've been working on
 it for two days now.]
 
 Overview:  What I'm trying to do is query one table by passing it two
 different variables - and return only the results that are COMMON to
 both variables.  [PHP 4.1.2/mySQL 3.23.44/FreeBSD]
 
 Assume I have a site_category table:
 
 ---
 site_category
 ---
 site_category_id
 site_id
 category_id
 ---
 
 Perhaps a dump of this looks something like this:
 
 --- ---
 site_category_idsite_id category_id
 --- ---
 1  2   10
 2  3   11
 3  4   12
 4  4   10
 5  5   12
 6  5   14
 --- ---
 
 Using values for the varibles I'm passing to the query (see below) of
 ...
 
 $category_id_1 = 10
 $category_id_2 = 12
 
 ... the result I'm looking for is:
 
 site_id = 4
 
 ... as this is the only site_id which is common to both ...
 
 category_id = 10
 category_id = 12
 
 I've tried a bazillion variations on the following query:
 
 SELECT  sc.*
 FROMsite_category sc
 WHERE   (sc.category_id = $category_id_1 OR sc.category_id =
 $category_id_2)
 
 Breaking out the parts ...
 
 So, if category_id_1 = 10, I'm returned:
 
 site_id = 2
 site_id = 4
 
 So, if category_id_2 = 12, I'm returned:
 
 site_id = 4
 site_id = 5
 
 How can I get that 4 which you can clearly see is common to both of
 the parts above?
 
 But just about no matter how I write my queries, I keep getting:
 
 site_id = 2
 site_id = 4
 site_id = 4
 site_id = 5
 
 Or if use SELECT DISTINCT we get:
 
 site_id = 2
 site_id = 4
 site_id = 5
 
 [I want that extra 4 that the DISTINCT threw out!!!]
 
 I keep thinking that I can do this in a single query - but I don't know
 for sure.  I've tried sub-selects with no luck [E.g. IN()].  Do I need
 to do something with arrays and array_intersect?  [I've even tried
 messing with the PHP3 hacks for array_unique - trying to reverse them 'n
 stuff - but still no luck.]
 
 Does anyone have a simple solution?  [I'll even take a hard solution -
 but I keep thinking that I'm just looking at the the wrong way.]
 
 TIA,
 
 Summit
 
 
 There is no such thing as a stupid person -
there are only those who choose not to learn!
Summit - [EMAIL PROTECTED]
 
 
 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php

-- 
--
 Peak to Peak Trail and Wilderness Links
Steve Fry - LinkKeeper - [EMAIL PROTECTED]
   http://www.peaktopeak.net
--

-- 

[PHP-DB] Searching results of results

2002-03-19 Thread Chris Payne

Hi there everyone,

Say I do a simple search as follows:

$query = SELECT * FROM search WHERE 
(description LIKE '%$test%' OR state LIKE '%$test%' OR city LIKE '%$test%' OR fname 
LIKE '%$test%') AND (category = '$category' AND country = '$country' AND type = 
'$type') ORDER BY city ASC LIMIT $offset, $item_perpage;

and this brings up 1000 results, how can I then do another search based on THESE 
search results only?  That is, it only searches the results it currently has and 
doesn't search the DB for other entries at the same time?

Thanks for your help

Chris



Re: [PHP-DB] Searching results of results

2002-03-19 Thread olinux

You could select these results into a temporary table
and then query that table. Look at the mysql.com docs
and check out the CREATE TEMPORARY TABLE. You can
select data right into the table and the table is
erased when the connection closes. 

But first it looks like cleaning up your query would
probably be the best way to get what you want.

try something like

$query = SELECT * FROM search WHERE ;

if ($description) {
   $query .= description LIKE '$description%' AND ;
}
if ($state) {
   $query .= state = '$state' AND ; }
if ($city) {
   $query .= city = '$city' AND ; }
if ($fname) {
   $query .= fname = '$fname' AND ; }

$query .= (category = '$category' AND country =
'$country' AND type = '$type') ORDER BY city ASC LIMIT
$offset, $item_perpage;

have fun,
olinux


--- Chris Payne [EMAIL PROTECTED] wrote:
 Hi there everyone,
 
 Say I do a simple search as follows:
 
 $query = SELECT * FROM search WHERE 
 (description LIKE '%$test%' OR state LIKE '%$test%'
 OR city LIKE '%$test%' OR fname LIKE '%$test%') AND
 (category = '$category' AND country = '$country' AND
 type = '$type') ORDER BY city ASC LIMIT $offset,
 $item_perpage;
 
 and this brings up 1000 results, how can I then do
 another search based on THESE search results only? 
 That is, it only searches the results it currently
 has and doesn't search the DB for other entries at
 the same time?
 
 Thanks for your help
 
 Chris
 


__
Do You Yahoo!?
Yahoo! Sports - live college hoops coverage
http://sports.yahoo.com/

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




Re: [PHP-DB] Searching results of results

2002-03-19 Thread Chris Payne

Hi there,

Thanks for your help on this it's appreciated, i'll look into temporary
tables tomorrow and see what I can do.  Just curious, why is the method you
have shown below better than the method I used previously?  Is it a speed
thing or is it more logical?  I am learning different methods of doing
things so I would really appreciate your input :-)

Thanks for everything.

Chris

 You could select these results into a temporary table
 and then query that table. Look at the mysql.com docs
 and check out the CREATE TEMPORARY TABLE. You can
 select data right into the table and the table is
 erased when the connection closes.

 But first it looks like cleaning up your query would
 probably be the best way to get what you want.

 try something like

 $query = SELECT * FROM search WHERE ;

 if ($description) {
$query .= description LIKE '$description%' AND ;
 }
 if ($state) {
$query .= state = '$state' AND ; }
 if ($city) {
$query .= city = '$city' AND ; }
 if ($fname) {
$query .= fname = '$fname' AND ; }

 $query .= (category = '$category' AND country =
 '$country' AND type = '$type') ORDER BY city ASC LIMIT
 $offset, $item_perpage;

 have fun,
 olinux


 --- Chris Payne [EMAIL PROTECTED] wrote:
  Hi there everyone,
 
  Say I do a simple search as follows:
 
  $query = SELECT * FROM search WHERE
  (description LIKE '%$test%' OR state LIKE '%$test%'
  OR city LIKE '%$test%' OR fname LIKE '%$test%') AND
  (category = '$category' AND country = '$country' AND
  type = '$type') ORDER BY city ASC LIMIT $offset,
  $item_perpage;
 
  and this brings up 1000 results, how can I then do
  another search based on THESE search results only?
  That is, it only searches the results it currently
  has and doesn't search the DB for other entries at
  the same time?
 
  Thanks for your help
 
  Chris
 


 __
 Do You Yahoo!?
 Yahoo! Sports - live college hoops coverage
 http://sports.yahoo.com/

 --
 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-DB] Re: Turtle slow bind variables are 6 times slower in Oracle?

2002-03-19 Thread John Lim

Found out why it was so slow.

  $e = OCIExecute($stmt);

The above commits every insert. It should be changed to

  $e = OCIExecute($stmt,OCT_DEFAULT);

Then I got the expected results. Using bind vars is nearly twice as fast.


John Lim [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Hello,
 I recently benchmarked using bind variables for inserts versus sending
 simple sql over to oracle 8.1.7. Surprisingly, sending simple sql was
 nearly 6 times faster. My database is using cursor_sharing=force.

 Can anyone else verify this?

  Not using bind variables (MySQL and Oracle), using ADOdb library:

 $DB-BeginTrans();
 for ($i=0; $i  $NUMRECS; $i++) {
  $DB-Execute(
 insert into test5000 (name,price,stock) values ('a name
 $i',$i,$i));
 }
 $DB-CommitTrans();


  Using bind variables:

 $DB-BeginTrans();
 $a = '';
 $b = 0;
 $c = 0;
 $stmt = OCIParse($DB-_connectionID,
 insert into test5000 (name,price,stock) values (:a,:b,:c));
 OCIBindByName($stmt,:a,$a,32);
 OCIBindByName($stmt,:b,$b,32);
 OCIBindByName($stmt,:c,$c,32);
 for ($i=0; $i  $NUMRECS; $i++) {
  $a = a name $i;
  $b = $i;
  $c = $i;
  $e = OCIExecute($stmt);
  if (!$e) {
   print $DB-ErrorMsg();
   break;
  }
 }
 $DB-CommitTrans();

 ---
 For more details, see:
 http://php.weblogs.com/oracle_mysql_performance







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




[PHP-DB] Indexable DB Driven site on Windows Server

2002-03-19 Thread olinux

There's a great article at phpbuilder on making your
dynamic site indexable. 
http://phpbuilder.com/columns/tim2526.php3

Unfortunately I only found solutions that work with
apache. Does anyone have a solution that allows urls
to be constructed in Search Engine Friendly format. 

thanks much,
olinux

__
Do You Yahoo!?
Yahoo! Sports - live college hoops coverage
http://sports.yahoo.com/

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




Re: [PHP-DB] post to a url and return to same page

2002-03-19 Thread olinux

I know that there is a PEAR library
[http://pear.php.net] that allows this. I don't know
if it requires CURL or not. I ran into the same
problem and haven't had time to check out PEAR yet.
perhaps someone can enlighten us.

olinux


--- mailing list [EMAIL PROTECTED] wrote:
 Hello,
 
 I am trying to post to a URL and return to the same
 page with the result
 and or error messages.  The shared server that is
 hosting this site was
 not compiled with CURL.  Is there an alternative way
 to post a form to an
 alternate url and return to the same page without
 having to rely on the
 alternate URL's server?
 
 Regards,
 
 Adrian
 
 
 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 


__
Do You Yahoo!?
Yahoo! Sports - live college hoops coverage
http://sports.yahoo.com/

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




Re: [PHP-DB] Searching results of results

2002-03-19 Thread Remco Oosten

I use a method I'd like to share:

For building queries with many conditions you first create an array like so

$select = SELECT *;

if (isset($cond)) unset($cond);
if ($desc) $cond[] = desc LIKE '$desc%';
if ($state) $cond[] = state LIKE '$state%';
if ($city) $cond[] = city LIKE '$city%';

if (isset($cond)) $cond =  WHERE .implode( AND ,$cond);

$order= ORDER BY city;
$limit= LIMIT $offset, $item_perpage;

$query = $select.$cond.$order.$limit;

Regards,
Remco

- Original Message -
From: Chris Payne [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, March 20, 2002 6:58 AM
Subject: Re: [PHP-DB] Searching results of results


 Hi there,

 Thanks for your help on this it's appreciated, i'll look into temporary
 tables tomorrow and see what I can do.  Just curious, why is the method
you
 have shown below better than the method I used previously?  Is it a speed
 thing or is it more logical?  I am learning different methods of doing
 things so I would really appreciate your input :-)

 Thanks for everything.

 Chris

  You could select these results into a temporary table
  and then query that table. Look at the mysql.com docs
  and check out the CREATE TEMPORARY TABLE. You can
  select data right into the table and the table is
  erased when the connection closes.
 
  But first it looks like cleaning up your query would
  probably be the best way to get what you want.
 
  try something like
 
  $query = SELECT * FROM search WHERE ;
 
  if ($description) {
 $query .= description LIKE '$description%' AND ;
  }
  if ($state) {
 $query .= state = '$state' AND ; }
  if ($city) {
 $query .= city = '$city' AND ; }
  if ($fname) {
 $query .= fname = '$fname' AND ; }
 
  $query .= (category = '$category' AND country =
  '$country' AND type = '$type') ORDER BY city ASC LIMIT
  $offset, $item_perpage;
 
  have fun,
  olinux
 
 
  --- Chris Payne [EMAIL PROTECTED] wrote:
   Hi there everyone,
  
   Say I do a simple search as follows:
  
   $query = SELECT * FROM search WHERE
   (description LIKE '%$test%' OR state LIKE '%$test%'
   OR city LIKE '%$test%' OR fname LIKE '%$test%') AND
   (category = '$category' AND country = '$country' AND
   type = '$type') ORDER BY city ASC LIMIT $offset,
   $item_perpage;
  
   and this brings up 1000 results, how can I then do
   another search based on THESE search results only?
   That is, it only searches the results it currently
   has and doesn't search the DB for other entries at
   the same time?
  
   Thanks for your help
  
   Chris
  
 
 
  __
  Do You Yahoo!?
  Yahoo! Sports - live college hoops coverage
  http://sports.yahoo.com/
 
  --
  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