如何将数据保存在表格中 [英] How can I save my data in a table

查看:105
本文介绍了如何将数据保存在表格中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表单,其中有一个用户填写的country_full组合框。



I have a form that has a combo box for country_full which the users fill it.

<select name="country_full" class="stylish-select-input span3" style="background:#eee; font-size:12px" >
<option value=""></option>
<?  $resultCont = mysql_query("SELECT * FROM countries ORDER BY countryName ASC");
     while($rowCont=mysql_fetch_array($resultCont)) {  ?>
<option value="<?=$rowCont['countryName']?>" <? if( $row['country_full']==$rowCont['countryName']) echo"selected=selected"; ?> ><?=$rowCont['countryName']?></option><? } ?>
</select>









现在我需要那个当用户提交表单时,我将country_full保存在users表中,而country表中的国家也保存在用户表中。

countries表有两列(countryCode是country + CountryName,是country_full)。










Now I need that when user submit the form I save country_full in users table, and country which is in countries table also save in user table.
countries table has two columns (countryCode which is country + CountryName which is country_full).



<pre> 
$country_full = str_replace("'", "", $_POST['country_full']);		 
$country= mysql_query("SELECT countryCode FROM countries WHERE $country_full==countryName");    		  
        
if( $s_user==1  && $captcha_error==0 ) {
        $query = "INSERT INTO users (id,username, password,pass_raw,organization,contact,email,fax, phone,  website ,country_full ,country ,address2,status,confirmed,active, last_edit)

VALUES      (NULL,  '$user','$password','$pass_raw','$organization','$contact','$email', '$fax', '$phone', '$website','$country_full','$country', '$mcat', '1','0','$activation_code', '".date('Y-m-d H:i:s')."')";





我尝试了什么:



现在country_full保存在用户表中但是Country不保存。!!!



What I have tried:

Now country_full save in user table But Country doesnt Save.!!!

推荐答案

resultCont = mysql_query(SELECT * FROM countries ORDER BY countryName ASC);
while(
resultCont = mysql_query("SELECT * FROM countries ORDER BY countryName ASC"); while(


rowCont = mysql_fetch_array(
rowCont=mysql_fetch_array(


resultCont)){?>
< option value =<?=
resultCont)) { ?> <option value="<?=


这篇关于如何将数据保存在表格中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆