0

View all table field values using while loop, but same value is repeated many times.

How to solve it...?? Please any one help me?

$tender_select_query ="SELECT * FROM new_tender_one,new_tender_two,new_tender_three,new_tender_four WHERE new_tender_one.id = new_tender_two.tender_id AND new_tender_one.id = new_tender_three.tender_id AND new_tender_one.id = new_tender_four.tender_id";
$tender_select_result =mysql_query($tender_select_query);
while($tender_row = mysql_fetch_assoc($tender_select_result)){
    $id =$tender_row['id'];
    $work_name =$tender_row['work_name'];
    $procuring_entity =$tender_row['procuring_entity'];
    $reference_no =$tender_row['reference_no'];
    $procurement_method =$tender_row['procurement_method'];
    $bid_eligibility =$tender_row['bid_eligibility'];
    $last_date =$tender_row['last_date'];
    $pre_tend_info =$tender_row['pre_tend_info'];
    $comp_work =$tender_row['comp_work'];
    $tend_security =$tender_row['tend_security'];
    $tend_instruction =$tender_row['tend_instruction'];
    $tend_invite =$tender_row['tend_invite'];
    $cont_details =$tender_row['cont_details'];
    $publish_date =$tender_row['publish_date'];
    $tender_status =$tender_row['tender_status'];

    $tender_id =$tender_row['tender_id'];
    $tender_type =$tender_row['tender_type'];
    $tender_type_subcat =$tender_row['tender_type_subcat'];

    $item_name =$tender_row['item_name'];
    $item_description =$tender_row['item_description'];
    $item_offer =$tender_row['item_offer'];
    $quantity =$tender_row['quantity'];
    $unit_type =$tender_row['unit_type'];

    $required_name =$tender_row['required_name'];                       

enter image description here

1
  • 2
    Welcome to stackoverflow. Please read How to Ask. Commented May 8, 2016 at 9:51

1 Answer 1

1

The problem is the query you used.

If you have the same tender_id in new_tender_one or new_tender_two or so on, you will get multiple rows for sure.

new_tender_one

id  | tender_title
1   | tender_1
2   | tender_2

new_tender_two

tender_id | tenderer_name
    1     |  smith
    1     |  john
    2     |  paul

result

id  | tender_title | tender_id | tenderer_name
1   | tender_1     |     1     |  smith
1   | tender_1     |     1     |  john
2   | tender_2     |     2     |  paul

Make sure don't have repeating tender_ids in tables new_tender_two,new_tender_three,new_tender_four.

If there is, you have to use sub queries. Then you need to know which record you need from those other tables. (Eg: for id 1 whether smith or john).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.