1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Duplicate output

Discussion in 'PHP' started by zed420, Nov 24, 2008.

  1. #1
    Hi All
    Can someone please point out what am I doing wrong here, the query should display one set of results but its showing me THREE same results even thou there is only ONE set of results in the databse so the insert query is fine it hasn't inserted the duplicate data. Some help will appreciated. Thanks
    		function normalJob(){
    $id = $_GET['id'];
    $query = "SELECT DISTINCT 
    job_tb.job_id,job_tb.dateTime,job_tb.cust_name,job_tb.cust_address,job_tb.des,job_tb.typeOfbooking, user.id 
    FROM job_tb,user 
    WHERE job_tb.user_id = '$id'";
    $result = mysql_query($query)or die(mysql_error());	   
    
    ?><div class="smallerText">
    <b>These are the jobs you have booked so far.  Please click on Job ID to view further details about the job</b>
    <TABLE BORDER=0 WIDTH=100% CELLSPACING=3 CELLPADDING=3 ALIGN=CENTER bgcolor="#CCCCCC">
    <TR bgcolor="#FFFFCC" align="center">
    <td width="10%"><font color=red><b>Job No.</b></font></TD>
    <td width="15%"><font color=red><b>Date/Time</b></font></TD>
    <td width="15%"><font color=red><b>Name</b></font></TD>
    <td width="25%"><font color=red><b>Pick up Address</b></font></TD>
    <td width="20%"><font color=red><b>Destination</b></font></TD>
    <td width="20%"><font color=red><b>Booking Type</b></font></TD>
    </tr>
    <?
     	while ($row = mysql_fetch_array($result))  {
        extract($row);
    		echo "<tr >
    <td>
    <a href=\"javascript:open_window('detailNormal.php?job_id=$job_id');\">" . $row['job_id'] . "</a></td>
    		<td>" . $row['dateTime'] . "</td>
    		<td>" . $row['cust_name'] . "</td>
    		<td>" . $row['cust_address'] . "</td>
    		<td>" . $row['des'] . "</td>
    		<td>" . $row['typeOfbooking'] . "</td>
    		</tr>";
    	}
    ?></TABLE></div><?
    } 
    normalJob();
    
    Code (markup):
    Thanks
    Zed
     
    zed420, Nov 24, 2008 IP
  2. share_boy

    share_boy Active Member

    Messages:
    71
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #2
    Change :

    job_tb.job_id,job_tb.dateTime,job_tb.cust_name,job_tb.cust_address,job_tb.des,job_tb.typeOfbooking, user.id
    FROM job_tb,user
    WHERE job_tb.user_id = '$id'";

    To :

    job_tb.job_id,job_tb.dateTime,job_tb.cust_name,job_tb.cust_address,job_tb.des,job_tb.typeOfbooking, user.id
    FROM job_tb,user
    WHERE job_tb.user_id = '$id' and job_tb.user_id = user.id " ;
     
    share_boy, Nov 25, 2008 IP
  3. zed420

    zed420 Member

    Messages:
    60
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #3
    thanks for your reply its been sorted

    Thanks
    Zed
     
    zed420, Nov 26, 2008 IP