RE: [PHP-DB] Re: UPDATE command

2005-06-20 Thread jusa_98
The trick is your using the wrong ' instead you need ` ...
 
go away from kl;-' and go to `-123 ;)
The key above the (Tab) key, or the key next to the number 1 above the q.  
 
so ...
 
$query=SELECT * FROM bibleverses WHERE `used` = 0 ORDER BY RAND() 
LIMIT 1;
 
When I first learned this also I was fooled and used ' instead of `.  But in 
some cases you don't need to use it also.
 
I hope this covers it!  Sorry if someone else has responded before me.  I might 
of been a bit slow! ;)

Jerry

 


From: Ron Piggott [EMAIL PROTECTED]
Reply-To: Ron Piggott [EMAIL PROTECTED]
To: Webmaster [EMAIL PROTECTED]
CC: PHP DB php-db@lists.php.net
Subject: [PHP-DB] Re: UPDATE command
Date: Fri, 17 Jun 2005 23:47:31 -0400

This is kind of interesting ...

$query=SELECT * FROM quiettimequotation WHERE used = 0 ORDER BY 
RAND()
LIMIT 1;

works;

$query=SELECT * FROM bibleverses WHERE 'used' = 0 ORDER BY RAND() 
LIMIT 
1;

doesn't!  Having the ' around used makes that select command fail --- 
but
the UPDATE command requires it!

Thanks for those of you who responded to my question below.  I am 
creating 
a
mailing list for my web site that I am wanting each entry which is 
randomly
selected from the database to only be used once and not be available 
again
until the entire list has been used.  I needed the UPDATE command to 
change
the used column all back to 0 again once the last entry had been 
selected
from the database.  I think I like programming mySQL stuff :)  Ron

---

 Does the UPDATE command only change one row or each occurance if the 
the
 criteria repeat itself through the table?

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


Send instant messages to your online friends http://au.messenger.yahoo.com 


**

IMPORTANT NOTICE

This communication is for the exclusive use of the intended recipient(s)
named above. If you receive this communication in error, you should
notify the sender by e-mail or by telephone (+44) 191 224 4461, delete
it and destroy any copies of it.

This communication may contain confidential information and material
protected by copyright, design right or other intellectual property
rights which are and shall remain the property of Piranha Studios
Limited. Any form of distribution, copying or other unauthorised use
of this communication or the information in it is strictly prohibited.
Piranha Studios Limited asserts its rights in this communication and
the information in it and reserves the right to take action against
anyone who misuses it or the information in it.

Piranha Studios Limited cannot accept any liability sustained as a
result of software viruses and would recommend that you carry out your
own virus checks before opening any attachment.


GWAVAsigAdmID:2D9388A3F9FA0C7BE52690ABC7B22408



**

IMPORTANT NOTICE

This communication is for the exclusive use of the intended recipient(s)
named above. If you receive this communication in error, you should
notify the sender by e-mail or by telephone (+44) 191 224 4461, delete
it and destroy any copies of it.

This communication may contain confidential information and material
protected by copyright, design right or other intellectual property
rights which are and shall remain the property of Piranha Studios
Limited. Any form of distribution, copying or other unauthorised use
of this communication or the information in it is strictly prohibited.
Piranha Studios Limited asserts its rights in this communication and
the information in it and reserves the right to take action against
anyone who misuses it or the information in it.

Piranha Studios Limited cannot accept any liability sustained as a
result of software viruses and would recommend that you carry out your
own virus checks before opening any attachment.


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

RE: [PHP-DB] Re: UPDATE command

2005-06-20 Thread bastien_k
used is a column name, if you need to surround it use the back ticks (beow 
the esc key, same button as the tilde (~). That is why it fails...it 
shouldn't be req'd for the update, though the value may need to be quoted 
depending on the col data type

Bastien

From: Ron Piggott [EMAIL PROTECTED]
Reply-To: Ron Piggott [EMAIL PROTECTED]
To: Webmaster [EMAIL PROTECTED]
CC: PHP DB php-db@lists.php.net
Subject: [PHP-DB] Re: UPDATE command
Date: Fri, 17 Jun 2005 23:47:31 -0400

This is kind of interesting ...

$query=SELECT * FROM quiettimequotation WHERE used = 0 ORDER BY RAND()
LIMIT 1;

works;

$query=SELECT * FROM bibleverses WHERE 'used' = 0 ORDER BY RAND() LIMIT 
1;

doesn't!  Having the ' around used makes that select command fail --- but
the UPDATE command requires it!

Thanks for those of you who responded to my question below.  I am creating 
a
mailing list for my web site that I am wanting each entry which is randomly
selected from the database to only be used once and not be available again
until the entire list has been used.  I needed the UPDATE command to change
the used column all back to 0 again once the last entry had been selected
from the database.  I think I like programming mySQL stuff :)  Ron

---

 Does the UPDATE command only change one row or each occurance if the the
 criteria repeat itself through the table?

--
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




**

IMPORTANT NOTICE

This communication is for the exclusive use of the intended recipient(s)
named above. If you receive this communication in error, you should
notify the sender by e-mail or by telephone (+44) 191 224 4461, delete
it and destroy any copies of it.

This communication may contain confidential information and material
protected by copyright, design right or other intellectual property
rights which are and shall remain the property of Piranha Studios
Limited. Any form of distribution, copying or other unauthorised use
of this communication or the information in it is strictly prohibited.
Piranha Studios Limited asserts its rights in this communication and
the information in it and reserves the right to take action against
anyone who misuses it or the information in it.

Piranha Studios Limited cannot accept any liability sustained as a
result of software viruses and would recommend that you carry out your
own virus checks before opening any attachment.


GWAVAsigAdmID:2D9388A3F9FA0C7BE52690ABC7B22408



**

IMPORTANT NOTICE

This communication is for the exclusive use of the intended recipient(s)
named above. If you receive this communication in error, you should
notify the sender by e-mail or by telephone (+44) 191 224 4461, delete
it and destroy any copies of it.

This communication may contain confidential information and material
protected by copyright, design right or other intellectual property
rights which are and shall remain the property of Piranha Studios
Limited. Any form of distribution, copying or other unauthorised use
of this communication or the information in it is strictly prohibited.
Piranha Studios Limited asserts its rights in this communication and
the information in it and reserves the right to take action against
anyone who misuses it or the information in it.

Piranha Studios Limited cannot accept any liability sustained as a
result of software viruses and would recommend that you carry out your
own virus checks before opening any attachment.


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

[PHP-DB] Re: UPDATE command

2005-06-20 Thread ron . php
This is kind of interesting ...

$query=SELECT * FROM quiettimequotation WHERE used = 0 ORDER BY RAND()
LIMIT 1;

works;

$query=SELECT * FROM bibleverses WHERE 'used' = 0 ORDER BY RAND() LIMIT 1;

doesn't!  Having the ' around used makes that select command fail --- but
the UPDATE command requires it!

Thanks for those of you who responded to my question below.  I am creating a
mailing list for my web site that I am wanting each entry which is randomly
selected from the database to only be used once and not be available again
until the entire list has been used.  I needed the UPDATE command to change
the used column all back to 0 again once the last entry had been selected
from the database.  I think I like programming mySQL stuff :)  Ron

---

Does the UPDATE command only change one row or each occurance if the the
criteria repeat itself through the table?

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




**

IMPORTANT NOTICE

This communication is for the exclusive use of the intended recipient(s)
named above. If you receive this communication in error, you should
notify the sender by e-mail or by telephone (+44) 191 224 4461, delete
it and destroy any copies of it.

This communication may contain confidential information and material
protected by copyright, design right or other intellectual property
rights which are and shall remain the property of Piranha Studios
Limited. Any form of distribution, copying or other unauthorised use
of this communication or the information in it is strictly prohibited.
Piranha Studios Limited asserts its rights in this communication and
the information in it and reserves the right to take action against
anyone who misuses it or the information in it.

Piranha Studios Limited cannot accept any liability sustained as a
result of software viruses and would recommend that you carry out your
own virus checks before opening any attachment.


GWAVAsigAdmID:7EFDB58CC6D11227EE45BEC0BF84E6A2



**

IMPORTANT NOTICE

This communication is for the exclusive use of the intended recipient(s)
named above. If you receive this communication in error, you should
notify the sender by e-mail or by telephone (+44) 191 224 4461, delete
it and destroy any copies of it.

This communication may contain confidential information and material
protected by copyright, design right or other intellectual property
rights which are and shall remain the property of Piranha Studios
Limited. Any form of distribution, copying or other unauthorised use
of this communication or the information in it is strictly prohibited.
Piranha Studios Limited asserts its rights in this communication and
the information in it and reserves the right to take action against
anyone who misuses it or the information in it.

Piranha Studios Limited cannot accept any liability sustained as a
result of software viruses and would recommend that you carry out your
own virus checks before opening any attachment.


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

[PHP-DB] multiple queries in the same request

2005-06-20 Thread Gabriel B.
I have a table with some relational values, that really saves me on
selects, but gives me a weird error in the insert...

in the DB i have this 2 tables data and categories:
data(
id int
category tinyint ),
categories (
id tinyint
description varchar )

for selects i can use a single query with a left join.

but to populate the table without having to use magic numbers in my
code i've come up with:

SELECT (@category_id:=id) FROM categories WHERE description = cat1;
REPLACE INTO data VALUES( 10, @category_id);

i send this as a single query in PHP and it returns an error quoting
everything after the first ;

anyidea if i can't send several queries at once? any workaround?

Thanks,
Gabriel

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



Re: [PHP-DB] multiple queries in the same request

2005-06-20 Thread Bruno Ferreira

Gabriel B. wrote:


SELECT (@category_id:=id) FROM categories WHERE description = cat1;
REPLACE INTO data VALUES( 10, @category_id);

i send this as a single query in PHP and it returns an error quoting
everything after the first ;

anyidea if i can't send several queries at once? any workaround?
 

   You can't send multiple queries in an SQL statement. You can just 
split that in two separates queries. It's not really slower by any 
practical means because the DB system would have to execute them both 
anyway.


   -- Bruno Ferreira
---
[This E-mail scanned for viruses by Declude Virus]

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



[PHP-DB] Mail System Error - Returned Mail

2005-06-20 Thread Returned mail
The original message was received at Mon, 20 Jun 2005 17:55:49 +0200
from lists.php.net [114.240.28.128]

- The following addresses had permanent fatal errors -
php-db@lists.php.net




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

Re: [PHP-DB] multiple queries in the same request

2005-06-20 Thread Bruno Ferreira

Gabriel B. wrote:


   You can't send multiple queries in an SQL statement. You can just
split that in two separates queries. It's not really slower by any
   



I'm not really concerned about performance. i'm *really* concerned
about race conditions.

I have more than 3mi hits per day. the chance that two pairs of
queries will run consecutively is imense.
 

   Then you need to use transactions, which fill your purpose :) I 
presume you're using MySQL or Postgres, google for START TRANSACTION and 
COMMIT.


   -- Bruno Ferreira


Re: [PHP-DB] Re: UPDATE command

2005-06-20 Thread -{ Rene Brehmer }-
Documented research indicate that on Mon, 20 Jun 2005 12:47:56 +0100,
[EMAIL PROTECTED] wrote:

 The trick is your using the wrong ' instead you need ` ...
  
 go away from kl;-' and go to `-123 ;)
 The key above the (Tab) key, or the key next to the number 1 above the q.  

I hope you realise those directions only work for US keyboards (might work
for UK too, never seen those), but just about every other keyboard layout
it's in a different place (like on DK keyboards it's next to the backspace
key, and you have to first hit, then hit space, to make it show up alone,
because it's actually an accent aigu)... not sure where Ron is from, but it
is something worth considering when giving keyboard directions ...


Rene

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



[PHP-DB] auto-generating next id (in order) for an add script

2005-06-20 Thread tramelw

Hello,

I have a site that allows reporters to enter their articles into a 
forum. I am then spilling their articles onto the main page from a 
MySQL dbase via a php script, read LATEST ARTICLES.


I am now entering the data myself after they email it to me, however 
this is becoming more of a task I dont' have time for as the number of 
articles increase per day.


Right now, I have an addarticle.php page where they can enter their 
information. I have ran a test of this script, and it works great. 
However, I have been entering the PHP IDs myself in ascending order 
(i.e. 0005, 0006, 0007) because I can see all of the articles.


The reporters however are not able to see these articles, and instead 
of having them enter a random php ID, I'd like my add script to check 
for the last ID entered and then enter the number above (i.e add 
row to table, check PHP ID, if 0007 is last row entered, enter 0008 for 
php ID for new article).


Does anyone know how to add this particular command to a page, and if 
so, where?



Thank you in advance.

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



RE: [PHP-DB] auto-generating next id (in order) for an add script

2005-06-20 Thread Bastien Koert
post your code and db structure, it might be simpler to use an auto 
increment value and let the db do the work in assigning the next number...


bastien


From: [EMAIL PROTECTED]
To: php-db@lists.php.net
Subject: [PHP-DB] auto-generating next id (in order) for an add script
Date: Mon, 20 Jun 2005 12:54:20 -0400

Hello,

I have a site that allows reporters to enter their articles into a forum. I 
am then spilling their articles onto the main page from a MySQL dbase via a 
php script, read LATEST ARTICLES.


I am now entering the data myself after they email it to me, however this 
is becoming more of a task I dont' have time for as the number of articles 
increase per day.


Right now, I have an addarticle.php page where they can enter their 
information. I have ran a test of this script, and it works great. However, 
I have been entering the PHP IDs myself in ascending order (i.e. 0005, 
0006, 0007) because I can see all of the articles.


The reporters however are not able to see these articles, and instead of 
having them enter a random php ID, I'd like my add script to check for the 
last ID entered and then enter the number above (i.e add row to table, 
check PHP ID, if 0007 is last row entered, enter 0008 for php ID for new 
article).


Does anyone know how to add this particular command to a page, and if so, 
where?



Thank you in advance.

--
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] auto-generating next id (in order) for an add script

2005-06-20 Thread Micah Stevens

Use an autonumber field in MySQL.  It will increment automatically every time 
you insert a record, and not repeat numbers. No extra PHP code needed. After 
the insert query, you can then issue a mysql_insert_id() function that will 
return the autonumber field for the last insert, that way you can know what 
it was (if you need that) Don't do it with PHP. 

-Micah 


On Monday 20 June 2005 09:54 am, [EMAIL PROTECTED] wrote:
 Hello,

 I have a site that allows reporters to enter their articles into a
 forum. I am then spilling their articles onto the main page from a
 MySQL dbase via a php script, read LATEST ARTICLES.

 I am now entering the data myself after they email it to me, however
 this is becoming more of a task I dont' have time for as the number of
 articles increase per day.

 Right now, I have an addarticle.php page where they can enter their
 information. I have ran a test of this script, and it works great.
 However, I have been entering the PHP IDs myself in ascending order
 (i.e. 0005, 0006, 0007) because I can see all of the articles.

 The reporters however are not able to see these articles, and instead
 of having them enter a random php ID, I'd like my add script to check
 for the last ID entered and then enter the number above (i.e add
 row to table, check PHP ID, if 0007 is last row entered, enter 0008 for
 php ID for new article).

 Does anyone know how to add this particular command to a page, and if
 so, where?


 Thank you in advance.

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



Re: [PHP-DB] auto-generating next id (in order) for an add script. .

2005-06-20 Thread Patel, Aman

I'd recommend you use what mysql provides for this. Auto_increment flag.

Here's more information on how to make your id column be an 
auto_increment primary key.


http://dev.mysql.com/doc/mysql/en/example-auto-increment.html

- Aman Patel, Sys Admin / Database / Web Devloper, International 
Outreach x4076



[EMAIL PROTECTED] wrote:

Hello,

I have a site that allows reporters to enter their articles into a 
forum. I am then spilling their articles onto the main page from a MySQL 
dbase via a php script, read LATEST ARTICLES.


I am now entering the data myself after they email it to me, however 
this is becoming more of a task I dont' have time for as the number of 
articles increase per day.


Right now, I have an addarticle.php page where they can enter their 
information. I have ran a test of this script, and it works great. 
However, I have been entering the PHP IDs myself in ascending order 
(i.e. 0005, 0006, 0007) because I can see all of the articles.


The reporters however are not able to see these articles, and instead of 
having them enter a random php ID, I'd like my add script to check for 
the last ID entered and then enter the number above (i.e add row to 
table, check PHP ID, if 0007 is last row entered, enter 0008 for php ID 
for new article).


Does anyone know how to add this particular command to a page, and if 
so, where?



Thank you in advance.



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



Re: [PHP-DB] auto-generating next id (in order) for an add script. .

2005-06-20 Thread tramelw
Thanks Aman and guy from 'listmail.innovate.net'... I will change my 
primarykey ID colum to auto_increment.


I am off to try your suggestions.

Thanks again.



-Original Message-
From: Patel, Aman [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Cc: php-db@lists.php.net
Sent: Mon, 20 Jun 2005 12:27:01 -0500
Subject: Re: [PHP-DB] auto-generating next id (in order) for an add 
script. .


  I'd recommend you use what mysql provides for this. Auto_increment 
flag.


 Here's more information on how to make your id column be an 
auto_increment primary key.


http://dev.mysql.com/doc/mysql/en/example-auto-increment.html

 - Aman Patel, Sys Admin / Database / Web Devloper, International 
Outreach x4076


[EMAIL PROTECTED] wrote:
 Hello,
   I have a site that allows reporters to enter their articles into a 
 forum. I am then spilling their articles onto the main page from a 
MySQL  dbase via a php script, read LATEST ARTICLES.
   I am now entering the data myself after they email it to me, 
however  this is becoming more of a task I dont' have time for as the 
number of  articles increase per day.
   Right now, I have an addarticle.php page where they can enter 
their  information. I have ran a test of this script, and it works 
great.  However, I have been entering the PHP IDs myself in ascending 
order  (i.e. 0005, 0006, 0007) because I can see all of the articles.
   The reporters however are not able to see these articles, and 
instead of  having them enter a random php ID, I'd like my add script 
to check for  the last ID entered and then enter the number above 
(i.e add row to  table, check PHP ID, if 0007 is last row entered, 
enter 0008 for php ID  for new article).
   Does anyone know how to add this particular command to a page, and 
if  so, where?

   Thank you in advance.


  


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



Re: [PHP-DB] auto-generating next id (in order) for an add script

2005-06-20 Thread tramelw

Thanks Bastien,

I am off to try the auto increment. I will post back if I cannot get it 
to work properly.



Again, thanks everyone.


-Original Message-
From: Bastien Koert [EMAIL PROTECTED]
To: [EMAIL PROTECTED]; php-db@lists.php.net
Sent: Mon, 20 Jun 2005 13:30:13 -0400
Subject: RE: [PHP-DB] auto-generating next id (in order) for an add 
script


  post your code and db structure, it might be simpler to use an auto 
increment value and let the db do the work in assigning the next 
number...


bastien

From: [EMAIL PROTECTED]
To: php-db@lists.php.net
 Subject: [PHP-DB] auto-generating next id (in order) for an add 
script

Date: Mon, 20 Jun 2005 12:54:20 -0400

Hello,

 I have a site that allows reporters to enter their articles into a 
forum. I am then spilling their articles onto the main page from a 
MySQL dbase via a php script, read LATEST ARTICLES.


 I am now entering the data myself after they email it to me, however 
this is becoming more of a task I dont' have time for as the number of 
articles increase per day.


 Right now, I have an addarticle.php page where they can enter their 
information. I have ran a test of this script, and it works great. 
However, I have been entering the PHP IDs myself in ascending order 
(i.e. 0005, 0006, 0007) because I can see all of the articles.


 The reporters however are not able to see these articles, and instead 
of having them enter a random php ID, I'd like my add script to check 
for the last ID entered and then enter the number above (i.e add 
row to table, check PHP ID, if 0007 is last row entered, enter 0008 
for php ID for new article).


 Does anyone know how to add this particular command to a page, and if 
so, where?



Thank you in advance.

--
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] Re: UPDATE command

2005-06-20 Thread Dwight Altman
This is kind of interesting ...

$query=SELECT * FROM quiettimequotation WHERE used = 0 ORDER BY RAND()
LIMIT 1;

works;

$query=SELECT * FROM bibleverses WHERE 'used' = 0 ORDER BY RAND() LIMIT
1;

doesn't!  Having the ' around used makes that select command fail ---
but
the UPDATE command requires it!

Use the ` mark around table names and field names.
Use the ' mark around values.
Although sometimes you may get away without them.

$query=SELECT * FROM `bibleverses` WHERE `used` = '0' ORDER BY RAND()
LIMIT 1;

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



Re: [PHP-DB] auto-generating next id (in order) for an add script

2005-06-20 Thread Miles Thompson
Depending on your version of MySQL, table type should be MyISAM so that 
numbers for deleted articles do not get reused.

Miles Thompson

At 02:33 PM 6/20/2005, [EMAIL PROTECTED] wrote:

Thanks Bastien,

I am off to try the auto increment. I will post back if I cannot get it to 
work properly.



Again, thanks everyone.


-Original Message-
From: Bastien Koert [EMAIL PROTECTED]
To: [EMAIL PROTECTED]; php-db@lists.php.net
Sent: Mon, 20 Jun 2005 13:30:13 -0400
Subject: RE: [PHP-DB] auto-generating next id (in order) for an add script

  post your code and db structure, it might be simpler to use an auto 
increment value and let the db do the work in assigning the next number...


bastien

From: [EMAIL PROTECTED]
To: php-db@lists.php.net
 Subject: [PHP-DB] auto-generating next id (in order) for an add script
Date: Mon, 20 Jun 2005 12:54:20 -0400

Hello,

 I have a site that allows reporters to enter their articles into a 
forum. I am then spilling their articles onto the main page from a MySQL 
dbase via a php script, read LATEST ARTICLES.


 I am now entering the data myself after they email it to me, however 
this is becoming more of a task I dont' have time for as the number of 
articles increase per day.


 Right now, I have an addarticle.php page where they can enter 
their information. I have ran a test of this script, and it works great. 
However, I have been entering the PHP IDs myself in ascending order 
(i.e. 0005, 0006, 0007) because I can see all of the articles.


 The reporters however are not able to see these articles, and instead 
of having them enter a random php ID, I'd like my add script to check 
for the last ID entered and then enter the number above (i.e add row 
to table, check PHP ID, if 0007 is last row entered, enter 0008 for php 
ID for new article).


 Does anyone know how to add this particular command to a page, and if 
so, where?



Thank you in advance.

--
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



[PHP-DB] Threading theory help needed

2005-06-20 Thread Chris Payne
Hi there everyone,

 

I've written a simple forum in PHP for my website (It's an artistic
Jean-Michel Jarre website called Planet Oxygene where I experiment with all
things tech) but I want to add threading to my messages but I'm not sure of
the theory for such a thing.

 

For example, I know I need ID, messageid, forumid and messagerootid (Just
example names) but I'm not sure of the theory of how replies to replies etc
... would work in PHP with MySQL?  I guess I'm just confused on the whole
threading business and I'm just looking for some good explanation of how I
can easily add threading to my messageboard (Assuming my messageboard is
just an average system which adds the ID as an auto-numerator, the messageid
and all subject etc ...).

 

Any help would really be appreciated just on the basics of how threading
works so I can work out the code.

 

Thank you for your help on this, a very confusing subject for me :-)

 

Chris



Re: [PHP-DB] Threading theory help needed

2005-06-20 Thread Micah Stevens
On Monday 20 June 2005 04:54 pm, Chris Payne wrote:
 For example, I know I need ID, messageid, forumid and messagerootid (Just
 example names) but I'm not sure of the theory of how replies to replies etc
 ... would work in PHP with MySQL?  I guess I'm just confused on the whole
 threading business and I'm just looking for some good explanation of how I
 can easily add threading to my messageboard (Assuming my messageboard is
 just an average system which adds the ID as an auto-numerator, the
 messageid and all subject etc ...).


What I usually do in the interest of just keeping things simple, is to just 
have a message ID, and parentID. You can then calculate the root message 
(select * from messages where parentID = 0) and get children from there 
(select * from messages where parentID = $messageID)

Anytime a reply is made, just make the original messageID the parentID of the 
reply. This makes unlimited threads which leads to some formatting issues (if 
you're indenting for each reply, for example, you must limit the indenting at 
some point) but that's a seperate issue. 

Hope that helps,
-Micah 

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