Jump to content

PLEASE HELP - Select DB where Field is an array and loop table? How?


l4cky

Recommended Posts

I want to make a table for each paddler_id (Field) which exists into pushup Database

 

My code for paddler_id = 1 is


require "../sql.php";

$result = mysql_query("EXPLAIN pushup");
$r = mysql_query("SELECT * FROM paddlerinfo t1 LEFT JOIN pushup t2 on t2.paddler_id=t1.id LEFT JOIN practicedate t3 on t3.practice=t2.practice_id ORDER BY t1.firstname ASC ");
$r1 = mysql_query("SELECT * FROM pushup  where paddler_id =1 ORDER BY practice_id ASC ");

echo "<table width='30%' border='1' cellpadding='0' cellspacing='0' style='font-family: monospace'>";
echo "<tr>";
echo "<td>DATE</td>";
while ($row = mysql_fetch_array($result)) {
if (in_array($row["Field"], array("paddler_id", "practice_id", "p_id"))) continue;
echo "<td>",($row["Field"]), "</td>";
}
echo "</tr>";

while (($data = mysql_fetch_array($r1, MYSQL_ASSOC)) !== FALSE) {
   unset($data["p_id"],$data["paddler_id"]);
echo "<tr>";
   foreach ($data as $k => $v) { 
echo "<td>";
      echo"$v";
echo "</td>";
}

echo "</tr>";
}


echo "</table>";

mysql_free_result($result);
mysql_free_result($r);
mysql_free_result($r1);
mysql_close();

 

The problem is on line

$r1 = mysql_query("SELECT * FROM pushup  where paddler_id =1 ORDER BY practice_id ASC ");

I want to put something which makes it paddler_id = X where x = 2,3,4,5... and x exists in database and do not print twice the x (because that database may have rows where x = same id

 

 

How do i do that??

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.