[PHP-DB] Displaying by post time instead of topic time...

2001-04-28 Thread David Balatero

Ok, I have a forum script I’m writing with the following table
structure:
 
///
 
CREATE TABLE forum_topics (
   topic_id int(11) NOT NULL auto_increment,
   topic_title varchar(100) NOT NULL,
   topic_poster int(11) DEFAULT '0' NOT NULL,
   topic_time int(14) DEFAULT '0' NOT NULL,
   topic_views int(10) DEFAULT '0' NOT NULL,
   forum_id int(10) DEFAULT '0' NOT NULL,
   topic_status int(10) DEFAULT '0' NOT NULL,
   topic_notify int(2) DEFAULT '0' NOT NULL,
   PRIMARY KEY (topic_id)
);
 
 
CREATE TABLE forum_posts (
   post_id int(11) NOT NULL auto_increment,
   topic_id int(11) DEFAULT '0' NOT NULL,
   forum_id int(11) DEFAULT '0' NOT NULL,
   poster_id int(11) DEFAULT '0' NOT NULL,
   post_text text NOT NULL,
   post_time int(14) DEFAULT '0' NOT NULL,
   poster_ip varchar(16) NOT NULL,
   PRIMARY KEY (post_id)
);
 
/
 
The posts are linked to the topics using the topic_id field in each one.
As well, topic_time and post_time are both UNIX datestamps that are made
with mktime(). My current sql and display code is:
 
Error: Could not query forum
database.".$sql."Mysql said:".mysql_error()."");
 
while ($myrow = mysql_fetch_array($result)) {
  if ($i % 2) {
 echo '';
  }
  else {
 echo '';
  }
  $i++;
  // the following three vars are custom functions I wrote, don’t
worry about them.
  $poster = getUserName($myrow["topic_poster"]);  
  $replies = (getTotalPosts($myrow["topic_id"], "topic") - 1);  
  $lastpost = getLastPost($myrow["topic_id"]); // post_time,
poster_id, username as array()
  $date = returnDateNoTime($lastpost["post_time"]);
  $user = $lastpost["username"];
 
  echo ' ';
  echo ''.$font.''.$myrow["topic_title"].'
';
  echo ''.$font.$poster.'';
  echo ''.$font.$myrow["topic_views"].'';
  echo "$font$user posted on
$date";
  echo ''.$font.$replies.'';
  echo '';
}
 
?>
 
What I’m doing right now is querying the database and pulling out the
latest topics in order of topic creation. What I want to do is ORDER
them by the most recent post_time in each topic. If anyone has any
suggestions on how I might do that, I’d be very grateful.
 
Thanks!
David Balatero
[EMAIL PROTECTED]
 
 



RE: [PHP-DB] Inserting correct value from database into formoption field

2001-04-28 Thread Rudi Benkoviè

> For example,
>
> 
> If ($row['voyage'] == 'One voyage only') { echo ' selected'; }
>
> ?>>One voyage only

Perhaps even a bit more elegant solution:



>One voyage
only



It's just that a bunch of IF's look darn ugly if you have ~25 options.


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] Select statements - A Quest !!!

2001-04-28 Thread Bob Hall

>I have two tables namely,
>1. cpkaizen : The following is the desc
>
>Field | Type | Null | Key | Default | Extra |
>++--+--+-+-++
>| kno | int(10) | | PRI | NULL | auto_increment |
>| loginid | varchar(20) | YES | | NULL | |
>| period | varchar(6) | YES | | NULL | |
>| peryear | int(5) | YES | | NULL | |
>| star | char(1) | YES | | N | |
>| name1 | varchar(30) | YES | | NULL | |
>| name2 | varchar(30) | YES | | NULL | |
>| name3 | varchar(30) | YES | | NULL | |
>| name4 | varchar(30) | YES | | NULL | |
>| date | date | YES | | NULL | |
>| problem | varchar(255) | YES | | NULL | |
>| action | varchar(255) | YES | | NULL | |
>| result | varchar(255) | YES | | NULL | |
>| benefit | varchar(255) | YES | | NULL | |
>| evalution_para | varchar(100) | YES | | NULL | |
>| dept | varchar(20) | YES | | NULL | |
>| name0 | varchar(30) | YES | | NULL | |
>
>(* the records in this table are KAIZENS. dept is of that employee 
>i.e either \'ms\' or fin,com,log,epcm,po,ms,hr . *)
>
>2. employee : following is the desc
>
>Field | Type | Null | Key | Default | Extra |
>+---+-+--+-+-+---+
>| edpno | int(10) | YES | | NULL | |
>| name | varchar(40) | | | | |
>| loginid | varchar(20) | YES | | NULL | |
>| superuser | char(1) | YES | | N | |
>| groupno | int(4) | YES | | NULL | |
>| dept | varchar(30) | YES | | NULL | |
>| sub_dept | varchar(30) | YES | | NULL | |
>
>(* dept is common for employees i.e \'cp\' but sub_depts are 
>fin,com,log,epcm,po,ms,hr . So there are more than one employee in 
>each sub_dept *)
>
>Now actually, I want to generate the report :
>
>the output should be :
>
>Department | Total no of employee | Total KAizen | Average

Average what?

>
>(* here under departments should come the above seven mentioned.
>then total no of employees in eeach sub_dept.
>Then total no of KAIZENS for that sub_dept from table cpkaizen
>and
>Average which is Total no of kaizen divide by total no of employees *)
>
>How can I go ahead to get that output table generated.
>
>Thank you,
>Pranot

Sir, from looking at your tables, I can't tell which contains the 
parent records and which contains the child records. I might be able 
to figure it out if know what a kaizen is. You haven't declared any 
primary keys on the employee table, and you didn't say which DBMS 
you're using.

In general, pattern is

SELECT dept, Count(p.something), Count(c.something_else), Avg(some_column)
FROM parent_table AS p INNER JOIN child_table AS c ON p.id = c.p_id
GROUP BY dept;

The actual syntax depends on your DBMS.

Bob Hall

Know thyself? Absurd direction!
Bubbles bear no introspection. -Khushhal Khan Khatak
MySQL list magic words: sql query database

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] Inserting correct value from database into formoption field

2001-04-28 Thread Paul Burney

on 4/28/01 1:32 AM, Howard Picken at [EMAIL PROTECTED] wrote:

> Which Voyage: value="">
> 
>   One voyage only

In an HTML , you can't specify the value in the select tag (btw, you
can't specify cols or rows either).  To specify the item to pick, you must
add a " selected" keyword to the appropriate option tag.  Typically in PHP,
this is done with a series of if statements.

For example,

>One voyage only

Hope that helps,

Paul Burney
http://paulburney.com/
http://webdevel.burney.ws/


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] How to randomly select data in a field. Please help newbie.

2001-04-28 Thread Greg K

Can someone explain to me the best way to randomly select data from field
that consist of urls. The fields consist  urls that  are images of people. I
believe I have to setup that field as a array and turn it into a interger.
But I have no experience doing this can someone sort of give me a example on
how I would do this .

Thank you ..

Your Help would be well appreciate it ..





-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] ibm db2

2001-04-28 Thread Dan Scott

Yup, there's been PHP support for DB2 on Linux for quite some time. Use the 
--with-ibm-db2[=name] configure option when you build PHP. Then use the 
Unified ODBC PHP functions and you're rocking. Under the covers PHP uses 
DB2's native CLI interface, so it's quite fast.

(By the way, IBM has been making DB2 available on Linux for a couple of 
years now; they shipped a beta version of DB2 5.2, then shipped production 
versions of V6.1 and V7.1. Check out the DB2 V7.1 for Linux HOWTO at 
http://www.linuxdoc.org/HOWTO/DB2-HOWTO for basic DB2 installation 
instructions on a number of different Linux distributions).

Dan

Mike Wright wrote:

> Hi All,
> 
> I've noticed that IBM is making its DB2 database available
> for Linux platforms. Does anyone know if there will be PHP
> support for it?
> 
> Thank you,
> Mike Wright
> 


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] newbie: showing records from SQL

2001-04-28 Thread Andreas D. Landmark

At 28.04.2001 18:06, you wrote:
>Hello,
>
>I'm new at php... I've done a little SQL with visual basic in the past, and
>now I would like to publish a database online...
>
>I managed to find out how to add records in my table, but I can't find out
>how to show records...
>Are there manuals on the web that are specific to php & sql?
>I've found manuals for both, but they both give only a little bit of
>information, and refer to the other website for more information...
>
>or is there anyone who can give me a simple example, where the page just
>renders all the records?
>and one where the page renders all records where name is "Jhon"
>
>Thanx
>
>2peak
>
click on links at php.net and look under tutorials (or similar) there you 
should find
a couple of tutorials and guides to get you started, it simpler than you 
think...

If you look in the annotated manual you'll probably find some examples 
there too.


--
Andreas D. Landmark / noXtension
PGP ID:0xB2BEAE80 / 4096bits
Fingerprint:654B 3BCD 1130 9B3A 08BB  AB1A BF72 841D B2BE AE80


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] newbie: showing records from SQL

2001-04-28 Thread twopeak

Hello,

I'm new at php... I've done a little SQL with visual basic in the past, and
now I would like to publish a database online...

I managed to find out how to add records in my table, but I can't find out
how to show records...
Are there manuals on the web that are specific to php & sql?
I've found manuals for both, but they both give only a little bit of
information, and refer to the other website for more information...

or is there anyone who can give me a simple example, where the page just
renders all the records?
and one where the page renders all records where name is "Jhon"

Thanx

2peak



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] mySQL connection problem

2001-04-28 Thread LENNART KARLSSON

Hi!
I have a problem when I try to use a mySQL connection.
I run Win98SE, PWS 4 and php4. php is working.

When I try to run any mySQL scripts (v this one is a forum from
planet-source-code.com) I get this error:

Running:   mysql_pconnect("localhost","root");   -->
Warning: Can't connect to MySQL server on 'localhost' (10061) in x.php
on line xx.

What am I doing wrong?

/Eric



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] Select statements - A Quest !!!

2001-04-28 Thread Pranot Kokate

I have two tables namely, 
1. cpkaizen : The following is the desc 

Field | Type | Null | Key | Default | Extra | 
++--+--+-+-++ 
| kno | int(10) | | PRI | NULL | auto_increment | 
| loginid | varchar(20) | YES | | NULL | | 
| period | varchar(6) | YES | | NULL | | 
| peryear | int(5) | YES | | NULL | | 
| star | char(1) | YES | | N | | 
| name1 | varchar(30) | YES | | NULL | | 
| name2 | varchar(30) | YES | | NULL | | 
| name3 | varchar(30) | YES | | NULL | | 
| name4 | varchar(30) | YES | | NULL | | 
| date | date | YES | | NULL | | 
| problem | varchar(255) | YES | | NULL | | 
| action | varchar(255) | YES | | NULL | | 
| result | varchar(255) | YES | | NULL | | 
| benefit | varchar(255) | YES | | NULL | | 
| evalution_para | varchar(100) | YES | | NULL | | 
| dept | varchar(20) | YES | | NULL | | 
| name0 | varchar(30) | YES | | NULL | | 

(* the records in this table are KAIZENS. dept is of that employee i.e either \'ms\' 
or fin,com,log,epcm,po,ms,hr . *) 

2. employee : following is the desc 

Field | Type | Null | Key | Default | Extra | 
+---+-+--+-+-+---+ 
| edpno | int(10) | YES | | NULL | | 
| name | varchar(40) | | | | | 
| loginid | varchar(20) | YES | | NULL | | 
| superuser | char(1) | YES | | N | | 
| groupno | int(4) | YES | | NULL | | 
| dept | varchar(30) | YES | | NULL | | 
| sub_dept | varchar(30) | YES | | NULL | | 

(* dept is common for employees i.e \'cp\' but sub_depts are fin,com,log,epcm,po,ms,hr 
. So there are more than one employee in each sub_dept *) 

Now actually, I want to generate the report : 

the output should be : 

Department | Total no of employee | Total KAizen | Average 

(* here under departments should come the above seven mentioned. 
then total no of employees in eeach sub_dept. 
Then total no of KAIZENS for that sub_dept from table cpkaizen 
and 
Average which is Total no of kaizen divide by total no of employees *) 

How can I go ahead to get that output table generated. 

Thank you, 
Pranot



[PHP-DB] Inserting correct value from database into form option field

2001-04-28 Thread Howard Picken

Hi guys

Created a database and now I've done the pages for editing it.

This is what I have...

Which Voyage:">

One voyage only
First voyage
Second voyage
Third voyage
Fourth voyage
Fifth voyage
Sixth voyage
Various voyages


When I get the record and open it for editing it automatically selects the
first option from the list.
I would like it to show the original value from the stored record.

Any ideas??


Howard Picken
[EMAIL PROTECTED]
Launceston,  Tasmania, Australia


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]