Re: [PHP-DB] Category Listing

2003-09-22 Thread Peter Beckman
On Sun, 21 Sep 2003, Paul B. [pbcomm, aka WPD] wrote:

 Hi, i'm working on the site that involves a lot ot categories and subs there
 of ... The way i have things now is that the structure goes one sub deep ...

 Ex:
 PHP - Database
 PHP - Books

 in the DB it looks like:
 id 1 name PHP parent 0
 id 2 name Database parent 1

 this way its easy to show dinamicaly where the user is (PHP: Database) by
 prividing
 index.php?dir=1sub=1.
 What i want to do, is go 3 or 4 subs deep. I just wanted to get an idea on
 the best posible way of doing this.

 index.php?dir=2

 Then select * from DB where id=2
 that gives you

 2  Database1

 If parentid!=0
select * from DB where id=parentid (1 in this case)
push $name onto an array (database is now array index 0)

 Then you'll have

 1  PHP 0

 Know you know you are at the top.
push $name onto an array (PHP is now array index 1)

 Now just pop them off the array (PHP - Database - end of array)

Beckman
---
Peter Beckman  Internet Guy
[EMAIL PROTECTED] http://www.purplecow.com/
---

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



[PHP-DB] Databases and PHP?

2003-09-22 Thread IN
Hello all,
With PHP, Is it possible to use DB2-UDB as a database (ADO) or any other
database, or must I use MySql.
I am considering using PHP for building web's and the kind of database to
use might be an important factor.

TIA
I. Nemlich

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



RE: [PHP-DB] Databases and PHP?

2003-09-22 Thread Jacob A. van Zanen
PHP can be used with many different databases (MySql support is just
built in, others you have to compile in).
I do not know about DB2 but ODBC is always possible


Jack



-Original Message-
From: IN [mailto:[EMAIL PROTECTED] 
Sent: Monday, September 22, 2003 11:31 AM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Databases and PHP?


Hello all,
With PHP, Is it possible to use DB2-UDB as a database (ADO) or any other
database, or must I use MySql. I am considering using PHP for building
web's and the kind of database to use might be an important factor.

TIA
I. Nemlich

-- 
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] MySQL: How to properly extract fields from retrieved single record ???

2003-09-22 Thread -{ Rene Brehmer }-
Hi gang

Still working on this DB for my gameclan not that it's essential what 
it's for... and be warned: Never worked with any form of DB in PHP before I 
began this project, so I'm a total n00b at these MySQL commands (and the 
manual for MySQL is by far nowhere near as good as the PHP one).

Anyways, I'm retrieving a single record from the DB table, and then, 
because of the way the data needs to be displayed and manipulated, need to 
extract every single field from that record as a seperate value.

I tried this:

$num2edit = $_POST['edit'];
$link = mysql_connect($host,$username,$password)
  or die('Could not connect : '.mysql_error());
mysql_select_db($database) or die('Could not select database');
$query = SELECT 
countryNum,country,nw,gov,strat,spy,troops,jets,turrets,tanks,ally,owner 
FROM a2a WHERE countryNum=$num2edit;
$result = mysql_query($query);

$countryNum = mysql_result($result,1,'countryNum');
$country = mysql_result($result,1,'country');
$nw = mysql_result($result,1,'nw');
$gov = mysql_result($result,1,'gov');
$strat = mysql_result($result,1,'strat');
$spy = mysql_result($result,1,'spy');
$troops = mysql_result($result,1,'troops');
$jets = mysql_result($result,1,'jets');
$turrets = mysql_result($result,1,'turrets');
$tanks = mysql_result($result,1,'tanks');
$ally = mysql_result($result,1,'ally');
$owner = mysql_result($result,1,'owner');
/* Free resultset */
mysql_free_result($result);
/* Closing connection */
mysql_close($link);
But all it gives me are errors like this:

Warning: mysql_result(): supplied argument is not a valid MySQL result 
resource in E:\web\mpe\a2aedit.php on line 350
Warning: mysql_result(): supplied argument is not a valid MySQL result 
resource in E:\web\mpe\a2aedit.php on line 351
Warning: mysql_result(): supplied argument is not a valid MySQL result 
resource in E:\web\mpe\a2aedit.php on line 352
Warning: mysql_result(): supplied argument is not a valid MySQL result 
resource in E:\web\mpe\a2aedit.php on line 353
Warning: mysql_result(): supplied argument is not a valid MySQL result 
resource in E:\web\mpe\a2aedit.php on line 354
Warning: mysql_result(): supplied argument is not a valid MySQL result 
resource in E:\web\mpe\a2aedit.php on line 355
Warning: mysql_result(): supplied argument is not a valid MySQL result 
resource in E:\web\mpe\a2aedit.php on line 356
Warning: mysql_result(): supplied argument is not a valid MySQL result 
resource in E:\web\mpe\a2aedit.php on line 357
Warning: mysql_result(): supplied argument is not a valid MySQL result 
resource in E:\web\mpe\a2aedit.php on line 358
Warning: mysql_result(): supplied argument is not a valid MySQL result 
resource in E:\web\mpe\a2aedit.php on line 359
Warning: mysql_result(): supplied argument is not a valid MySQL result 
resource in E:\web\mpe\a2aedit.php on line 360
Warning: mysql_result(): supplied argument is not a valid MySQL result 
resource in E:\web\mpe\a2aedit.php on line 361

Obviously, the first mysql_result line is line 350 in the full code. I've 
also tried changing the row number to 0, but results in the same errors.

I can't find any decent reference on the web that shows how to do this - 
field extraction - when there's only the single record. So I've been mixing 
code from various places. And I don't even know if it retrieves the right 
record, or any record at all (how do I test that?).

Any help is highly appreciated :)

TIA

Rene
--
Rene Brehmer
aka Metalbunny
http://metalbunny.net/
References, tools, and other useful stuff...
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] MySQL: How to properly extract fields from retrieved single record ???

2003-09-22 Thread Peter Beckman
On Mon, 22 Sep 2003, -{ Rene Brehmer }- wrote:

  $result = mysql_query($query);

 replace with:

   $result = mysql_query($query) or die(MySQL Error: .mysql_error().\nbr/SQL: 
.$query);

 If the query fails, you will see why the query failed, and be able to view
 the query itself.  Maybe $_POST['edit'] isn't set.  Maybe you have a
 problem in your SQL.  Maybe the DB you are connecting to doesn't exist.  I
 would check your connection as well.

Beckman
---
Peter Beckman  Internet Guy
[EMAIL PROTECTED] http://www.purplecow.com/
---

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



RE: [PHP-DB] MySQL: How to properly extract fields from retrieved single record ???

2003-09-22 Thread Jacob A. van Zanen
Hi,


I think this is what you are trying to do. You get a record back that
has seveal fields and you want to reference those fields indiviually.

This is what I do in this example (which shows people information) and
present in HTML table

EXAMPLE

$result = mysql_query(select * from ledenlijst order by naam,$db);
if ($myrow = mysql_fetch_row($result))
{
print(table border=\0\ \n);
print(trtd bgcolor=\#990066\a
href=all.php?insert=yesToevoegena/td\n);
print(td bgcolor=\#990066\bNaam/b/td\n);
print(td bgcolor=\#990066\bVoornaam/b/td\n);
print(td bgcolor=\#990066\bStraat/b/td\n);
print(td bgcolor=\#990066\bPostcode/b/td\n);
print(td bgcolor=\#990066\bWoonplaats/b/td\n);
print(td bgcolor=\#990066\bTelefoon/b/td\n);
print(td bgcolor=\#990066\bGsm/b/td\n);
print(td bgcolor=\#990066\bE-Mail/b/td\n);
print(td bgcolor=\#990066\bBrevet/b/td/tr\n);
do
{
print(trtd bgcolor=\#cc\);
print(a href=all.php?id=$myrow[0]update=yesupdate/a / a
href=all.php?id=$myrow[0]delete=yesdelete/a);
print(\n);
print(/tdtd bgcolor=\#cc\);
print($myrow[1]);
print(\n);
print(/tdtd bgcolor=\#cc\);
print($myrow[2]);
print(\n);
print(/tdtd bgcolor=\#cc\);
print($myrow[3]);
print(\n);
print(/tdtd bgcolor=\#cc\);
print($myrow[4]);
print(\n);
print(/tdtd bgcolor=\#cc\);
print($myrow[5]);
print(\n);
print(/tdtd bgcolor=\#cc\);
print($myrow[6]);
print(\n);
print(/tdtd bgcolor=\#cc\);
print($myrow[9]);
print(\n);
print(/tdtd bgcolor=\#cc\);
print($myrow[7]);
print(\n);
print(/tdtd bgcolor=\#cc\);
print($myrow[8]);
print(\n);
print(/td/tr\n);
}
while ($myrow = mysql_fetch_row($result));
print(/table\n);
}
else
{
print(bSorry, no Records were found!/b);
}
EXAMPLE


-Original Message-
From: -{ Rene Brehmer }- [mailto:[EMAIL PROTECTED] 
Sent: Monday, September 22, 2003 1:57 PM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] MySQL: How to properly extract fields from retrieved
single record ???


Hi gang

Still working on this DB for my gameclan not that it's essential
what 
it's for... and be warned: Never worked with any form of DB in PHP
before I 
began this project, so I'm a total n00b at these MySQL commands (and the

manual for MySQL is by far nowhere near as good as the PHP one).

Anyways, I'm retrieving a single record from the DB table, and then, 
because of the way the data needs to be displayed and manipulated, need
to 
extract every single field from that record as a seperate value.

I tried this:

 $num2edit = $_POST['edit'];
 $link = mysql_connect($host,$username,$password)
   or die('Could not connect : '.mysql_error());
 mysql_select_db($database) or die('Could not select database');

 $query = SELECT 
countryNum,country,nw,gov,strat,spy,troops,jets,turrets,tanks,ally,owner

FROM a2a WHERE countryNum=$num2edit;
 $result = mysql_query($query);

 $countryNum = mysql_result($result,1,'countryNum');
 $country = mysql_result($result,1,'country');
 $nw = mysql_result($result,1,'nw');
 $gov = mysql_result($result,1,'gov');
 $strat = mysql_result($result,1,'strat');
 $spy = mysql_result($result,1,'spy');
 $troops = mysql_result($result,1,'troops');
 $jets = mysql_result($result,1,'jets');
 $turrets = mysql_result($result,1,'turrets');
 $tanks = mysql_result($result,1,'tanks');
 $ally = mysql_result($result,1,'ally');
 $owner = mysql_result($result,1,'owner');

 /* Free resultset */
 mysql_free_result($result);
 /* Closing connection */
 mysql_close($link);

But all it gives me are errors like this:

Warning: mysql_result(): supplied argument is not a valid MySQL result 
resource in E:\web\mpe\a2aedit.php on line 350
Warning: mysql_result(): supplied argument is not a valid MySQL result 
resource in E:\web\mpe\a2aedit.php on line 351
Warning: mysql_result(): supplied argument is not a valid MySQL result 
resource in E:\web\mpe\a2aedit.php on line 352
Warning: mysql_result(): supplied argument is not a valid MySQL result 
resource in E:\web\mpe\a2aedit.php on line 353
Warning: mysql_result(): supplied argument is not a valid MySQL result 
resource in E:\web\mpe\a2aedit.php on line 354
Warning: mysql_result(): supplied argument is not a valid MySQL result 
resource in E:\web\mpe\a2aedit.php on line 355
Warning: mysql_result(): supplied argument is not a valid MySQL result 
resource in E:\web\mpe\a2aedit.php on line 356
Warning: mysql_result(): supplied argument is not a valid MySQL result 
resource in E:\web\mpe\a2aedit.php on line 357
Warning: mysql_result(): 

[PHP-DB] Query Filter in GUI

2003-09-22 Thread dpgirago
Good Morning PHP-DB Listers,

I have a PHP GUI in which a select box gets populated by a query of a 
MySQL DB for all CD's by all artists when the page is first opened. I am 
now trying to implement 
the same query but with a WHERE clause that filters the returned CD's to 
be displayed in the same select box according to the artist selected via a 
group of checkboxes (one per artist).  The problem so far is that if I try 
to implement some flow control (if checbox one is selected, append where 
artist='hendrix' to the select all CDs query, mysql_query() etc...), I get 
an error message saying that the query string is empty. So I am looking 
for some advice about how to implement the logic of having the same select 
box display the results of different but related queries.

For example, 

$query_1 = SELECT CD_title FROM CDs order by CD_title;
$result_1 = mysql_query($query_1) or die(Can't select CD_title from CDs 
. mysql_error());
while($row=mysql_fetch_array($result_1, MYSQL_BOTH)) ..etc...

works just fine.

But if I try to use some flow control to alter which query statement is 
assigned to $query_1...

if(checkbox one is selected)
{
$query_1 = SELECT CD_title FROM CDs WHERE artist_name = 'Hendrix' 
order by CD_title;
}

elseif(no checkboxes are checked)
{ 
$query_1 = SELECT CD_title FROM CDs order by CD_title;
}

$result_1 = mysql_query($query_1) or die(Can't select CD_title from CDs 
. mysql_error());
while($row=mysql_fetch_array($result_1, MYSQL_BOTH)) ..etc...

produces the error message stated above ... that the query string is 
empty. I've also tried to duplicate the mysql_query($query_1) or 
die()... within each section of the IF group, but then the select box 
does not get populated at all.

I am using session variables, and I'm certain that the checkboxes are 
correctly assigning the necessary values to the variables associated with 
them because I am echo'ing the variables and I can see the values that 
they have.

And when I run the query with the where clause in the MySQL client, it 
works just fine.

I'm guessing I'm missing something fairly simple because this type of 
functionality must have been implemented before.

Thanks for reading the rather long question. 

David

RE: [PHP-DB] Query Filter in GUI

2003-09-22 Thread Griffiths, Daniel
how are you testing the check boxes?, looks like the the query string is empty because 
both the tests you are doing in the code below return false.

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: 22 September 2003 15:01
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Query Filter in GUI


Good Morning PHP-DB Listers,

I have a PHP GUI in which a select box gets populated by a query of a 
MySQL DB for all CD's by all artists when the page is first opened. I am 
now trying to implement 
the same query but with a WHERE clause that filters the returned CD's to 
be displayed in the same select box according to the artist selected via a 
group of checkboxes (one per artist).  The problem so far is that if I try 
to implement some flow control (if checbox one is selected, append where 
artist='hendrix' to the select all CDs query, mysql_query() etc...), I get 
an error message saying that the query string is empty. So I am looking 
for some advice about how to implement the logic of having the same select 
box display the results of different but related queries.

For example, 

$query_1 = SELECT CD_title FROM CDs order by CD_title;
$result_1 = mysql_query($query_1) or die(Can't select CD_title from CDs 
. mysql_error());
while($row=mysql_fetch_array($result_1, MYSQL_BOTH)) ..etc...

works just fine.

But if I try to use some flow control to alter which query statement is 
assigned to $query_1...

if(checkbox one is selected)
{
$query_1 = SELECT CD_title FROM CDs WHERE artist_name = 'Hendrix' 
order by CD_title;
}

elseif(no checkboxes are checked)
{ 
$query_1 = SELECT CD_title FROM CDs order by CD_title;
}

$result_1 = mysql_query($query_1) or die(Can't select CD_title from CDs 
. mysql_error());
while($row=mysql_fetch_array($result_1, MYSQL_BOTH)) ..etc...

produces the error message stated above ... that the query string is 
empty. I've also tried to duplicate the mysql_query($query_1) or 
die()... within each section of the IF group, but then the select box 
does not get populated at all.

I am using session variables, and I'm certain that the checkboxes are 
correctly assigning the necessary values to the variables associated with 
them because I am echo'ing the variables and I can see the values that 
they have.

And when I run the query with the where clause in the MySQL client, it 
works just fine.

I'm guessing I'm missing something fairly simple because this type of 
functionality must have been implemented before.

Thanks for reading the rather long question. 

David

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



Re: [PHP-DB] Query Filter in GUI

2003-09-22 Thread CPT John W. Holmes
From: [EMAIL PROTECTED]

 I have a PHP GUI in which a select box gets populated by a query of a
 MySQL DB for all CD's by all artists when the page is first opened. I am
 now trying to implement
 the same query but with a WHERE clause that filters the returned CD's to
 be displayed in the same select box according to the artist selected via a
 group of checkboxes (one per artist).  The problem so far is that if I try
 to implement some flow control (if checbox one is selected, append where
 artist='hendrix' to the select all CDs query, mysql_query() etc...), I get
 an error message saying that the query string is empty. So I am looking
 for some advice about how to implement the logic of having the same select
 box display the results of different but related queries.

 For example,

 $query_1 = SELECT CD_title FROM CDs order by CD_title;
 $result_1 = mysql_query($query_1) or die(Can't select CD_title from CDs
 . mysql_error());
 while($row=mysql_fetch_array($result_1, MYSQL_BOTH)) ..etc...

 works just fine.

 But if I try to use some flow control to alter which query statement is
 assigned to $query_1...

 if(checkbox one is selected)
 {
 $query_1 = SELECT CD_title FROM CDs WHERE artist_name = 'Hendrix'
 order by CD_title;
 }

 elseif(no checkboxes are checked)
 {
 $query_1 = SELECT CD_title FROM CDs order by CD_title;
 }

 $result_1 = mysql_query($query_1) or die(Can't select CD_title from CDs
 . mysql_error());
 while($row=mysql_fetch_array($result_1, MYSQL_BOTH)) ..etc...

 produces the error message stated above ... that the query string is
 empty. I've also tried to duplicate the mysql_query($query_1) or
 die()... within each section of the IF group, but then the select box
 does not get populated at all.

In order for you to get that error, neither of your two conditions are TRUE.
Since you have pseudo-code, it's hard to tell where the problem is,
though.Something in (checkbox one is selected) and (no checkboxes are
checked) is not right.

Here's an easy way to do this, though, so pay attention. :)

Create your checkboxes like this:

input type=checkbox name=artist[] value=Hendrix
input type=checkbox name=artist[] value=Violent Femmes
etc...

Notice how they are all named the same and have different value.

Now, when processing this form, you'll have a variable $_GET['artist']
that's an array. If a checkbox was checked, then the array will have some
elements, otherwise it'll be empty and not set... so use something like
this:

if(isset($_GET['artist'])  is_array($_GET['artist']) 
!empty($_GET['artist']))
{
  $artist_list = ' . implode(',',$_GET['artist']) . ';
  $query = SELECT CD_title FROM CDs WHERE artist_name IN ($artist_list)
order by CD_title;
}
else
{
  $query = SELECT CD_title FROM CDs order by CD_title;
}

Then run your query and retrieve the results like you are doing now. What
this will to is take multiple checkboxes selected by the user (or just one
if you want) and make it into a comma separated list to send to the query.
So if two checkboxes are selected, you end up with a query such as:

WHERE artist_name IN ('Hendrix','Violent Femmes')

Hope that helps.

---John Holmes...

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



[PHP-DB] Count down

2003-09-22 Thread Frank McIsaac
Hi all.  I was wanting to make a page that takes a set date and
counts down to zero displaying days, minutes, and seconds.  Basically, I
want it to count down from the current date and time until a future date
and time is reached (ie.  Sept. 30th is x days, y minutes, and z seconds
away from right now).  Is this possible?  If so, how.  Thanks for the
help.

Frank

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

[PHP-DB] Query FIlter in GUI

2003-09-22 Thread dpgirago
Thank you CPT John W. Holmes. I'll give it a try.

 David

Re: [PHP-DB] MySQL: How to properly extract fields from retrieved single record ???

2003-09-22 Thread Ignatius Reilly
read the PHP manual and examples under the function mysql_fetch_array().

I find the MySQL manual is very well done and helpful. I've been using it as
a reference for 2 years. Take a harder look!

Ignatius
_
- Original Message -
From: -{ Rene Brehmer }- [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, September 22, 2003 1:57 PM
Subject: [PHP-DB] MySQL: How to properly extract fields from retrieved
single record ???


 Hi gang

 Still working on this DB for my gameclan not that it's essential what
 it's for... and be warned: Never worked with any form of DB in PHP before
I
 began this project, so I'm a total n00b at these MySQL commands (and the
 manual for MySQL is by far nowhere near as good as the PHP one).

 Anyways, I'm retrieving a single record from the DB table, and then,
 because of the way the data needs to be displayed and manipulated, need to
 extract every single field from that record as a seperate value.

 I tried this:

  $num2edit = $_POST['edit'];
  $link = mysql_connect($host,$username,$password)
or die('Could not connect : '.mysql_error());
  mysql_select_db($database) or die('Could not select database');

  $query = SELECT
 countryNum,country,nw,gov,strat,spy,troops,jets,turrets,tanks,ally,owner
 FROM a2a WHERE countryNum=$num2edit;
  $result = mysql_query($query);

  $countryNum = mysql_result($result,1,'countryNum');
  $country = mysql_result($result,1,'country');
  $nw = mysql_result($result,1,'nw');
  $gov = mysql_result($result,1,'gov');
  $strat = mysql_result($result,1,'strat');
  $spy = mysql_result($result,1,'spy');
  $troops = mysql_result($result,1,'troops');
  $jets = mysql_result($result,1,'jets');
  $turrets = mysql_result($result,1,'turrets');
  $tanks = mysql_result($result,1,'tanks');
  $ally = mysql_result($result,1,'ally');
  $owner = mysql_result($result,1,'owner');

  /* Free resultset */
  mysql_free_result($result);
  /* Closing connection */
  mysql_close($link);

 But all it gives me are errors like this:

 Warning: mysql_result(): supplied argument is not a valid MySQL result
 resource in E:\web\mpe\a2aedit.php on line 350
 Warning: mysql_result(): supplied argument is not a valid MySQL result
 resource in E:\web\mpe\a2aedit.php on line 351
 Warning: mysql_result(): supplied argument is not a valid MySQL result
 resource in E:\web\mpe\a2aedit.php on line 352
 Warning: mysql_result(): supplied argument is not a valid MySQL result
 resource in E:\web\mpe\a2aedit.php on line 353
 Warning: mysql_result(): supplied argument is not a valid MySQL result
 resource in E:\web\mpe\a2aedit.php on line 354
 Warning: mysql_result(): supplied argument is not a valid MySQL result
 resource in E:\web\mpe\a2aedit.php on line 355
 Warning: mysql_result(): supplied argument is not a valid MySQL result
 resource in E:\web\mpe\a2aedit.php on line 356
 Warning: mysql_result(): supplied argument is not a valid MySQL result
 resource in E:\web\mpe\a2aedit.php on line 357
 Warning: mysql_result(): supplied argument is not a valid MySQL result
 resource in E:\web\mpe\a2aedit.php on line 358
 Warning: mysql_result(): supplied argument is not a valid MySQL result
 resource in E:\web\mpe\a2aedit.php on line 359
 Warning: mysql_result(): supplied argument is not a valid MySQL result
 resource in E:\web\mpe\a2aedit.php on line 360
 Warning: mysql_result(): supplied argument is not a valid MySQL result
 resource in E:\web\mpe\a2aedit.php on line 361

 Obviously, the first mysql_result line is line 350 in the full code. I've
 also tried changing the row number to 0, but results in the same errors.

 I can't find any decent reference on the web that shows how to do this -
 field extraction - when there's only the single record. So I've been
mixing
 code from various places. And I don't even know if it retrieves the right
 record, or any record at all (how do I test that?).

 Any help is highly appreciated :)

 TIA

 Rene
 --
 Rene Brehmer
 aka Metalbunny

 http://metalbunny.net/
 References, tools, and other useful stuff...

 --
 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] Count down

2003-09-22 Thread Peter Beckman
On Mon, 22 Sep 2003, Frank McIsaac wrote:

 Hi all.  I was wanting to make a page that takes a set date and
 counts down to zero displaying days, minutes, and seconds.  Basically, I
 want it to count down from the current date and time until a future date
 and time is reached (ie.  Sept. 30th is x days, y minutes, and z seconds
 away from right now).  Is this possible?  If so, how.  Thanks for the
 help.

 $futuretime = strtotime(9/30/2003 12:00:00);

 $difftime = $futuretime - time();

 $days = (int)($difftime/86400);
 $leftover = $difftime%86400;
 $minutes = (int)($leftover/1440);
 $leftover = $leftover%1440;
 $seconds = $leftover;

 printf(Future Time is %d day%s, %d minute%s, and %d second%s away from
 now., $days, $days==1?:s,
$minutes, $minutes==1?:s,
$seconds, $seconds==1?:s);

Beckman
---
Peter Beckman  Internet Guy
[EMAIL PROTECTED] http://www.purplecow.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

Re: [PHP-DB] Count down

2003-09-22 Thread Peter Beckman
On Mon, 22 Sep 2003, Peter Beckman wrote:

 On Mon, 22 Sep 2003, Frank McIsaac wrote:

  Hi all.  I was wanting to make a page that takes a set date and
  counts down to zero displaying days, minutes, and seconds.  Basically, I
  want it to count down from the current date and time until a future date
  and time is reached (ie.  Sept. 30th is x days, y minutes, and z seconds
  away from right now).  Is this possible?  If so, how.  Thanks for the
  help.

  $futuretime = strtotime(9/30/2003 12:00:00);

  $difftime = $futuretime - time();

  $days = (int)($difftime/86400);
  $leftover = $difftime%86400;
  $minutes = (int)($leftover/1440);
  $leftover = $leftover%1440;

 Whoops.  Change 1440 to 60 in the above two lines.

  $seconds = $leftover;

  printf(Future Time is %d day%s, %d minute%s, and %d second%s away from
  now., $days, $days==1?:s,
 $minutes, $minutes==1?:s,
 $seconds, $seconds==1?:s);

Beckman
---
Peter Beckman  Internet Guy
[EMAIL PROTECTED] http://www.purplecow.com/
---

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



Re: [PHP-DB] MySQL: How to properly extract fields from retrieved single record ???

2003-09-22 Thread George Patterson
On Mon, 22 Sep 2003 13:06:37 +0200
Ignatius Reilly [EMAIL PROTECTED] wrote:

 read the PHP manual and examples under the function
 mysql_fetch_array().
 
 I find the MySQL manual is very well done and helpful. I've been using
 it as a reference for 2 years. Take a harder look!
   
I think Ignatius meant the PHP manual... It is rather terse, but the
functions have been categorised to make it easier to find.

See code alteration below.


George Patterson



 Ignatius
 
  Hi gang
 
-snipped--
 
  I tried this:
 
   $num2edit = $_POST['edit'];
   $link = mysql_connect($host,$username,$password)
 or die('Could not connect : '.mysql_error());
   mysql_select_db($database) or die('Could not select database');
 
   $query = SELECT
  countryNum,country,nw,gov,strat,spy,troops,jets,turrets,tanks,ally,
  owner FROM a2a WHERE countryNum=$num2edit;
   $result = mysql_query($query);
 
   $countryNum = mysql_result($result,1,'countryNum');
   $country = mysql_result($result,1,'country');
   $nw = mysql_result($result,1,'nw');
   $gov = mysql_result($result,1,'gov');
   $strat = mysql_result($result,1,'strat');
   $spy = mysql_result($result,1,'spy');
   $troops = mysql_result($result,1,'troops');
   $jets = mysql_result($result,1,'jets');
   $turrets = mysql_result($result,1,'turrets');
   $tanks = mysql_result($result,1,'tanks');
   $ally = mysql_result($result,1,'ally');
   $owner = mysql_result($result,1,'owner');
 
   /* Free resultset */
   mysql_free_result($result);
   /* Closing connection */
   mysql_close($link);
 
  But all it gives me are errors like this:
 
  Warning: mysql_result(): supplied argument is not a valid MySQL
  result resource in E:\web\mpe\a2aedit.php on line 350
  Warning: mysql_result(): supplied argument is not a valid MySQL
Duplicate error message delete...
 
  Obviously, the first mysql_result line is line 350 in the full code.
  I've also tried changing the row number to 0, but results in the
  same errors.
 

This ain't microsoft anymore...

$num2edit = $_POST['edit'];
$link = mysql_connect($host,$username,$password)
 or die('Could not connect : '.mysql_error());
mysql_select_db($database) or die('Could not select database');

$query = SELECT countryNum, country, nw, gov, strat, spy, troops, jets,
turrets, tanks, ally, owner FROM a2a WHERE countryNum=$num2edit;
echo This is for test only: Print Query- $querybr\n;
$result = mysql_query($query);

$row=mysql_fetch_assoc($result); #$row is an array. 

#display the row retrived from the database. For you information only.
 echo pre\n;
print_r($row);
echo /pre\n;

$countryNum = $row['countryNum'];
$country = $row['country'];
$nw = $row['nw'];

#then close the database connection... 
As you had it...


  I can't find any decent reference on the web that shows how to do
  this - field extraction - when there's only the single record. So
  I've been mixing code from various places. And I don't even know if
  it retrieves the right record, or any record at all (how do I test
  that?).
 
  Any help is highly appreciated :)
 
  TIA
 
  Rene
  --
  Rene Brehmer
  aka Metalbunny
 

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



Re: [PHP-DB] Pop3?

2003-09-22 Thread andu
On Mon, 22 Sep 2003 16:04:06 -0400
Chris Payne [EMAIL PROTECTED] wrote:

 Hi there,
 
 I get an error about a T_Variable here:
 
 $messg_list=pop3_list($id);
 print_r $messg_list;

print_r($messg_list);

 pop3_quit($id);

My mistake but you can't really use php without learning it. Having looked up
print_r in the manual you would've noticed what was missing.
The danger here is that if you don't do your part you will prove those who just
answer RTFM right.

 
 (The print_r line).  If I change $messg_list to $id on the print_r line, it
 doesn't give me that error by rather the ID Number, but I try with the
 $messg_list I get a T_Variable error, any ideas?
 
 BTW, I haven't touched your functions so they are the same as you sent to
 the list, I just changed the details for my pop3 server which logs in fine
 as if I put in a wrong password it knows it's wrong :-)
 
 Chris
 
  On Sunday, September 21, 2003, at 11:58  PM, Chris Payne wrote:
 
   Hi there,
  
   Thanks for that, very appreciated, just one question?  Without meaning
   to
   sound dumb (Which I probably will) how do I call your function?  I
   don't
   usually deal with functions, I know I need to start though .
  
   Chris
  
  Don't have time to test but this is the idea:
  ?php
  require_once('pop3_fcn.php');
 
  $id=open_pop3(server,110,username,passwd);
 
  $messg_list=pop3_list($id);
  print_r $messg_list;
  pop3_quit($id);
  ?
 
  Andu
 
 
 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 



Regards, Andu Novac

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



Re: [PHP-DB] Pop3?

2003-09-22 Thread Chris Payne
Hi there,

Thanks for your help :-)  Oh and I did read the manual, found it about 20
minutes after I sent the emeial but got sidetracked and forgot to post i'd
figured it out in the group - sorry :-)

Chris

 On Mon, 22 Sep 2003 16:04:06 -0400
 Chris Payne [EMAIL PROTECTED] wrote:

  Hi there,
 
  I get an error about a T_Variable here:
 
  $messg_list=pop3_list($id);
  print_r $messg_list;

 print_r($messg_list);

  pop3_quit($id);

 My mistake but you can't really use php without learning it. Having looked
up
 print_r in the manual you would've noticed what was missing.
 The danger here is that if you don't do your part you will prove those who
just
 answer RTFM right.

 
  (The print_r line).  If I change $messg_list to $id on the print_r line,
it
  doesn't give me that error by rather the ID Number, but I try with the
  $messg_list I get a T_Variable error, any ideas?
 
  BTW, I haven't touched your functions so they are the same as you sent
to
  the list, I just changed the details for my pop3 server which logs in
fine
  as if I put in a wrong password it knows it's wrong :-)
 
  Chris
 
   On Sunday, September 21, 2003, at 11:58  PM, Chris Payne wrote:
  
Hi there,
   
Thanks for that, very appreciated, just one question?  Without
meaning
to
sound dumb (Which I probably will) how do I call your function?  I
don't
usually deal with functions, I know I need to start though .
   
Chris
   
   Don't have time to test but this is the idea:
   ?php
   require_once('pop3_fcn.php');
  
   $id=open_pop3(server,110,username,passwd);
  
   $messg_list=pop3_list($id);
   print_r $messg_list;
   pop3_quit($id);
   ?
  
   Andu
  
 
  -- 
  PHP Database Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 


 
 Regards, Andu Novac

 -- 
 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] Auto load data

2003-09-22 Thread ascll
Greetings,

I'm designing a table with 21 columns and 3 rows (1-row column header, 2-row
data) store in .php file, and each cell of this table storing a value, that
I stored it using MySQL database. Now, I want all the values (just the
values, but NOT the table) shown on this page automatic update every
1-second.

So, I use create_table.php to create the table and automatic load
get_data.php every 1-second to retrieve data from database. Once the
get_data.php loaded, my IE only show those data and the table disappeared.

Please help. Thanks in advance.


== start create_table.php 

html
head
titleMember Area/title
META HTTP-EQUIV=Refresh CONTENT=5; URL=get_data.php
/head
body
center

table bgcolor=#EE border=0 width=95%trtd
table bgcolor=#B6C7E5 border=0 width=100%trtd
  table bgcolor=#FF border=0 width=100%trtd

table border=0 bgcolor=#F7F7FF width=100%
  trth colspan=21font size=+1RACING RESULT/font/td/tr
  tr bgcolor=#FFth colspan=21/tr

  tr
  td width=20%1st row/tdtd width=4%1/tdtd
width=4%2/tdtd width=4%3/tdtd width=4%4/td
  td width=4%5/tdtd width=4%6/tdtd width=4%7/tdtd
width=4%8/tdtd width=4%9/td
  td width=4%10/tdtd width=4%11/tdtd
width=4%12/tdtd width=4%13/tdtd width=4%14/td
  td width=4%15/tdtd width=4%16/tdtd
width=4%17/tdtd width=4%18/tdtd width=4%19/tdtd
width=4%20/td
  /tr

  tr
  td width=20%2nd row/tdtd width=4%' . $myWin1 . '/tdtd
width=4%' . $myWin2 . '/tdtd width=4%' . $myWin3 . '/td
  td width=4%' . $myWin4 . '/tdtd width=4%' . $myWin5 .
'/tdtd width=4%' . $myWin6 . '/tdtd width=4%' . $myWin7 . '/td
  td width=4%' . $myWin8 . '/tdtd width=4%' . $myWin9 .
'/tdtd width=4%' . $myWin10 . '/tdtd width=4%' . $myWin11 .
'/td
  td width=4%' . $myWin12 . '/tdtd width=4%' . $myWin13 .
'/tdtd width=4%' . $myWin14 . '/tdtd width=4%' . $myWin15 .
'/td
  td width=4%' . $myWin16 . '/tdtd width=4%' . $myWin17 .
'/tdtd width=4%' . $myWin18 . '/tdtd width=4%' . $myWin19 .
'/td
  td width=4%' . $myWin20 . '/td
  /tr

  tr
  td width=20%3rd row/tdtd width=4%' . $myPlace1 .
'/tdtd width=4%' . $myPlace2 . '/tdtd width=4%' . $myPlace3 .
'/td
  td width=4%' . $myPlace4 . '/tdtd width=4%' . $myPlace5
. '/tdtd width=4%' . $myPlace6 . '/tdtd width=4%' . $myPlace7 .
'/td
  td width=4%' . $myPlace8 . '/tdtd width=4%' . $myPlace9
. '/tdtd width=4%' . $myPlace10 . '/tdtd width=4%' . $myPlace11
. '/td
  td width=4%' . $myPlace12 . '/tdtd width=4%' .
$myPlace13 . '/tdtd width=4%' . $myPlace14 . '/tdtd width=4%' .
$myPlace15 . '/td
  td width=4%' . $myPlace16 . '/tdtd width=4%' .
$myPlace17 . '/tdtd width=4%' . $myPlace18 . '/tdtd width=4%' .
$myPlace19 . '/td
  td width=4%' . $myPlace20 . '/td
  /tr

/table
  /td/tr/table
/td/tr/table
/td/tr/table
/center
/body
/html

== end create_table.php 


== start get_data.php 

?php
$result = @mysql_query('SELECT `myWin1`, `myWin2`, `myWin3`, `myWin4`,
`myWin5`, `myWin6`, `myWin7`, `myWin8`, `myWin9`, `myWin10`, `myWin11`,
`myWin12`, `myWin13`, `myWin14`, `myWin15`, `myWin16`, `myWin17`, `myWin18`,
`myWin19`, `myWin20`, `myPlace1`, `myPlace2`, `myPlace3`, `myPlace4`,
`myPlace5`, `myPlace6`, `myPlace7`, `myPlace8`, `myPlace9`, `myPlace10`,
`myPlace11`, `myPlace12`, `myPlace13`, `myPlace14`, `myPlace15`,
`myPlace16`, `myPlace17`, `myPlace18`, `myPlace19`, `myPlace20` FROM
Testing');
if (!$result) {
die('pError performing query: ' . mysql_error() . '/p');
}


while ( $row = mysql_fetch_array($result) )
{
  $myWin1 = $row['0'];
  $myWin2 = $row['1'];
  $myWin3 = $row['2'];
  $myWin4 = $row['3'];
  $myWin5 = $row['4'];
  $myWin6 = $row['5'];
  $myWin7 = $row['6'];
  $myWin8 = $row['7'];
  $myWin9 = $row['8'];
  $myWin10 = $row['9'];
  $myWin11 = $row['10'];
  $myWin12 = $row['11'];
  $myWin13 = $row['12'];
  $myWin14 = $row['13'];
  $myWin15 = $row['14'];
  $myWin16 = $row['15'];
  $myWin17 = $row['16'];
  $myWin18 = $row['17'];
  $myWin19 = $row['18'];
  $myWin20 = $row['19'];
  $myPlace1 = $row['20'];
  $myPlace2 = $row['21'];
  $myPlace3 = $row['22'];
  $myPlace4 = $row['23'];
  $myPlace5 = $row['24'];
  $myPlace6 = $row['25'];
  $myPlace7 = $row['26'];
  $myPlace8 = $row['27'];
  $myPlace9 = $row['28'];
  $myPlace10 = $row['29'];
  $myPlace11 = $row['30'];
  $myPlace12 = $row['31'];
  $myPlace13 = $row['32'];
  $myPlace14 = $row['33'];
  $myPlace15 = $row['34'];
  $myPlace16 = $row['35'];
  $myPlace17 = $row['36'];
  $myPlace18 = $row['37'];
  $myPlace19 = $row['38'];
  $myPlace20 = $row['39'];


echo('trtd width=20%2nd row/tdtd width=4%' . $myWin1 . '/tdtd
width=4%' . $myWin2 . '/tdtd width=4%' . $myWin3 . '/td
td width=4%' . $myWin4 . '/tdtd width=4%' . $myWin5 . '/tdtd
width=4%' . $myWin6 . '/tdtd width=4%' . $myWin7 . '/td
td width=4%' . $myWin8 . '/tdtd width=4%' . $myWin9 .