i have a table in my db call db_blog. in it i have an auto_increment column called entryNum. i use that strictly for order when i view the blog. i also have a column called comNum. each row in the table is an entry in the blog, and has comments (comNum) i have a variable called $comNum that is used to count how many comments are per entry in the blog. example, entry number 1 has 3 comments, and entry number 5 has 0 comments. if there are no comments on the entry, and the user wants to make one, and if statement decides whether to display or input into the db. that works fine. now, when i input lies the problem. i want to input data in a newly created table called $entryNum_comms (xx_comms) AND add to the number in the comNum column for THAT entry in dm_blog.
example:
i am making the first comment on entry number 74 in db_blog.
comNum in dm_blog should change form 0 to 1 and the data fromt he form should be inserted into 74_comms, a newly created table for that entry.
example 2:
i am making the 3rd comment on entyr number 94 in db_blog.
comNum in db_blog should change form 3 to 4 and the data from the form should be entered into the already created table 94_comms.
the only thing i am stuck on is entering the data into the two different tables.
here is the code im using:
if ($comms=="true") { //define a table name based on main Post number $theTable = $entryNum . '_comms'; if ($newTab=="true") { //create a table $sql = 'CREATE TABLE ' . $theTable . ' ( `daUser` VARCHAR( 255 ) NOT NULL ,' . ' `entryNumb` INT NOT NULL ,' . ' `priv` VARCHAR( 1 ) NOT NULL ,' . ' `comm` BLOB NOT NULL ,' . ' PRIMARY KEY ( `entryNumb` ) )'; $resulter = mysql_query($sql) or die("There has been an error creating table: $theTable <br /> newTab = $newTab"); //insert the values into the table for the comment $commPost = "INSERT INTO $theTable VALUES ('$daUser', '$entryNumb', '$priv', '$comm')"; //output the comment or errors $CommResult = mysql_query($commPost) or die("(Error on line 70 of inputBlog.php) <br /><br /> tableName:$theTable <br /> entryNum:$entryNum <br /> entryNumb:$entryNumb<br /> priv:$priv <br />usr:$daUser<br /> comm:$comm"); }else{ $select_comNum = 'SELECT `comNum` FROM dm_blog' //insert the values into the table for the comment $commPost = "INSERT INTO `' . $theTable . '` VALUES ('$daUser', '$entryNumb', '$priv', '$comm')"; $post = "INSERT INTO dm_blog VALUES ('$comNum')"; //output the comment or errors $CommResult = mysql_query($commPost) or die("(Error on line 78 of inputBlog.php) <br /><br /> tableName:$theTable <br /> entryNum:$entryNum <br /> priv:$priv <br />usr:$daUser<br /> comm:$comm"); $result = mysql_query($post) or die("(Error on line 85 of inputBlog.php) <br /> $post </td> \n\r </tr> \n\r </table> </body></html>"); }
while($myrow = mysql_fetch_array($result2)){ $p_entryNumb = $myrow["entryNumb"]; $p_daUser = $myrow["daUser"]; echo "entryNumber: $p_entryNumb [user: $p_daUser] <br />"; }
//echo "posting a comment"; //if posting a new post do this: }else{
$post = "INSERT INTO dm_blog VALUES ('$date', '$chapter', '$mood', '$theuser', '$message', '$entryNum' ,'$song','$t_level','$r_thought','comms')"; $result = mysql_query($post) or die("(Error on line 85 of inputBlog.php) <br /> $post </td> \n\r </tr> \n\r </table> </body></html>");
}
thanks in advance -AJ Seelund [EMAIL PROTECTED]
-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php