Hi all
I have created a dynamic for on a loop that works perfectly. On submission to this script I am having a problem getting the count value of the $x to increment accordingly. If I use the form and insert GetSQLValueString($_POST['track_name[1]'], "text"),GetSQLValueString($_POST['track_name[2]'], "text"), etc the entries are put to mysql perfectly but when using the variable $x the names do not increment. I have tried all manner of methods to get this and many pre written scripts to work, but have yet tio find anything which will show an increment for the count. If anyone can help I would appreciate it.
Thanks in advance.
PHP Code:if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
//conditional loop
if (isset($_POST['send']))
{
$send = $_POST['send'];
}
else
{
exit();
}
for ($x = 1; $x <= $send; $x++)
{
$insertSQL = sprintf("INSERT INTO metal_tracks (disco_id, track_name) VALUES (%s, %s)",
GetSQLValueString($_POST['disco_id'], "int"),
GetSQLValueString($_POST['track_name[$x]'], "text"));
mysql_select_db($database_SiteConn, $SiteConn);
$Result1 = mysql_query($insertSQL, $SiteConn) or die(mysql_error());
}
//end loop
$insertGoTo = "";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}





Bookmarks