Jump to content
php.lv forumi
Sign in to follow this  
krisis32

Pieskaitam pie update tabulā

Recommended Posts

Sveiki! Tātad ir tabula: numbers

 

+--------+------------------------+
| Number | Date                   | 
+--------+------------------------+
|    1   | 15/02/11-12:13         |
|    2   | 15/02/11-12:13         |       
|    3   | 15/02/11-12:13         |
|    4   | 15/02/11-12:13         |
|    5   |                        |
+--------+------------------------+

Kā lai izveidot skriptu kas updeito Number.

Ir forma no kuras izvēlos Date un ievadu Number attiecīgajam Date.

Ievadīto Number pieskaita jau esošajam.

Update numbers ... ?

Edited by krisis32

Share this post


Link to post
Share on other sites

+--------+------------------------+
| Number | Date               	| 
+--------+------------------------+
|    1   | 15/02/11-12:13     	|
|    2   | 15/02/11-12:13     	|   	
|    3   | 15/02/11-12:13     	|
|    4   | 15/02/11-12:13     	|
|    5   |                        |
+--------+------------------------+

 

 

Kā lai dabū tādu tekstuālu atspoguļojumu tabulai? =/

Share this post


Link to post
Share on other sites

Es darītu tā:

mysql_query ("UPDATE tabula SET Number = Number+1 WHERE Date = $izveletais_date");

 

Liels paldies. Paprovēšu šo te.

 

Kā lai dabū tādu tekstuālu atspoguļojumu tabulai? =/

 

Copy paste. (Postu krāšana?)

Share this post


Link to post
Share on other sites

Var darīt tā, ka uz Date kolonas uzliek unikālu indeksu un izmanto

 

INSERT INTO tabula SET date=xxx, number=Y ON DUPLICATE KEY UPDATE number=number+Y

Share this post


Link to post
Share on other sites

Copy paste. (Postu krāšana?)

 

Nesapratu. Tagad jautājuma paprasīšana skaitās kā postu krāšana?? Tu esi galīgi slims, ko?!

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...