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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.