如何使用其他查询将question_text
插入数据库表中,如下面的代码所示?
mysql_connect ("localhost", "root","") or die ('Error : '.mysql_error());
mysql_select_db("keyword");
$first_word = current(explode(' ', $_POST['question_text']));
$qStuff=mysql_query("SELECT c.field_name,t.category_name, d.domain_name FROM category_fields c, taxonomy_category t, taxonomy_domain d WHERE c.category_id = t.category_id AND t.domain_id = d.domain_id AND c.field_name = '" . mysql_real_escape_string($first_word) . "'");
$num_rows = mysql_num_rows($qStuff);
// some print codes here
答案 0 :(得分:0)
只需输入:
mysql_query("insert into ... values ...");
但要注意可能的mysql注入!使用mysql_real_escape_string()并查看:http://www.tizag.com/mysqlTutorial/mysql-php-sql-injection.php
答案 1 :(得分:0)
此insert语句使用select查询填充field1和field2的值:
insert into table (field1, field2)
select field1, field2 from table2