ms access - php select from a join table -
still new php! want select number of products category name, i'm getting no results. suggestions?
i have products table , categories table created in ms access:
    category fields categoryid, productid, , category head, sculpture, , vase records. 
     products fields productid, productname, price, , details. 
$conn = new com("adodb.connection") or die("cannot start ado"); $connstring= "provider=microsoft.jet.oledb.4.0;data source=e:\\ectserver\\aharden2\\database\\products.mdb"; //creates connection object , define connection string $conn->open($connstring); $selectcommand="select productname, price, details products productid = head"; $rs = $conn->execute($selectcommand); //opens recordset connection object if (!$rs->eof){ $productname = $rs->fields("productname"); $price = $rs->fields("price"); $details = $rs->fields("details"); } print "you selected following product last time:<p>"; print "<div id=\"category\"> "; print "product name: $productname<br>"; print "price: $price<br>"; print "details: $details<br>"; print "</div>"; $rs->close;  
your sql command
$selectcommand="select productname, price, details products productid = head";  must changed pulls data both tables. use sql joinfor purpose. join 2 tables based on common id. example this
$selectcommand="select productname, price, details products join category on products.productid = category.productid";  the above query join 2 tables based on productid field. can of course apply clause in end of query sql query.
if not solves problem, let me know can clarify it.
Comments
Post a Comment