![]() |
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 ?? |
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') |
You can also use REPLACE INTO instead of INSERT INTO to overwrite existing lines.
|
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 |
UPDATE name SET(comment='$comment') WHERE nameid=xx
replace the xx with the nameid of the uptodate line :) |
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:( |
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 |
Code:
$getname=$DB_site->query_first("SELECT comment FROM name ORDER BY nameid DESC LIMIT 1"); |
you are really great thank you very much for helping me :) i hope i can be as much help to someone sometime
|
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 | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|