I have a script that builds a query on the fly and checks to make sure that it filled and creates a query accordingly.
It looks like so.
<?php
require("includes/sitewide/config.php");
$table = "clanmemSpecs";
$compSpecs =
array
("compManu",
"opSystem",
"cpuMan",
"cpuSpeed",
"memoryManu",
"memAmount",
"hdManu",
"hdSize",
"videoCard",
"monitorMan",
"monitorSize",
"monitorType",
"soundCard",
"hdphMan",
"mouseMan",
"mousePad",
"keyManu");
for($i = 0; $i < count($compSpecs); $i++)
{
if(strlen($_POST[$compSpecs[$i]]) > 0)
{
$user_vars[$x][0] = $compSpecs[$i];
$user_vars[$x][1] = $_POST[$compSpecs[$i]];
$x++;
}
}
$sql = "UPDATE $table SET ";
for($i = 0; $i < count($user_vars); $i++)
{
if($i != count($user_vars) - 1)
{
$sql = $sql . $user_vars[$i][0] . " = \"" . $user_vars[$i][1] ."\", ";
}
else
{
$sql = $sql . $user_vars[$i][0] . " = \"" . $user_vars[$i][1] . "\" WHERE memrefID = 1";
}
}
echo $sql;
Problem is when the query does get created, the very first part of the query doesn't not get set so rather it looking like this
UPDATE clanmemSpecs SET compManu= "1", opSystem = "1", cpuMan = "2", cpuSpeed = "3", memoryManu = "2", memAmount = "4", hdManu = "5", hdSize = "3", videoCard = "1", monitorMan = "1", monitorSize = "1", monitorType = "2", soundCard = "1", hdphMan = "1", mouseMan = "1", mousePad = "7", keyManu = "1" WHERE memrefID = 1
I get it like this
UPDATE clanmemSpecs SET = "", opSystem = "1", cpuMan = "2", cpuSpeed = "3", memoryManu = "2", memAmount = "4", hdManu = "5", hdSize = "3", videoCard = "1", monitorMan = "1", monitorSize = "1", monitorType = "2", soundCard = "1", hdphMan = "1", mouseMan = "1", mousePad = "7", keyManu = "1" WHERE memrefID = 1
As you can notice the first portion query comes up come up not set. Anyone have any input why this is happening? Any input? thank you in advance..
to see it in action here it is.
http://www.unisonclan.com/arrays.php