Jump to content

[SOLVED] omitting result duplicates in dynamic forms


gwydionwaters

Recommended Posts

hello,

so i have a database containing tables with foreign keys corresponding to values like; rate(being a rating /10) author, cost, etc.

the database also has a table of items like this:

id|title|desc|cost_id|type_id etc ...

my form for browsing this database is built dynamically depending on what values have been used in the items table. each selectable list has it's own form. problem is that if i have three entries that are classed as a rating of 8/10, my drop list in the form contains three choices for 8/10.

my question.. how do i eliminate the extras of identical nature?

my form code is

<?
  include('scripts/dbase.incl.php');
  mysql_connect($hostname,$username,$password);
  @mysql_select_db($database) or die( 'unable to select database, please refresh');
  $query = 'SELECT * FROM items INNER JOIN type ON items.Type_id = type.Type_id INNER JOIN author ON items.Author_id = author.Author_id INNER JOIN func ON items.Func_id = func.Func_id INNER JOIN cost ON items.Cost_id = cost.Cost_id INNER JOIN rate ON items.Rate_id = rate.Rate_id';
  $result = mysql_query($query);
  $num = mysql_num_rows($result);
  mysql_close();
  ?>
// ...skip some irrelivance
<form name="abrowse" action="scripts/gearbrowse.php" method="post">Author<BR><select onChange="this.form.submit()" name="Author"><option></option>
     <?
  $i = 0;
  while ($i < $num) {
	  $Author=mysql_result($result,$i,"Author");
 ?>
     <option value="<? echo $Author; ?>"><? echo $Author; ?></option><? $i++ ; } ?></select></form>

Link to comment
Share on other sites

i suppose you could say that, but they both pertain to different aspects of my project. so to avoid confusing portions of a discussion i broke it up into one for each question. and i gave up trying and just retrieved the values from their index table instead of being based on their use in the items table

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.