mysql query og php. kan an det her ?
hej jeg har en almindelig select statement i denne funktion der joiner mellem 2 tabeller.læg mærke til at jeg forsøger at selecte både Customer.id og Contacts.id.
Dette fejler som sådan ikke, men jeg kan heller ikke få adgang til contacs.id
her er funktionen
function getContactData($id, $type) {
if(is_numeric($id)){
logon();
$sql = "SELECT Customer.id,Customer.customer, Customer.address, Customer.zipCode, Customer.city, contacts.phone, contacts.firstName, contacts.lastName, contacts.phone, contacts.mobilPhone,
contacts.emailAddress,contacts.id FROM Customer, contacts where Customer.id
=contacts.customerId and contacts.customerId= $id and contacts.contactType=$type";
$contactData = mysql_query($sql) or die(mysql_error());
if(!$contactData) {
echo "query failed";
}
while ($row=mysql_fetch_array($contactData)){
$result[]=$row;
}
return $result;
close_db();
}
}
Her er hvordan jeg forsøger at få den efter funktionen er udført.
$result=getContactData($mindrop,1);
if (isset($result)) {
foreach ($result as $value) {
echo "<tr>";
echo "<form action=\"update_customer.php\"name = \"frmUpdateContacts\" method=POST >";
echo "<td><input type=\"text\" name = \"firstName\" value= \"".$value['firstName'] . "\"</td>";
echo "<td><input type=\"text\" name = \"lastName\"value= \"".$value['lastName'] . "\"</td>";
echo "<td><input type=\"text\" name = \"phone\" value= \"".$value['phone'] . "\"</td>";
echo "<td><input type=\"text\" name = \"mobilPhone\" value= \"".$value['mobilPhone'] . "\"</td>";
$contactId=$value['contacts.id'];
//echo "<td><input type=\"text\" value= \"".$value['address'] . "\"</td>";
echo "<td><input type=\"text\" value= \"".$value['emailAddress'] . "\"</td>";
$i=$i+1;
}
echo "<td></td><td><input type=\"submit\" value = \"Update Contacts\"></td>";
echo "<input type=\"hidden\" name = \"contactId\" value =$contactId>";
echo "<input type=\"hidden\" name = \"custId\" value = $mindrop>";
echo "<input type=\"hidden\" name = \"upDateType\" value = 2>";
echo "</form>";
}
hvordan kan jeg få indhold af f.eks id felt fra begge tabeller eller er det overhovedet muligt.
