[PHP] Alter table and add cell at a time.

2002-05-17 Thread Jule

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 
Quizbr\n;
} else {
echo mysql_error() . 1br;
}
} else {
echo mysql_error(). 2br;
}
}

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 [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 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 |
 |   [EMAIL PROTECTED] |
 |   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 [EMAIL PROTECTED]
 To unsubscribe, e-mail
 [EMAIL PROTECTED]
 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 [EMAIL PROTECTED]
 To unsubscribe, e-mail
 [EMAIL PROTECTED] Trouble
 unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

--

|\/\__/\/|
|   Jule Slootbeek   |
|   [EMAIL PROTECTED]|
|   http://blindtheory.cjb.net   |
|   __   |
|/\/  \/\|

---

-- 
|\/\__/\/|
|   Jule Slootbeek   |
|   [EMAIL PROTECTED]|
|   http://blindtheory.cjb.net   |
|   __   |
|/\/  \/\|

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




Re: [PHP] Alter table and add cell at a time.

2002-05-17 Thread Miguel Cruz

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 
Quizbr\n;
   } else {
   echo mysql_error() . 1br;
   }
   } else {
   echo mysql_error(). 2br;
   }
 }
 
 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 [EMAIL PROTECTED]
  To: [EMAIL PROTECTED]
  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 |
  |   [EMAIL PROTECTED] |
  |   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 [EMAIL PROTECTED]
  To unsubscribe, e-mail
  [EMAIL PROTECTED]
  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 [EMAIL PROTECTED]
  To unsubscribe, e-mail
  [EMAIL PROTECTED] Trouble
  unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
 
 --
 
 |\/\__/\/|
 |   Jule Slootbeek |
 |   [EMAIL PROTECTED]  |
 |   http://blindtheory.cjb.net |
 |   __ |
 |/\/\/\|
 
 ---
 
 


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