Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/63.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将两个数据库表条目相互链接的PHP代码_Php_Mysql_Sql_Database - Fatal编程技术网

将两个数据库表条目相互链接的PHP代码

将两个数据库表条目相互链接的PHP代码,php,mysql,sql,database,Php,Mysql,Sql,Database,这是我的代码: <?php $connect = mysql_connect("host","user","password"); if (!$connect){ die("Failed to connect to the database: ".mysql_error()); } $kies_bd = mysql_select_db("eraenz_db1",$connect); if (!$kies_bd){ di

这是我的代码:

<?php 
$connect = mysql_connect("host","user","password");  
    if (!$connect){ 
        die("Failed to connect to the database: ".mysql_error()); 
    } 
$kies_bd = mysql_select_db("eraenz_db1",$connect); 
    if (!$kies_bd){ 
        die("failed to choose from BD: ".mysql_error()); 
    } 
$query = mysql_query("SELECT ListNumber FROM residential");// or die($myQuery."<br/><br/>".mysql_error()); 
//$result1 =  mysql_fetch_assoc($query);// or die($myQuery."<br/><br/>".mysql_error()); 
print_r($result1)."</ br>";
    if (mysql_num_rows($query) >10){ 
        $difference = mysql_num_rows($query) - 10; 
        $myQuery = mysql_query("SELECT * FROM residential ORDER BY ListNumber LIMIT 10,". $difference) ; 
       $result2 = mysql_fetch_assoc($query);// or die($myQuery."<br/><br/>".mysql_error());
//print_r($result2);
        $replace =  str_replace(", "," | ", $result2);
    while ($line = mysql_fetch_array($result2, MYSQL_BOTH)){ 
        mysql_query("INSERT INTO lisitngs
        (listnumber, mandatetype, listdate,expirydate, updatedate,virtualtoururl,status,propertyright,agnt_id, erfsize,erf_no, housesize,outbuildingsize,    bathroomoptions,closedusergroup,facingoptions,features,kitchenoptions,flatlet,parking,carport,price,numofbath,numofbed, numofgarages, numofkitchens, numofreception,numofstudies,numofdomesticbath,numofdomesticbed,numofoutsidetoil,off_id,ownershiptype, parkingdesc, pooloptions,pool,sellingreason,sfeatureoptions,roofoptions,roomoptions,walloptions,windowoptions, styleoptions,securityoptions,tempcontrol,streetname,streetnumber, suburb, propertycategory,propertytype,ss_name,agentcontactname,province,city, postalcode,email,listingstatus,feedtype, rates, levies)
        values ({$line['ListNumber']}','{$line['MandateType']}','{$line['ListDate']}','{$line['ExpiryDate']}','{$line['UpdateDate']}','{$line['VisualTourURL']}','{$line['Status']}','{$line['PropertyCategory']}','{$line['AgentI']}','{$line['SizeOfErf']}','{$line['StandNumber']}','{$line['SizeOfHouse']}','{$line['SizeOfOutBuildings']}','{$line['BathroomOptions']}','{$line['ClosedUserGroup']}','{$line['FacingDescrip']}','{$line['Features']}','{$line['KitchenOptions']}','{$line['Flatlet']}','{$line['Parking']}','{$line['NumOfCarports']}','{$line['ListPrice']}','{$line['NumOfBathrooms']}','{$line['NumOfBedrooms']}','{$line['NumOfGarages']}','{$line['NumOfKitchens']}','{$line['NumReceptionRooms']}','{$line['NumStudies']}','{$line['NumOfDomBathrooms']}','{$line['NumOfDomBedrooms']}','{$line['NumOfOutSideToilets']}','{$line['OfficeId']}','{$line['OwnershipType']}','{$line['ParkingDesc']}','{$line['PoolOptions']}','{$line['Pool']}','{$line['ReasonForSelling']}','{$line['SpecialFeatures']}','{$line['RoofOptions']}','{$line['RoomOptions']}','{$line['WallFinishes']}','{$line['Windows']}','{$line['StyleOptions']}','{$line['SecurityOptions']}','{$line['TempControl']}','{$line['StreetName']}','{$line['StreetNumber']}','{$line['Suburb']}','{$line['PropertyCategory']}','{$line['TypeOfProperty']}','{$line['UnitName']}','{$line['AgentContactName']}','{$line['Province']}','{$line['City']}','{$line['PostalCode']}','{$line['SellerEmail']}','{$line['Status']}','{$line['FeedType']}','{$line['MunRatesTaxes']}','{$line['MonthlyLevy']}')"); 
        mysql_query("INSERT INTO clients
                (clnt_title,clnt_name,clnt_surname,clnt_street_name,clnt_street_no,clnt_complex_name,clnt_unit_no,clnt_suburb,clnt_city,clnt_cell,clnt_email,agnt_id,)
        values ({$line['SellerTitle']}','{$line['SellerFirstName']}','{$line['SellerSurname']}','{$line['StreetName']}','{$line['StreetNumber']}','{$line['UnitName']}','{$line['UnitNumber']}','{$line['Suburb']}','{$line['City']}','{$line['SellerMobileNumber']}','{$line['SellerEmail']}','{$line['AgentID']}')"); 
       // mysql_query("DELETE FROM residential WHERE ListNumber={$line['ListNumber']}"); 
       // echo "{$line['ListNumber']} was deleted <br/>"; 
    } 
 } 
 mysql_close($connect); 

?>

不要将表“链接”在一起,使用JOIN语句并使用PHP对象访问所有信息。

我不明白“链接”是什么意思,您需要告诉我们,表t1的哪个字段必须与表t2的字段f2链接。关于链接,有什么不需要理解的?正确的客户端行应该链接到清单中的clients属性行?现在我想起来了,这两行都应该是clnt_idlook up mysql JOIN语句。属性表中的字段必须包含客户端id valie或其他内容。