I found by doing
${'foo' . $x}
creates an array that would them make the variables foo1, foo2, ... foo20.
It also works as a session/post variable ->
$_SESSION['foo' . $x]
$_POST['foo' . $x]Here's a snippet of code:
$item = 1;
for ($i=0; $i < $num; $i++)
{
$_SESSION['line' . $item] = mysql_result($result, $i, "table1.x");
$_SESSION['line' . $item] = mysql_result($result, $i, "table1.x");
$_SESSION['line' . $item] = mysql_result($result, $i, "table2.x");
$item++;
}
Now I did run into an issue with the sql insert statement. Here is how I got around it:
$sqlqueryitems = "$id', '${'line' . $item }',
'${'line' . $item }',
'${'line' . $item }";
$sql = "INSERT INTO table_items (line1, line2, line3)
VALUES
('$sqlqueryitems')";
if (!mysql_query($sqlitems,$con))
{
die('Error: ' . mysql_error($con));
}
No comments:
Post a Comment