ok this is my code, when I try to insert the values I get 1,2,3,4 etc
instead of what is entered in the form, can u tell me where is my
mistake please and how to solve the whole thing pease?
gracias
if ($material_to_be_added==$j)
{
$resultprod = $sqlquery ("describe $tabname");
echo "<form method=\"post\" action=$php_self>";
while($row = $sqlfetcharray($resultprod)) {
$col_name = $row['Field'];
$null_value = $row['Null'];
$translated_colname = 'translation_'.$col_name ;
$dispayed_colname = ${$translated_colname};
if ($col_name=='id' || $null_value=='YES')
echo "";
else {echo "<br>$dispayed_colname:<BR><INPUT TYPE=\"TEXT\"
NAME=\"$k\" SIZE=\"40\">";
$col_to_insert .= "$col_name,";
$cols_to_insert = substr_replace($col_to_insert,'',-1);
$val_to_insert .= "$k,";
$vals_to_insert = substr_replace($val_to_insert,'',-1);
$k = $k +1;
}
}
echo "<p><input type=\"submit\" name=\"submit\" value=\"$submit\">
</form><p> $cols_to_insert <p> $vals_to_insert";
if ($submit) {
$result=$sqlquery("INSERT INTO $tabname($cols_to_insert)".
"VALUES ($vals_to_insert)");
}
}
"kingofkolt" <je**********@comcast.net> wrote in message news:<ppyXc.322092$%_6.188275@attbi_s01>...
<ki*********@yahoo.com> wrote in message
news:39**************************@posting.google.c om... hey all:
I do a loop that creates text forms on the fly kinda like this:
for (i,i<=$x,i++)(
echo "<input type=text name=$forname> <br>"
$values .= "$forname,"
)
echo "<input form type=submit name="submit">"
then
if ($submit)
//to get rid of the last comma:
$myvalues= str_replace($values,-1)
//i use a function to get the $namesofcolumns but im in a netcafe
right now so...
mysql_query(insert into blabla ($namesofcolumns) values ($myvalues);
the problem is that the insert works but only null values get
inserted, how can I do that?
thanx in advance
I didn't see enough of your code to know for sure that this is the case, but
I'm guessing you're working on the assumption that register_globals in
php.ini is set to On. The best policy to go by is to use $_POST['somevar']
instead of $somevar, as that will be more reliable. For example, your line
"if ($submit)" should be "if ($_POST['submit'])". Or actually, "if
(isset($_POST['submit']))" for good measure...
- JP