jaxdevil Posted March 2, 2008 Share Posted March 2, 2008 I am a little twisted up here. I have two different tables, one table contains rows with a field name called 'fldname' and a field called 'id', and in another table has a matching field 'id' that contains the description the field ID of those names match up to. So I have a code that draws up the rows one a webpage, which works perfect, but I need each row on the webpage to also contain the field from the other table where the field name matches the first tables field 'id'. How can I import this? I tried like this but it wouldn't work. <?php $sql = "SELECT * FROM `fld` WHERE `fldview`='yes'"; $query = mysql_query($sql); while($row = mysql_fetch_array($query)) { $fldid = $row['id']; ?> <?php $sql = "SELECT $fldid FROM `stock`"; $query = mysql_query($sql); while($row = mysql_fetch_array($query)) { $fld_description = $row['id']; } ?> <p><div style="padding-left: 60px;"><label for="first_name"><?=$row['fldname']?></label> <input id="<?=$row['id']?>" name="<?=$row['id']?>" type="text" size="30" value="<?=$fld_description?>" /> </div></p> <?php } ?> ?> Link to comment https://forums.phpfreaks.com/topic/94091-mixed-data-2-tables-and-wildcard-where-and-select-based-on-other-query/ Share on other sites More sharing options...
Barand Posted March 3, 2008 Share Posted March 3, 2008 see http://www.w3schools.com/sql/sql_join.asp Link to comment https://forums.phpfreaks.com/topic/94091-mixed-data-2-tables-and-wildcard-where-and-select-based-on-other-query/#findComment-482045 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.