Showing data too many times

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
New problem ;). I got script running and showing projects, now i'm trying to
show category for every project from another table. I want to do this in new
page. Everything is fine except ;))... it shows the data in according with
how many projects i have. So if i have 3 project da data from category table
is shown three times, if two projects it's shown two times etc.
The code is following:

 $conn = mysql_connect(SQL_HOST, SQL_USER, SQL_PASS) or
   die ('Could not connect to MySQL database.' .mysql_error());
    mysql_select_db (SQL_DB, $conn);

$display_block = "<h1>$project_name</h1>
<P>Select a Category to see details.</P>";

//validate category
$cat_id_info = isset($_GET['id']) ? intval($_GET['id']) : 0;
 $get_info = "SELECT,
     category.project_id = $cat_id_info
    ORDER BY category.cat_name";
 $result = mysql_query($get_info) or die (mysql_error());
 $num_category = mysql_num_rows($result);

  $display_block .= "<a href=\"proba_link.php\">Back</a></strong></p>";

  if (mysql_num_rows($result) < 1) {
     $display_block = "<P><em>BLABLA.</em><br>
     <a href=\"proba_link.php\">Back</a></strong></p>";
  } else {

    while ($cat = mysql_fetch_array($result)) {
         $cat_id = $cat[id];
         $cat_name = strtoupper(stripslashes($cat[cat_name]));
         $cat_desc = stripslashes($cat[cat_desc]);

         $display_block .= "<p><strong>$cat_name</strong>

 <TITLE>Navtec Marine</TITLE>

 print $display_block;


Tnx in advance, best regards
Igor Slivka

Re: Showing data too many times

Igor Slivka wrote:

Quoted text here. Click to load it
Quoted text here. Click to load it

You haven't joined the category and project tables so your getting a
cartesian product. Guessing the structure of your data, I would try adding
in the where clause.

'$cat_id_info' is badly named since it references a project not a category
(either that or the names of your other fields are bad).



Site Timeline