Re: Alter table and add cell at a time.

From: Date: Sat, 18 May 2002 00:38:28 +0000
Subject: Re: Alter table and add cell at a time.
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-98198@lists.php.net to get a copy of this message
update table set answer3=5 where id=2; miguel On Fri, 17 May 2002, Jule wrote: > a question: > > if i have this: > > for ($n = 1; $n <= $quiz[number_answers]; $n++) { > $table = $qcode."_answers"; > $value = $answers["answer".$n]; > $value2 = "answer".$n; > > $query_alter_table = "ALTER TABLE $table ADD $value2 TEXT NOT NULL"; > $query_add_answers = "INSERT INTO $table ($value2) VALUES('$value')"; > if (mysql_db_query($database_glob, $query_alter_table, $link_glob)) { > if (mysql_db_query($database_glob, $query_add_answers, $link_glob)) { > echo "Answer $n: $value has successfully been added to the Quiz<br>\n"; > } else { > echo mysql_error() ." 1<br>"; > } > } else { > echo mysql_error()." 2<br>"; > } > } > > How do I get the $value to be in the same row as the preceding one? > now it comes like this: > +----+---------+---------+---------+---------+ > > | id | answer1 | answer2 | answer3 | answer4 | > > +----+---------+---------+---------+---------+ > > | 1 | answer1 | | | | > | 2 | | answer2 | | | > | 3 | | | answer3 | | > | 4 | | | | answer4 | > > +----+---------+---------+---------+---------+ > > so it's like this? > +----+---------+---------+---------+---------+ > > | id | answer1 | answer2 | answer3 | answer4 | > > +----+---------+---------+---------+---------+ > > | 1 | answer1 | answer2 | answer3 | answer4 | > > +----+---------+---------+---------+---------+ > > thanks, > > Jule > > On Friday 17 May 2002 19:17, you wrote: > > Hello, > > > > Try using "NOT NULL". As weird as MySQL can be, don't think it is that > > NUTty. =) > > > > Harrison > > > > ----- Original Message ----- > > From: "Jule" <jslootbeek@clarku.edu> > > To: <mysql@lists.mysql.com> > > Sent: Friday, May 17, 2002 7:00 PM > > Subject: "ALTER TABLE $table ADD $value2 TEXT NUT NULL" > > > > > > Hey i'm getting this error: > > > > You have an error in your SQL syntax near 'NUT NULL' at line 1 > > > > when i run this query, > > > > "ALTER TABLE $table ADD $value2 TEXT NUT NULL" > > > > from the documentation i understood that this was the correct notation. > > > > any ideas? > > thanks > > Jule > > -- > > > > |\/\__________________________/\/| > > | Jule Slootbeek | > > | jslootbeek@clarku.edu | > > | http://blindtheory.cjb.net | > > | __________________________ | > > |/\/ \/\| > > > > --------------------------------------------------------------------- > > Before posting, please check: > > http://www.mysql.com/manual.php (the manual) > > http://lists.mysql.com/ (the list archive) > > > > To request this thread, e-mail <mysql-thread109440@lists.mysql.com> > > To unsubscribe, e-mail > > <mysql-unsubscribe-hcfisk=buffalo.edu@lists.mysql.com> > > Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php > > > > > > > > > > > > > > --------------------------------------------------------------------- > > Before posting, please check: > > http://www.mysql.com/manual.php (the manual) > > http://lists.mysql.com/ (the list archive) > > > > To request this thread, e-mail <mysql-thread109441@lists.mysql.com> > > To unsubscribe, e-mail > > <mysql-unsubscribe-jslootbeek=clarku.edu@lists.mysql.com> Trouble > > unsubscribing? Try: > > http://lists.mysql.com/php/unsubscribe.php > > -- > > |\/\__________________________/\/| > | Jule Slootbeek | > | jslootbeek@clarku.edu | > | http://blindtheory.cjb.net | > | __________________________ | > |/\/ \/\| > > ------------------------------------------------------- > >

« previous php.general (#98198) next »