Global Changes With Loop To Allow Nulls In A Table...
| From: | revDAVE | Date: | Tue, 27 Jan 2009 16:53:22 +0000 |
| Subject: | Global Changes With Loop To Allow Nulls In A Table... | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-287218@lists.php.net to get a copy of this message | ||
Hi Folks,
Newbie question....
I have a mysql table with 100 fields, currently all do not allow nulls.
Rather than hand typing in phpMyAdmin, I would like a way to loop through
all fields and update them to allow nulls....
My Beginning attempt needs help...
$i = 1;
while ($i <= 100):
// how do I word this to just change whatever field we are on to allow
nulls?
$sql = 'ALTER TABLE
mytable ?*update*?
'.$???WhatEverField??[$i].'
?ALLOWNULL?;';
//mysql_query($sql);
$result = mysql_query($sql) or die("<br /><br /> Could not renumber dB $sql
<br /><br />" . mysql_error());
$i++;
endwhile;
Thanks in advance
--
Thanks - RevDave
Cool @ hosting4days . com
[db-lists 09]