Re: [PHP-DB] How to add 2 years to todays date ?

2002-03-18 Thread Andrey Hristov

In php
$your_timestamp += gmmktime(0,0,0,1,1,1972);
MySQL has INTERVALling options.

Regards,
Andrey

- Original Message - 
From: Dave Carrera [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, March 18, 2002 10:11 AM
Subject: [PHP-DB] How to add 2 years to todays date ?


 Hi All
 I think the subject line says it all.
  
 How to add 2 years to today's date ?
  
 Any helps as always most appreciated.
  
  
  
 Dave Carrera
 Php Developer
 http://davecarrera.freelancers.net
 http://www.davecarrera.com
  
  
 


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




[PHP-DB] javascript problem

2002-03-18 Thread Ali Nayeri

hi all,

i know this is not exactly the place to ask this, but i don't know where
else to ask.  i'm doing a multiframe project and i'm trying to get one of
the pages to change the content of another frame when it loads.

in the main.htm i have:

html
head
titleA Global Village?/title
...
script src=../../media/scripts/rightside.js type=text/javascript
script type=text/javascript
!--
  rightopen();
  rightwrite('Hello', 'www.yahoo.com', 'Yahoo is really good.');
  rightclose();
//--
/script
/script

/head
body
...
/body
/html

the included rightside.js file has the three functions:

function rightopen () {
  parent.rightFrame.document.open();
  parent.rightFrame.document.write(!DOCTYPE html PUBLIC \-\/\/W3C\/\/DTD
XHTML 1.0 Strict\/\/EN\\n);
  parent.rightFrame.document.write(
\http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\\n);
  parent.rightFrame.document.write(html\n);
  parent.rightFrame.document.write(head\n);
  parent.rightFrame.document.write(title\/title\n);
  parent.rightFrame.document.write(meta http-equiv=\Content-Type\
content=\text\/html; charset=iso-8859-1\ \/\n);
  parent.rightFrame.document.write(link rel=\stylesheet\
href=\media\/scripts\/sidelayout.css\ type=\text\/css\ \/\n);
  parent.rightFrame.document.write(link rel=\stylesheet\
href=\media\/scripts\/sidetext.css\ type=\text\/css\ \/\n);
  parent.rightFrame.document.write(script
src=\media\/scripts\/scripts.js\ type=\text\/javascript\\/script\n);
  parent.rightFrame.document.write(\/head\n);
  parent.rightFrame.document.write(body\n);
}

function rightwrite (name, url, desc) {
  parent.rightFrame.document.write(p class=\rightlink\a href=\ + url
+ \ target=\_blank\ + name + \/abr \/);
  parent.rightFrame.document.write(desc + \/p);
}

function rightclose () {
  parent.rightFrame.document.write(\/body\n);
  parent.rightFrame.document.write(\/html\n);
  parent.rightFrame.document.close();
}

when i start the file i get a javascript error saying expecting object

i'm not sure what i'm doing wrong.  any help is appreciated.

thanks


_
Do You Yahoo!?
Get your free yahoo.com address at http://mail.yahoo.com


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




[PHP-DB] Re: Conflicting results using PHP/Mysql

2002-03-18 Thread George Pitcher

Doug,

Sorry for leaving this so long but I've been tied up in business meetings.

It may be that my query is restricting the data retrieval but I cannot see
how.

If I look at the data I am playing with, I have 3 tables and I want to show
transactions from a certain course. I also want to show related information
from the bib_extract table and the scanrates (prices) table.

I've checked the data in these tables and nothing is odd. Maybe there is a
different way to build my query so that it displays the full set of records.

Any suggestions?

George

- Original Message -
From: Doug Thompson [EMAIL PROTECTED]
To: George Pitcher [EMAIL PROTECTED]; [EMAIL PROTECTED];
[EMAIL PROTECTED]
Sent: Wednesday, March 13, 2002 5:59 PM
Subject: Re: Conflicting results using PHP/Mysql


 I would guess it's because only three records match the ANDed tests in the
WHERE clause (last 3 lines).

 Isn't that what you intended?

 Doug


 On Wed, 13 Mar 2002 16:08:43 -, George Pitcher wrote:

 Hi all,
 
 Posted this yesterday and got no response. Trying again today.
 
 I'm having a small problem with a biggish query.
 
 The query:
 
 $Itemlistquery= select [a whole load of fields from 3 tables] ending
with
 ;
 $Itemlistquery.= transactions.Pdownload ;
 $Itemlistquery.= from bib_extract,scanrates,transactions where ;
 $Itemlistquery.= (transactions.CourseID = '$Course_ID' and ;
 $Itemlistquery.= bib_extract.E_ID=transactions.ExtractID and ;
 $Itemlistquery.= scanrates.finrate=transactions.finrate) ;
 
 The problem:
 
 If I do a simple count of transactions.CourseID='$Course_ID' I get 18
(for a
 particular course) and the above query only displays 3 results.
 
 Any suggestions? I didn't want to clog the list with the whole query but
I
 can if it's necessary.
 
 George, in Edinburgh
 
 
 
 -
 Before posting, please check:
http://www.mysql.com/manual.php   (the manual)
http://lists.mysql.com/   (the list archive)
 
 To request this thread, e-mail [EMAIL PROTECTED]
 To unsubscribe, e-mail
[EMAIL PROTECTED]
 Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
 




 -
 Before posting, please check:
http://www.mysql.com/manual.php   (the manual)
http://lists.mysql.com/   (the list archive)

 To request this thread, e-mail [EMAIL PROTECTED]
 To unsubscribe, e-mail
[EMAIL PROTECTED]
 Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php


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




RE: [PHP-DB] increase date()

2002-03-18 Thread Rankin, Randy

Try this:

$six_months_from_now = date(Y-m-d, mktime(0,0,0, date(m)+6, date(1),
date(Y)));
echo Six Months From Now: $six_months_from_nowP;

-Original Message-
From: its me [mailto:[EMAIL PROTECTED]]
Sent: Sunday, March 17, 2002 12:28 AM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] increase date()


i have:
$nowdate=date(Y-m-d);
and i   want to increase it by 6 months,how can i do that??


Rehab M.Shouman





-
Express yourself with a super cool email address from BigMailBox.com.
Hundreds of choices. It's free!
http://www.bigmailbox.com
-

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



Re: [PHP-DB] javascript problem

2002-03-18 Thread Josh Trutwin

I am not a JavaScript expert, but I had a similar problem.  I THINK that
you need to reference your frames like this:

window.parent.frames.rightFrame.document.open();

Give it a try, hope that helps...

Josh

 hi all,

 i know this is not exactly the place to ask this, but i don't know
 where else to ask.  i'm doing a multiframe project and i'm trying to
 get one of the pages to change the content of another frame when it
 loads.

 in the main.htm i have:

 html
 head
 titleA Global Village?/title
 ...
 script src=../../media/scripts/rightside.js type=text/javascript
 script type=text/javascript
 !--
  rightopen();
  rightwrite('Hello', 'www.yahoo.com', 'Yahoo is really good.');
  rightclose();
 //--
 /script
 /script

 /head
 body
 ...
 /body
 /html

 the included rightside.js file has the three functions:

 function rightopen () {
  parent.rightFrame.document.open();
  parent.rightFrame.document.write(!DOCTYPE html PUBLIC
  \-\/\/W3C\/\/DTD
 XHTML 1.0 Strict\/\/EN\\n);
  parent.rightFrame.document.write(
 \http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\\n);
  parent.rightFrame.document.write(html\n);
  parent.rightFrame.document.write(head\n);
  parent.rightFrame.document.write(title\/title\n);
  parent.rightFrame.document.write(meta http-equiv=\Content-Type\
 content=\text\/html; charset=iso-8859-1\ \/\n);
  parent.rightFrame.document.write(link rel=\stylesheet\
 href=\media\/scripts\/sidelayout.css\ type=\text\/css\ \/\n);
  parent.rightFrame.document.write(link rel=\stylesheet\
 href=\media\/scripts\/sidetext.css\ type=\text\/css\ \/\n);
  parent.rightFrame.document.write(script
 src=\media\/scripts\/scripts.js\
 type=\text\/javascript\\/script\n);
  parent.rightFrame.document.write(\/head\n);
  parent.rightFrame.document.write(body\n);
 }

 function rightwrite (name, url, desc) {
  parent.rightFrame.document.write(p class=\rightlink\a href=\ +
  url
 + \ target=\_blank\ + name + \/abr \/);
  parent.rightFrame.document.write(desc + \/p);
 }

 function rightclose () {
  parent.rightFrame.document.write(\/body\n);
  parent.rightFrame.document.write(\/html\n);
  parent.rightFrame.document.close();
 }

 when i start the file i get a javascript error saying expecting
 object

 i'm not sure what i'm doing wrong.  any help is appreciated.

 thanks


 _
 Do You Yahoo!?
 Get your free yahoo.com address at http://mail.yahoo.com


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


Josh Trutwin
http://trutwins.homeip.net



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




Re: [PHP-DB] javascript problem

2002-03-18 Thread Remco Oosten

If your framecontainer is your top-document perhaps you can use:

top.rightFrame.document.open();

or maybe 

top.rightFrame.location='';

Remco
- Original Message - 
From: Josh Trutwin [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Monday, March 18, 2002 4:25 PM
Subject: Re: [PHP-DB] javascript problem


 I am not a JavaScript expert, but I had a similar problem.  I THINK that
 you need to reference your frames like this:
 
 window.parent.frames.rightFrame.document.open();
 
 Give it a try, hope that helps...
 
 Josh
 
  hi all,
 
  i know this is not exactly the place to ask this, but i don't know
  where else to ask.  i'm doing a multiframe project and i'm trying to
  get one of the pages to change the content of another frame when it
  loads.
 
  in the main.htm i have:
 
  html
  head
  titleA Global Village?/title
  ...
  script src=../../media/scripts/rightside.js type=text/javascript
  script type=text/javascript
  !--
   rightopen();
   rightwrite('Hello', 'www.yahoo.com', 'Yahoo is really good.');
   rightclose();
  //--
  /script
  /script
 
  /head
  body
  ...
  /body
  /html
 
  the included rightside.js file has the three functions:
 
  function rightopen () {
   parent.rightFrame.document.open();
   parent.rightFrame.document.write(!DOCTYPE html PUBLIC
   \-\/\/W3C\/\/DTD
  XHTML 1.0 Strict\/\/EN\\n);
   parent.rightFrame.document.write(
  \http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\\n);
   parent.rightFrame.document.write(html\n);
   parent.rightFrame.document.write(head\n);
   parent.rightFrame.document.write(title\/title\n);
   parent.rightFrame.document.write(meta http-equiv=\Content-Type\
  content=\text\/html; charset=iso-8859-1\ \/\n);
   parent.rightFrame.document.write(link rel=\stylesheet\
  href=\media\/scripts\/sidelayout.css\ type=\text\/css\ \/\n);
   parent.rightFrame.document.write(link rel=\stylesheet\
  href=\media\/scripts\/sidetext.css\ type=\text\/css\ \/\n);
   parent.rightFrame.document.write(script
  src=\media\/scripts\/scripts.js\
  type=\text\/javascript\\/script\n);
   parent.rightFrame.document.write(\/head\n);
   parent.rightFrame.document.write(body\n);
  }
 
  function rightwrite (name, url, desc) {
   parent.rightFrame.document.write(p class=\rightlink\a href=\ +
   url
  + \ target=\_blank\ + name + \/abr \/);
   parent.rightFrame.document.write(desc + \/p);
  }
 
  function rightclose () {
   parent.rightFrame.document.write(\/body\n);
   parent.rightFrame.document.write(\/html\n);
   parent.rightFrame.document.close();
  }
 
  when i start the file i get a javascript error saying expecting
  object
 
  i'm not sure what i'm doing wrong.  any help is appreciated.
 
  thanks
 
 
  _
  Do You Yahoo!?
  Get your free @yahoo.com address at http://mail.yahoo.com
 
 
  --
  PHP Database Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 Josh Trutwin
 http://trutwins.homeip.net
 
 
 
 -- 
 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] I can't get Oracle record structure from PHP

2002-03-18 Thread Sumesh Nair

what error does it give u. also check some of these examples on
http://conf.php.net/pres/index.php?p=slides%2Fociid=oci


-Original Message-
From: Csillag Zsolt [mailto:[EMAIL PROTECTED]]
Sent: 17 March 2002 18:40
To: [EMAIL PROTECTED]
Subject: [PHP-DB] I can't get Oracle record structure from PHP



Hi,


I want to call a Pl/Sql function from Php ( I'm using oci8 functions).

If the Pl/Sql function returns with VarChar2, number etc. it works
perfectly.
However when I use the following record for return it doesn't work:

Type T_CegTabla IS TABLE OF VarChar2(80) INDEX BY BINARY_INTEGER;
Type T_CimTabla IS TABLE OF VarChar2(110) INDEX BY BINARY_INTEGER;

  TYPE T_CegLista_REK IS RECORD

  ( Cegnev T_CegTabla ,
Cim T_CimTabla
 );

Function DoSomething (KeresoStr Varchar2,MinRow Integer, MaxRow Integer)
Return T_CegLista_REK ;


Is there a way in Php to workaround this?
I noticed that there isn't record structure in Php.


Thank you in advance




Zsolt Csillag,
Hungary


--
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] Fill select boxes with dependent data from a database. How?

2002-03-18 Thread Marco Viehl

Hi all,

i am searching for a solution for filling 2 (or 3) dependent select boxes
with values from a database.

That means, when you select a value in selectbox 1 the options for the
second selectbox should be filled with values related to select box 1.

Short example

Value for box 1Value for box 2
1a
1b
1c
2d
2e
2f


If you now select 1 in select box 1 then you should only see a,b and
c in selectbox 2.

Was that clear? I hope so.

Does anybody has a solution for this situation? Or maybe sample code?

Thank you in advance for any help.

Kind regards and greetings from Cologne/Germany,

Marco.
[EMAIL PROTECTED]



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




RE: [PHP-DB] RE: [PHP-WIN] Stange 'page-loading' effect

2002-03-18 Thread Jonathan Hilgeman

You should check your error logs after getting the server not found error.
There will frequently be PHP error messages stored in there that might help
discern the problem. You can also set checkpoints in your code that write
out Passed this part, passed this part, etc to a temporary debugging file
(whatever you want to call it), so you can determine where the script failed
if you don't get any help from the logfiles).

- Jonathan

-Original Message-
From: alain samoun [mailto:[EMAIL PROTECTED]]
Sent: Friday, March 15, 2002 9:19 AM
To: George Pitcher; [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: [PHP-DB] RE: [PHP-WIN] Stange 'page-loading' effect


You probably have an error in your code, difficult to help without at least
a snippet of it.
A+
Alain


-Original Message-
From: George Pitcher [mailto:[EMAIL PROTECTED]]
Sent: Friday, March 15, 2002 4:14 AM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: [PHP-WIN] Stange 'page-loading' effect


Hi all,

I have a part of my development site where the user hits a button, sending a
stream of values to a response page.

However, on testing, the response page comes up with 'server not found' but
when I refresh that error page, it loads the correct page but without any of
the transferred values.

Any ideas as to where it going wrong?

I'm using PHP-4.1.1, Apache (console) on Win 2000Pro.

Regards

George

George Pitcher is Technical Manager for the HERON Project
at Napier University, Edinburgh.




--
PHP Windows 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-DB] How to bring down the mysql server smoothly

2002-03-18 Thread andy

Hi there,

how is it possible to bring down the server after starting with safe_mysqld.
I read, that killing the ps with -9 is demmaging the tables.

Thanx, Andy



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




[PHP-DB] textarea and mysql query

2002-03-18 Thread jas

I need some help with a query to place the results within a text area...
here is the code and so far every time I try it out all that happens is it
displays the textbox but not the results of the query.
form name=wel_area method=post action=index_confirm.php3 target=box
?php
$record = mysql_fetch_array(mysql_query(SELECT wel_area FROM
cm_index,$dbh));
echo textarea name='wel_area' value='{$record['wel_area']}' cols='25'
rows='8'/textareabrinput type='submit' name='save'
value='save'br\n;
?
  /form
Any help would be great.
Jas



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




RE: [PHP-DB] textarea and mysql query

2002-03-18 Thread Hunter, Ray

Try this:

form name=wel_area method=post action=index_confirm.php3 target=box
?php
$record = mysql_fetch_array(@mysql_query(SELECT wel_area FROM
cm_index,$dbh)); 
echo textarea name='wel_area' value='.$record['wel_area'].' cols='25'
rows='8'/textareabrinput type='submit' name='save'
value='save'br\n; 
?
/form

If not then let me know...


Thank you,

Ray Hunter
Firmware Engineer

ENTERASYS NETWORKS


-Original Message-
From: jas [mailto:[EMAIL PROTECTED]] 
Sent: Sunday, March 17, 2002 11:54 PM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] textarea and mysql query


I need some help with a query to place the results within a text area...
here is the code and so far every time I try it out all that happens is it
displays the textbox but not the results of the query. form name=wel_area
method=post action=index_confirm.php3 target=box
?php
$record = mysql_fetch_array(@mysql_query(SELECT wel_area FROM
cm_index,$dbh)); echo textarea name='wel_area'
value='{$record['wel_area']}' cols='25' rows='8'/textareabrinput
type='submit' name='save' value='save'br\n; ?
  /form
Any help would be great.
Jas



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



Re: [PHP-DB] textarea and mysql query

2002-03-18 Thread Jason Wong

On Monday 18 March 2002 14:53, jas wrote:

 I need some help with a query to place the results within a text area...
 here is the code and so far every time I try it out all that happens is it
 displays the textbox but not the results of the query.
 form name=wel_area method=post action=index_confirm.php3
 target=box ?php
 $record = mysql_fetch_array(mysql_query(SELECT wel_area FROM
 cm_index,$dbh));
 echo textarea name='wel_area' value='{$record['wel_area']}' cols='25'
 rows='8'/textareabrinput type='submit' name='save'
 value='save'br\n;
 ?
   /form


If this is *all* your code then you're missing the important step of 
connecting to the mysql server and selecting a database.

Have a look at the examples in the manual.


-- 
Jason Wong - Gremlins Associates - www.gremlins.com.hk

/*
Most people don't need a great deal of love nearly so much as they need
a steady supply.
*/

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




Re: [PHP-DB] textarea and mysql query

2002-03-18 Thread jas

Yeah that didn't work either... If I put the same value (
value=\{$record['wel_area']}\ ) on a text line it works just fine however
using the same value for a textarea doesnt give me any results nor does it
give me an error message to go on, if there is a way to output the code to
the screen like a dos echo command that would help out alot.  Thanks in
advance,
Jas
Ray Hunter [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Try this:

 form name=wel_area method=post action=index_confirm.php3
target=box
 ?php
 $record = mysql_fetch_array(@mysql_query(SELECT wel_area FROM
 cm_index,$dbh));
 echo textarea name='wel_area' value='.$record['wel_area'].' cols='25'
 rows='8'/textareabrinput type='submit' name='save'
 value='save'br\n;
 ?
 /form

 If not then let me know...


 Thank you,

 Ray Hunter
 Firmware Engineer

 ENTERASYS NETWORKS


 -Original Message-
 From: jas [mailto:[EMAIL PROTECTED]]
 Sent: Sunday, March 17, 2002 11:54 PM
 To: [EMAIL PROTECTED]
 Subject: [PHP-DB] textarea and mysql query


 I need some help with a query to place the results within a text area...
 here is the code and so far every time I try it out all that happens is it
 displays the textbox but not the results of the query. form
name=wel_area
 method=post action=index_confirm.php3 target=box
 ?php
 $record = mysql_fetch_array(@mysql_query(SELECT wel_area FROM
 cm_index,$dbh)); echo textarea name='wel_area'
 value='{$record['wel_area']}' cols='25' rows='8'/textareabrinput
 type='submit' name='save' value='save'br\n; ?
   /form
 Any help would be great.
 Jas



 --
 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] textarea and mysql query

2002-03-18 Thread jas

Sorry, the connection is established already so that part works just fine.
It is getting the results of said connection \ query to appear in a textarea
vs. a text line.
Jason Wong [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]...
 On Monday 18 March 2002 14:53, jas wrote:

  I need some help with a query to place the results within a text area...
  here is the code and so far every time I try it out all that happens is
it
  displays the textbox but not the results of the query.
  form name=wel_area method=post action=index_confirm.php3
  target=box ?php
  $record = mysql_fetch_array(@mysql_query(SELECT wel_area FROM
  cm_index,$dbh));
  echo textarea name='wel_area' value='{$record['wel_area']}' cols='25'
  rows='8'/textareabrinput type='submit' name='save'
  value='save'br\n;
  ?
/form


 If this is *all* your code then you're missing the important step of
 connecting to the mysql server and selecting a database.

 Have a look at the examples in the manual.


 --
 Jason Wong - Gremlins Associates - www.gremlins.com.hk

 /*
 Most people don't need a great deal of love nearly so much as they need
 a steady supply.
 */



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




RE: [PHP-DB] textarea and mysql query

2002-03-18 Thread Hunter, Ray

What is the result of $record['wel_area'].  If this is a multidimensional
array then you will need to access it differently...

Example:
echo $record[0][0].\n;

Try this is your text area and see if that comes out...



Thank you,

Ray Hunter
Firmware Engineer

ENTERASYS NETWORKS


-Original Message-
From: jas [mailto:[EMAIL PROTECTED]] 
Sent: Monday, March 18, 2002 12:07 AM
To: [EMAIL PROTECTED]
Subject: Re: [PHP-DB] textarea and mysql query


Yeah that didn't work either... If I put the same value (
value=\{$record['wel_area']}\ ) on a text line it works just fine however
using the same value for a textarea doesnt give me any results nor does it
give me an error message to go on, if there is a way to output the code to
the screen like a dos echo command that would help out alot.  Thanks in
advance, Jas Ray Hunter [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Try this:

 form name=wel_area method=post action=index_confirm.php3
target=box
 ?php
 $record = mysql_fetch_array(@mysql_query(SELECT wel_area FROM 
 cm_index,$dbh)); echo textarea name='wel_area' 
 value='.$record['wel_area'].' cols='25' 
 rows='8'/textareabrinput type='submit' name='save' 
 value='save'br\n; ?
 /form

 If not then let me know...


 Thank you,

 Ray Hunter
 Firmware Engineer

 ENTERASYS NETWORKS


 -Original Message-
 From: jas [mailto:[EMAIL PROTECTED]]
 Sent: Sunday, March 17, 2002 11:54 PM
 To: [EMAIL PROTECTED]
 Subject: [PHP-DB] textarea and mysql query


 I need some help with a query to place the results within a text 
 area... here is the code and so far every time I try it out all that 
 happens is it displays the textbox but not the results of the query. 
 form
name=wel_area
 method=post action=index_confirm.php3 target=box
 ?php
 $record = mysql_fetch_array(@mysql_query(SELECT wel_area FROM 
 cm_index,$dbh)); echo textarea name='wel_area' 
 value='{$record['wel_area']}' cols='25' rows='8'/textareabrinput 
 type='submit' name='save' value='save'br\n; ?
   /form
 Any help would be great.
 Jas



 --
 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] textarea and mysql query

2002-03-18 Thread jas

Yeah it is not multidimensional at all, a simple text blob is what should be
pulled into the textarea.  I am not trying to query multipled record fields
at all.  One field per textarea.  Do you know of a good tutorial on pulling
sql queries into textareas?  If you do please let me know as I have searched
php.net and other sites for a tutorial on textarea's but have not found any
nor is there any reference to such a problem in any of the php or mysql
books i have.
Ray Hunter [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 What is the result of $record['wel_area'].  If this is a multidimensional
 array then you will need to access it differently...

 Example:
 echo $record[0][0].\n;

 Try this is your text area and see if that comes out...



 Thank you,

 Ray Hunter
 Firmware Engineer

 ENTERASYS NETWORKS


 -Original Message-
 From: jas [mailto:[EMAIL PROTECTED]]
 Sent: Monday, March 18, 2002 12:07 AM
 To: [EMAIL PROTECTED]
 Subject: Re: [PHP-DB] textarea and mysql query


 Yeah that didn't work either... If I put the same value (
 value=\{$record['wel_area']}\ ) on a text line it works just fine
however
 using the same value for a textarea doesnt give me any results nor does it
 give me an error message to go on, if there is a way to output the code to
 the screen like a dos echo command that would help out alot.  Thanks in
 advance, Jas Ray Hunter [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  Try this:
 
  form name=wel_area method=post action=index_confirm.php3
 target=box
  ?php
  $record = mysql_fetch_array(@mysql_query(SELECT wel_area FROM
  cm_index,$dbh)); echo textarea name='wel_area'
  value='.$record['wel_area'].' cols='25'
  rows='8'/textareabrinput type='submit' name='save'
  value='save'br\n; ?
  /form
 
  If not then let me know...
 
 
  Thank you,
 
  Ray Hunter
  Firmware Engineer
 
  ENTERASYS NETWORKS
 
 
  -Original Message-
  From: jas [mailto:[EMAIL PROTECTED]]
  Sent: Sunday, March 17, 2002 11:54 PM
  To: [EMAIL PROTECTED]
  Subject: [PHP-DB] textarea and mysql query
 
 
  I need some help with a query to place the results within a text
  area... here is the code and so far every time I try it out all that
  happens is it displays the textbox but not the results of the query.
  form
 name=wel_area
  method=post action=index_confirm.php3 target=box
  ?php
  $record = mysql_fetch_array(@mysql_query(SELECT wel_area FROM
  cm_index,$dbh)); echo textarea name='wel_area'
  value='{$record['wel_area']}' cols='25' rows='8'/textareabrinput
  type='submit' name='save' value='save'br\n; ?
/form
  Any help would be great.
  Jas
 
 
 
  --
  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] textarea and mysql query

2002-03-18 Thread John Hughes

jas [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 I need some help with a query to place the results within a text area...
 here is the code and so far every time I try it out all that happens is it
 displays the textbox but not the results of the query.
 form name=wel_area method=post action=index_confirm.php3
target=box
 ?php
 $record = mysql_fetch_array(@mysql_query(SELECT wel_area FROM
 cm_index,$dbh));
 echo textarea name='wel_area' value='{$record['wel_area']}' cols='25'
 rows='8'/textareabrinput type='submit' name='save'
 value='save'br\n;
 ?
   /form
 Any help would be great.
 Jas



If the wel_area is a TEXT field in the database, why the array treatment.
I have a database that contains several TEXT fields that I can call up and
edit.  To do that I bring the data into a textarea.

Here's part of my code:

The SQL query:

$sql = SELECT subj, body, info, fname, lname, title, city, other,
  record_date, status, batch, modified_by
  FROM $table_name
  WHERE id = '$id'
  ;

The results are read into variables:

while ($row = mysql_fetch_array($result)) {
  $subj = $row['subj'];
  $body = $row['body'];
  $info = $row['info'];
  $fname = $row['fname'];
  $lname = $row['lname'];
  $title = $row['title'];
  $city = $row['city'];
  $other = $row['other'];
  $record_date = $row['record_date'];
  $status = $row['status'];
  $batch = $row['batch'];
  $modified_by = $row['modified_by'];
 } #end while

In the body of the HTML section I have areas such as this:

td
  textarea cols=60 rows=20 name=body wrap=soft ? echo $body;
?/textarea
 /td

This creates an editable TEXTAREA that can then be UPDATEd in the database.

John Hughes



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




Re: [PHP-DB] textarea and mysql query

2002-03-18 Thread Jason Wong

On Monday 18 March 2002 15:09, jas wrote:
 Sorry, the connection is established already so that part works just fine.
 It is getting the results of said connection \ query to appear in a
 textarea vs. a text line.
 Jason Wong [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]...

  On Monday 18 March 2002 14:53, jas wrote:
   I need some help with a query to place the results within a text
   area... here is the code and so far every time I try it out all that
   happens is

 it

   displays the textbox but not the results of the query.
   form name=wel_area method=post action=index_confirm.php3
   target=box ?php

action=index_confirm.php3

Note the closing double-quote.



   $record = mysql_fetch_array(@mysql_query(SELECT wel_area FROM
   cm_index,$dbh));
   echo textarea name='wel_area' value='{$record['wel_area']}' cols='25'
   rows='8'/textareabrinput type='submit' name='save'
   value='save'br\n;
   ?
 /form



Text areas are specified as:

 textarea name=abcStuff which goes into text area/textarea


-- 
Jason Wong - Gremlins Associates - www.gremlins.com.hk

/*
Let's not complicate our relationship by trying to communicate with each 
other.
*/

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




RE: [PHP-DB] textarea and mysql query

2002-03-18 Thread Shrock, Court

You problem lies in the html that you are outputting.

For normal html input tags, you use the value attribute to initialize
the default display.  For textarea tags, you do not use the value
attribute; instead, enclose what you want displayed between the openining
textarea tag and the closing /textarea tag.  For example:

input type=text valuePlease edit this textbox
textareaPlease edit this textarea/textarea


 -Original Message-
 From: jas [mailto:[EMAIL PROTECTED]]
 Sent: Sunday, March 17, 2002 10:54 PM
 To: [EMAIL PROTECTED]
 Subject: [PHP-DB] textarea and mysql query
 
 
 I need some help with a query to place the results within a 
 text area...
 here is the code and so far every time I try it out all that 
 happens is it
 displays the textbox but not the results of the query.
 form name=wel_area method=post 
 action=index_confirm.php3 target=box
 ?php
 $record = mysql_fetch_array(@mysql_query(SELECT wel_area FROM
 cm_index,$dbh));
 echo textarea name='wel_area' value='{$record['wel_area']}' 
 cols='25'
 rows='8'/textareabrinput type='submit' name='save'
 value='save'br\n;
 ?
   /form
 Any help would be great.
 Jas
 
 
 
 -- 
 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] SQL statement - PHP/mySQL - brain fart

2002-03-18 Thread Summit

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




[PHP-DB] How display a BLOB field contents in a HTML file?

2002-03-18 Thread Sergio Cornejo

Hi.

I work in a client project that need to show a images of his products in a
HTML file.

I work with MySQL 3.23.47 for windows 98, Apache 1.3.23 for windows and
PHP4.

I insert the images with EMS MySQL Manager (is too easy)

My databese work ok wend i retrive text information like product_ID ,
Product_Name, Maximun amount of product, etc. but i can't show the image of
the product.

The PHP code is:

html
body
?
$link = mysql_connect(localhost, username,password);
mysql_select_db(MyDB, $link);
$result = mysql_query(SELECT * FROM producto, $link);
echo ID: .mysql_result($result, 0, PRO_ID).br;
echo Nombre: .mysql_result($result, 0, PRO_NOMBRE).br;
echo Cant max :.mysql_result($result, 0, PRO_CANTMAX).br;
echo Cant min :.mysql_result($result, 0, PRO_CANTMIN).br;
echo Foto :.mysql_result($result, 0, PRO_CANTMIN).br;
?
/body
/html

I know that some is wrong but i don't know what its

Sergio Cornejo



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




Re: [PHP-DB] passing array through $PHP_SELF

2002-03-18 Thread Mike de Libero

Sorry to say but the inelegant solution is the only way I have found how to
do it :(.  I read it on php FAQTs on how to pass arrays on multi-step forms.
This is a very similar thing.  So yes you have to implode the array then
pass it in a hidden field.  Then explode the array after being passed to
form again.  Hope this helps.

-Mike de Libero
[EMAIL PROTECTED]
http://www.soreye.com
- Original Message -
From: John Hughes, Jomari Works [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, March 18, 2002 5:27 PM
Subject: [PHP-DB] passing array through $PHP_SELF


 I have a page that selects students from a mysql table who meet a certain
 requirement. Those who meet the requirement have a check box variable that
 is checked. (The other students have the check box, but it is
unchecked.)

 The checked student id numbers are sent to the next PHP page.  That page
 allows the user to edit the text of a message that will be sent to each of
 the students checked on the previous page.

 Up to this point I'm fine.  I can pass the array of student ids and read
 them on the other page.

 What I want to do is use $PHP_SELF to allow the user to preview the letter
 after editing.

 My initial tries haven't worked. If I just submit $PHP_SELF the student id
 array disappears. When I attempt to create a hidden form field I get the
 message:

 Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or
 `T_NUM_STRING'

 Right now I have the book open to implode and explode, figuring I can
 translate the array and then pass it back and forth, but that seems rather
 inelegant.

 Is there a simple way to pass an array when using $PHP_SELF to reload a
 page?

 TIA

 John Hughes


 --
 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] passing array through $PHP_SELF

2002-03-18 Thread Shrock, Court

Why not write hidden inputs and name them appropriately so that when the
form gets submitted again, the array gets created automatically--no
implode/explode.

input name=input[var1] value=hello
input name=input[var2] value=world

then, upon submittal, the array, $_POST['input'], would look like this:

Array (
   var1 = hello
   var2 = world
)

Please let me know if this is unclear
Court

-Original Message-
From: Mike de Libero
To: John Hughes, Jomari Works; [EMAIL PROTECTED]
Sent: 3/18/02 7:22 PM
Subject: Re: [PHP-DB] passing array through $PHP_SELF

Sorry to say but the inelegant solution is the only way I have found how
to
do it :(.  I read it on php FAQTs on how to pass arrays on multi-step
forms.
This is a very similar thing.  So yes you have to implode the array then
pass it in a hidden field.  Then explode the array after being passed to
form again.  Hope this helps.

-Mike de Libero
[EMAIL PROTECTED]
http://www.soreye.com

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




Re: [PHP-DB] passing array through $PHP_SELF

2002-03-18 Thread Jason Wong

On Tuesday 19 March 2002 09:27, John Hughes, Jomari Works wrote:
 I have a page that selects students from a mysql table who meet a certain
 requirement. Those who meet the requirement have a check box variable that
 is checked. (The other students have the check box, but it is unchecked.)

 The checked student id numbers are sent to the next PHP page.  That page
 allows the user to edit the text of a message that will be sent to each of
 the students checked on the previous page.

 Up to this point I'm fine.  I can pass the array of student ids and read
 them on the other page.

 What I want to do is use $PHP_SELF to allow the user to preview the letter
 after editing.

 My initial tries haven't worked. If I just submit $PHP_SELF the student id
 array disappears. When I attempt to create a hidden form field I get the
 message:

 Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or
 `T_NUM_STRING'

 Right now I have the book open to implode and explode, figuring I can
 translate the array and then pass it back and forth, but that seems rather
 inelegant.

 Is there a simple way to pass an array when using $PHP_SELF to reload a
 page?

You can serialize() the array then pass it along in a hidden form element. Or 
you can use cookies (sessions).


-- 
Jason Wong - Gremlins Associates - www.gremlins.com.hk

/*
Why must you tell me all your secrets when it's hard enough to love
you knowing nothing?
-- Lloyd Cole and the Commotions
*/

-- 
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-18 Thread Jason Wong

On Tuesday 19 March 2002 10:22, Summit wrote:
 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.]


 SELECT sc.*
   FROM site_category sc
  WHERE sc.category_id = $category_id_1
AND sc.category_id = $category_id_2

Or am I missing something?


-- 
Jason Wong - Gremlins Associates - www.gremlins.com.hk

/*
Let's just be friends and make no special effort to ever see each other again.
*/

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




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

2002-03-18 Thread mailing list

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




[PHP-DB] login problem wasn't solved

2002-03-18 Thread its me

i have sell.php  page which requires loggin so i  put in it:
?
session_start();
  if(!(session_is_registered(valusername)))
  {
$page=$PHP_SELF;
session_register(page);
header(Location:http://$HTTP_HOST/auction/login.php;);
 exit();
  }
?


then in login.php i have;

$sql = SELECT * FROM registration WHERE username = '$username' and 
password='$password';
$result = mysql_query($sql,$conn);

 if(mysql_num_rows($result) 0)
 {
  $row = mysql_fetch_array($result);
  $valusername=$row[username];
  session_register(valusername);
   mysql_close($conn);
   if(session_is_registered(page))
  {
header(location:http://$HTTP_HOST/.$page);
session_unregister(page);
   }
else
header(location:http://$HTTP_HOST/auction/index.php;);
exit();
  }
  else
  {
   echo p align='center'font face='Comic Sans MS' size='6' 
color='#FF'Sorry!!/font/p
p align='center'font color='#80' size='4'You entered either a wrong username or
password.bra href='login.php'try again/a/font/p;
   }


and yes it goes to sell.php page but the url is:

http://localhost//php/php.exe/auction/seller/sell.php


and i tried instead:

if(session_is_registered(page))
  {
header(location:http://$HTTP_HOST/.$$HTTP_REFERRER);
session_unregister(page);
   }

but it goes to
 http://localhost

anyhelp?


Rehab M.Shouman





-
Express yourself with a super cool email address from BigMailBox.com.
Hundreds of choices. It's free!
http://www.bigmailbox.com
-

-- 
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-18 Thread Gurhan Ozen

ok it is 1:37 am here and i have been up since 6:00 am (the day before) and
have to be awake ths mornign again at 6:00 am so if I make any mistakes
trying to answer your question, please take it easy:)

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

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


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




[PHP-DB] Re: php-db Digest 18 Mar 2002 18:40:25 -0000 Issue 1105

2002-03-18 Thread Rob Small

At 06:40 PM 3/18/2002 +, you wrote:
Subject: How to add 2 years to todays date ?

Hi All
I think the subject line says it all.

How to add 2 years to today's date ?

Any helps as always most appreciated.



Dave Carrera
Php Developer


Subject: Re: [PHP-DB] How to add 2 years to todays date ?

In php
$your_timestamp += gmmktime(0,0,0,1,1,1972);
MySQL has INTERVALling options.

Regards,
Andrey

Subject: RE: [PHP-DB] increase date()

Try this:

$six_months_from_now = date(Y-m-d, mktime(0,0,0, date(m)+6, date(1),
date(Y)));
echo Six Months From Now: $six_months_from_nowP;


In my coding, I've used:
 $date_var=date(Y-m-d,strtotime(+0 days));

In your case, you could do it like:
 $date_var=date(Y-m-d, strtotime(+2 years))
or
 $date_var=date(Y-m-d H:i, strtotime(+2 years))
if you wanted hours/minutes

either example formats in a way that MySQL wants to see a date or datetime 
field (respectively)

hope it helps,

~ Rob Small
c0demonkey
Fresno, CA


-- 
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-18 Thread Frank Flynn

Well it's sorta' simple once you get your mind around this - you need two
tables but you've only got one.  And there's no OR, you need both to be true
for a site_id ...

The query would be easy if you actually had two tables so we'll search off
of the same table twice giving it different names each time (sc1 and sc2).

 SELECT  sc1.*
 FROMsite_category sc1, site_category sc2
 WHERE   sc1.category_id = $category_id_1
   AND   sc2.category_id = $category_id_2
   AND   sc1.site_id = sc2.site_id

DISTINCT and such are not necessary unless it's possible you'll have
duplicate rows (and you'd mind getting them back multiple times).

I know this will work in all the big ones (Oracle, MS SQL, IBM) but I'm less
sure about MySQL as I don't use it all that much.  This is standard SQL.

Good Luck,
Frank

On 3/18/02 10:53 PM, [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote:

 From: Summit [EMAIL PROTECTED]
 Date: Mon, 18 Mar 2002 19:22:22 -0700
 To: [EMAIL PROTECTED]
 Subject: 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



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




[PHP-DB] Re: Conflicting results using PHP/Mysql

2002-03-18 Thread George Pitcher

Thanks to Kevin, who yesterday emailed me with a solution to my JOIN
problem.

Thanks to all who helped me see the wood for the trees.

George
- Original Message -
From: Doug Thompson [EMAIL PROTECTED]
To: George Pitcher [EMAIL PROTECTED]; [EMAIL PROTECTED];
[EMAIL PROTECTED]
Sent: Monday, March 18, 2002 9:20 PM
Subject: Re: Conflicting results using PHP/Mysql


 Your base table is transactions.  I assume you want to do a LEFT JOIN.
 I think you might see an improvement if transactions were consistently
named on the left side of the equalities as:

 $Itemlistquery.= transactions.Pdownload ;
 $Itemlistquery.= from bib_extract,scanrates,transactions where ;
 $Itemlistquery.= (transactions.CourseID = '$Course_ID' and ;
 $Itemlistquery.= transactions.ExtractID=bib_extract.E_ID and ;
 $Itemlistquery.= transactions.finrate=scanrates.finrate) ;


 On Mon, 18 Mar 2002 10:58:02 -, George Pitcher wrote:

 It may be that my query is restricting the data retrieval but I cannot
see
 how.
 
 If I look at the data I am playing with, I have 3 tables and I want to
show
 transactions from a certain course. I also want to show related
information
 from the bib_extract table and the scanrates (prices) table.
 
 I've checked the data in these tables and nothing is odd. Maybe there is
a
 different way to build my query so that it displays the full set of
records.
 
 Any suggestions?
 
 George
 
 - Original Message -
 From: Doug Thompson [EMAIL PROTECTED]
 To: George Pitcher [EMAIL PROTECTED]; [EMAIL PROTECTED];
 [EMAIL PROTECTED]
 Sent: Wednesday, March 13, 2002 5:59 PM
 Subject: Re: Conflicting results using PHP/Mysql
 
 
  I would guess it's because only three records match the ANDed tests in
the
 WHERE clause (last 3 lines).
 
  Isn't that what you intended?
 
  Doug
 
 
  On Wed, 13 Mar 2002 16:08:43 -, George Pitcher wrote:
 
  Hi all,
  
  Posted this yesterday and got no response. Trying again today.
  
  I'm having a small problem with a biggish query.
  
  The query:
  
  $Itemlistquery= select [a whole load of fields from 3 tables] ending
 with
  ;
  $Itemlistquery.= transactions.Pdownload ;
  $Itemlistquery.= from bib_extract,scanrates,transactions where ;
  $Itemlistquery.= (transactions.CourseID = '$Course_ID' and ;
  $Itemlistquery.= bib_extract.E_ID=transactions.ExtractID and ;
  $Itemlistquery.= scanrates.finrate=transactions.finrate) ;
  
  The problem:
  
  If I do a simple count of transactions.CourseID='$Course_ID' I get 18
 (for a
  particular course) and the above query only displays 3 results.
  
  Any suggestions? I didn't want to clog the list with the whole query
but
 I
  can if it's necessary.
  
  George, in Edinburgh







 -
 Before posting, please check:
http://www.mysql.com/manual.php   (the manual)
http://lists.mysql.com/   (the list archive)

 To request this thread, e-mail [EMAIL PROTECTED]
 To unsubscribe, e-mail
[EMAIL PROTECTED]
 Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php


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