vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   auto incriment (https://vborg.vbsupport.ru/showthread.php?t=47504)

curley 01-08-2003 04:18 PM

auto incriment
 
hi i have a prob.

i have a database table with 2 fields and i want them to auto increment.

right the problem is i am using this query

// here we are trying to add a name
if ($action=="addcomment") {




$comment_insert = $DB_site->query("INSERT INTO `name` (`nameid`, `comment`) VALUES (null, '$comment')");

it just updates all the comments to the same one so i end up with loads of the same name???

the thing is if i use it in phpmyadmin and do the same query but change (null, '$comment')"); to this (null, 'trevor')");

it puts a new line in with the id no and trevor

what am i doing wrong ??

Xenon 01-08-2003 04:21 PM

if you use INSERT it doesn't update any lines, it inserts a new one, that's why the command is called insert

you should use UPDATE if you want to update :)

UPDATE name SET(comment='$comment')

filburt1 01-08-2003 04:46 PM

You can also use REPLACE INTO instead of INSERT INTO to overwrite existing lines.

curley 01-09-2003 05:59 PM

1 Attachment(s)
ok so if i have you right then the insert one should put a new line in well it does that ok but then i have all the rest of them with the comment in them as well how do i get the rest to stay as they are..

what i get now is this in the picy

how do i get each line to be different

Xenon 01-09-2003 08:07 PM

UPDATE name SET(comment='$comment') WHERE nameid=xx

replace the xx with the nameid of the uptodate line :)

curley 01-10-2003 04:57 PM

sorry but i dont know what this bit means nameid=xx..

i tried putting $nameid

then tried the last column number (21) but it still overwrites the lot:(

curley 01-11-2003 02:27 PM

ok i've sorted that bit out, i can now insert new lines with an id no but how do i use it now to display the newest line where i want to but leave the others as they were??

at the mo the only query i can get to work is this

//try name again
$getname=$DB_site->query_first("SELECT comment FROM name WHERE nameid=23");
$name=$getname[comment];

i have to put the id no in and then it wont go to the next one that i type in to put it into the next thread

Xenon 01-12-2003 12:31 PM

Code:

$getname=$DB_site->query_first("SELECT comment FROM name ORDER BY nameid DESC LIMIT 1");

curley 01-12-2003 02:27 PM

you are really great thank you very much for helping me :) i hope i can be as much help to someone sometime

curley 01-12-2003 03:16 PM

ok i have the name inputed now and getting a unique id everytime so i have a list..

now how would i allie the id of the newest name to the thread its supposed to be for??


All times are GMT. The time now is 06:28 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01486 seconds
  • Memory Usage 1,721KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete