I don't think it's possible but what I am trying to do is insert data into dynamic tables. (I know it's not in good db design but it's more for personal use than anything).
I'm trying to create a small memo script. The user selects the username or usernames from the dynamic textboxes, fills out the title and the body, the script formats the text and inserts it into the database. Everything works but I keep getting hung up on attempting to submit the data into multiple dynamic datatables... Here is my script as it currently stands:
<?php
$connection = mysql_connect('localhost','username','password')
or die ("Could not connect to MySQL!");
$selectdb = mysql_select_db('userindex')
or die ("Could not select to database!");
$result = mysql_query("SELECT DISTINCT fullname FROM profiles");
while($data = mysql_fetch_array($result)){
$fullname = $data[fullname];
$memoname = str_replace( ' ', '', $fullname );
$memoname = strtolower($memoname);
echo "<input type=\"checkbox\" name=\"$memoname\" value=\"$memoname\"";
if($memoname == "on"){echo" CHECKED";}
echo "> $fullname <br>";
}
?>
As you see from that example the username starts out as "Christopher Joe" and is converted to "christopherjo" then set to the variable $memoname to be posted upon submission of the form (the rest of the form isn't shown)
<?php
$title=$_POST["title"];
$newtitle=str_replace(Chr(13),'<p>', $title);
echo "$newtitle <br>";
$article=$_POST["article"];
$newarticle=str_replace(Chr(13),'<p>', $article);
// the above is for formatting
$memoname = "christopherjo"; // this variable is set for individual testing
$con = mysql_connect("localhost","username","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}mysql_select_db("memosystem", $con);
$sql="INSERT INTO $memoname (personalmemo, personalmemotitle) values ('$newarticle', '$newtitle')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "Memo sent!";mysql_close($con)
?>
That portion formats the text (keeps paragraphs as paragraphs) then attempts to insert the data into the proper datatable. It works perfactly with a single user (as shown above - I set the variable) however I can't wrap my head around attempting to insert the same memo to the other users... If there was some other function that I can use to create a type of "SQL echo" or some other idea to make this work please let me know.....
I would really appriciate it..
Christopher