/    Sign up×
Community /Pin to ProfileBookmark

Major Problems with including retrieving data from two tables.

Greetings All,
I am currently writing an application that has two tables.

Tables = CONTENT and THEME_IMAGE

CONTENT FIELDS = id, title, description, theme_id
THEME_IMAGE FIELDS = theme_id, title, filename

===================================
I have already written a script to output information from both tables. However, I am now working on a script to UPDATE the database from the web browser.

The CONTENT table is used to store information about an article. Each article has a theme image, but many articles can use the same theme image, hence the need for separate THEME_IMAGE table.
Now, when I go to edit the CONTENT article, there is a <select> field which should display ALL the contents from THEME_IMAGE table. This is so that when a user is editing the CONTENT article, they can select a new THEME IMAGE if one hasn’t been selected already.

Now, the problem I am getting is I don’t know how to interlink two tables (CONTENT + IMAGE_THEME) so that the user can see the IMAGE_THEME Image Title in the <select> <option> tags, and when they choose it, the “id” is written to the CONTENT theme_id table so that it can be referenced later.

Also, if there is a theme image already choosen, it should display that.

[code] <td>Theme Image:</td>
<td><select name=’Theme_Image’>
<? if($onecontent->Theme_Image!=””) { ?>
<option SELECTED value='<?php echo($Theme_Image); ?>’> <?php echo($Theme_Image); ?> </option>
<? } else {?>
<option value=”> No Theme_Image </option>
<? }?>
<?php
$sql = “select * from theme_image order by Theme_Title”;
$images = mysql_query($sql, $db);
while($oneimage = mysql_fetch_object($images))
{
echo (“<option value=’$oneimage->File’>$oneimage->Theme_Title</option>”);
}
?>
</select>
</td> [/code]

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @gc40 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...