Jump to content

Recommended Posts

THIS IS MY CODE:

"<?php

mysql_select_db("service", $db_handle);

 

$result = mysql_query("SELECT tp_id, email, Rating FROM tp_info WHERE tp_id.tp_info=user_skills.tp_info HAVING user_skills.sub_id=job_info.sub_id");

 

echo "<table border='1'>

<tr>

<th>Tradesperson Username</th>

<th>Tradesperson Email</th>

<th>Rating</th>

</tr>";

 

while($row = mysql_fetch_array($result))//ERROR LINE HERE

  {

  echo "<tr>";

  echo "<td>" . $row['tp_id'] . "</td>";

  echo "<td>" . $row['email'] . "</td>";

  echo "<td>" . $row['Rating'] . "</td>";

 

  echo "</tr>";

  }

echo "</table>";

 

?>

 

 

 

WHA SHOULD I DO TO SORT THIS OUT???

Have you tested your query in MySQL?

If not you could try:

SELECT tp_id, email, Rating FROM tp_info INNER JOIN user_skills ON (tp_id.tp_info=user_skills.tp_info) WHERE user_skills.sub_id = job_info.sub_id

Your use of HAVING is a bit off, it should only be used to limit a GROUP BY, not to refine an existing WHERE clause. Let us know how you get on.

The Table Structure is something like this:

Table Name        Field Name1          Field Name2        Field Name3      Field Name4

==============================================================

tp_info                tp_id                      Rating                email                  field4

user_skills          tp_id                      sub_id

job_info              sub_id

===============================================

I want to print tp_id,Rating,email from table-tp_info for only those tp_id that match tp_id from table-user_skills. Provided sub_id from table-user-skills match sub_info from table-job_info

 

What should my query be like????

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.