Jump to content

mixed data, 2 tables, and wildcard WHERE and Select based on other query


jaxdevil

Recommended Posts

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
}
?>
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.