PHP MYSQL JOIN QUERY 2 Databases, Where table1.id = table2.id, How to display table2.content as table1.id -


im trying put script allows me display links dynamically on site.

i have 2 tables. first one, domains can have 2 values per row. these being, domid , domain. next table, links can contain few values per row, ones im working here domid(matches domid of domains table) desc , `link'.

here query far:

$linkquery2 = 'select `link`,`desc`,`domid`                   `links`                  `catid`="'.$pagecat.'"                     && (`modid`="1" || modid="'.$pagemodel.'")               order `domainid` asc                  limit ' . $from . ', ' . $max_results2;     

here code im using display info need:

$linkloop2 = ''; $linkad = $row['link']; $linkdesc = stripslashes($row['desc']); $linkdomain = stripslashes($row['id']); $linkloop = '<ul class="bymodel-dllinks">'; $linkloop2 .= '<li><a href="'.$linkad.'" target="_tab">'.$linkdesc.' '.$linkdomain.'</a></li>'; $linkloop3 = '</ul>'; 

what trying find way when $linkdomain echo'd display text have stored in domain field on domains table. when $linkdomain echo'd, display 303, domid of site linking to.

use join select domain name domainstable :

$linkquery2 = 'select l.link,l.desc,l.domid,d.domain              links l left join domains d on d.domid = l.domid             l.catid="'.$pagecat.'"                 && (l.modid="1" || l.modid="'.$pagemodel.'")           order l.domainid asc              limit ' . $from . ', ' . $max_results2; 

Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -