Web Hosting Talk







View Full Version : [PHP / MySql] Add new column and fill it out


Wojtek
02-22-2004, 04:33 PM
Hey all,

What would be the best way to do that:

I want to add a column to ALL my entries that this code loops thruh and fill that with $topicid.

What code/query could I possibly use to accomplish that?


$cat = 'Friendship';

$db = new PrevNext_class;
$db->dbname = 'wojtek_poems';
$db->offset = 'poem';
$db->limit = 1000;
$db->number_type = 'number';
$db->connection('localhost','wojtek_poems','****');

$db->execute("SELECT * from $cat ORDER by id ASC");

// -------------
// Loop Start
// -------------

while($myrow = mysql_fetch_array($db->sql_result))
{
// ------------------------------------------------------
// Add poems entry into Invision Power Board
// ------------------------------------------------------
$topicid = $SDK->new_topic (15, $myrow[3], "", "Leave your comments about this poem...\n\r\n\r<a href=\"javascript:popUp('http://www.AllPoem.com/FriendshipPoems.php?id=$myrow[0]')\">Click Here to read this poem</a>", $disableemos="1", $disablesig="1", $bypassperms="1", $guestname="AllPoem Poem Manager");
$SDK->new_poll($topicid, "How do you rate this poem", array("Very Good", "Good", "OK", "Bad", "Very Bad"));

// ---------------------------------------------------------
// Add $topicid as the last column for each entry
// ---------------------------------------------------------

CODE GOES HERE
CODE GOES HERE
CODE GOES HERE

echo $topicid;
}
// ------------
// Loop End
// ------------
echo "Done";

Thanks :)

stephenM
02-22-2004, 05:51 PM
I'm not entirely sure what you mean, are you trying to add a column to the end of a table?

tlbinteractive
02-22-2004, 07:24 PM
Do you want to add a column on every table in your database?