주어진 DB와 테이블에서 자체적으로 생성되는 양식을 만들고 있습니다. 그러나 삽입 기능에 관해서는 문제가 있습니다. 나는 모든 필드가 입력을 생성 할 수 있도록 텍스트를 만들었습니다. 올바른 이름의 페이지에 무엇을 넣었습니까? 이제 내가 할 일은 게시판에 DB에 삽입하는 것뿐입니다. 하지만 implode를 사용하여 배열을이 (다시 말해, this, this)로 다시 만들 필요가 있습니다. 어떻게해야할지 모르겠습니다.열에서 배열 자동 생성
$resultInsert = mysql_query("SHOW COLUMNS FROM " . $table);
$fieldnames=array();
if (mysql_num_rows($resultInsert) > 0) {
while ($row = mysql_fetch_array($resultInsert)) {
echo $fieldnames[] = $row['Field']; #currently outputting titlebodytextcreated (three fields i have)
}
}
// FORMAT: field_name = $_POST[fieldname]
$values = array('title'=>$_POST['title'],'bodytext'=>$_POST['bodytext']); # need this to be autogenerated by the field names
echo "<br>" . sprintf('INSERT INTO %s (%s) VALUES ("%s")', 'testdb',
implode(', ', array_map('mysql_escape_string', array_keys($values))), implode('", "',array_map('mysql_escape_string', $values)));
// add loop for id to be generated in a hidden field, along with all other excluded fields so that the
// update will process correctly in the insert into phase
. 나는 PHP에 noobie 종류. 하지만 난 정말이 코드를 작동시키고 싶습니다 – Alex