I'm really getting stuck with this, I've tried so many different ways and I am unable to get what I need in order to make this work. Please, can you show me what's wrong in order for me to get this working.
In trying to build a property website a file (.blm) is uploaded, I am in need of getting the AGENT_REF from this file into an array so I can compare against the database and show the array difference... The .blm file contains information AGENT_REF^ADDRESS_1^ADDRESS_2^POSTCODE1^POSTCODE2...
I am convinced that it's the AGENT REF that's not working correctly in order to get the results I need.
Please help me solve this.
<?php
$rmdata = $rmparser->getPropertyData();
$properties = array();
foreach ($rmdata as $properties) {
$fields = array();
$values = array();
$blmarArray = array();
foreach ($properties as $field=>$value) {
if (!$value) continue;
$blmarArray = $values[0];
$agentref = $values[0];
$fields[] = $field;
$values[] = "'".$value."'";
}
$sql_archeck = mysql_query("SELECT `AGENT_REF` FROM `eprentals`");
$sqlarArray = array();
while($row = mysql_fetch_array($sql_archeck)) {
$sqlarArray[] = $row['AGENT_REF'];
}
$combyArrayDiff = array_diff($sqlarArray, $blmarArray);
echo '
<div style="background-color:#ffd7d7;border:#bcbcbc solid 1px;padding:6px;margin- bottom:6px;">
<span style="padding:2px;"><p><b>SQL list:</b> ' . implode(', ', $sqlarArray) . '</p></span>
<p><b>Uploaded list:</b> ' . implode(', ', $blmarArray) . '</p>
<p><b>Diff list:</b> ' . implode(', ', $combyArrayDiff ) . '</p>
</div>
';
}
I Greatly appreciate any assistance from this, it's really got me baffled. Thank you so much for your time.
I guess this is what you want to do:
/* create 2 empty arrays */
$rm_agentrefs = array();
$db_agentrefs = array();
/* fetch rmdata */
$rmdata = $rmparser->getPropertyData();
/* foreach rmdata */
foreach($rmdata as $current_row)
{
/* store the Agent Ref in the rm-array */
$rm_agentrefs[] = $current_row['AGENT_REF'];
}
/* define a database query for fetching agent ref from database */
$db_query = "SELECT `AGENT_REF` FROM `eprentals`";
/* run the database query */
$db_resource = mysql_query($db_query);
/* fetch each line from the resource */
while($current_row = mysql_fetch_array($db_resource))
{
/* store each agent ref in the db-array */
$db_agentrefs[] = $current_row['AGENT_REF'];
}
/* compare db and rm arrays (missing = db - rm) */
$missing_agentrefs = array_diff($db_agentrefs, $rm_agentrefs);