shadowsai
11-11-2012, 05:52 AM
No idea how to do this. Help guys?
So I have this neat little loop that basically goes through my SQL search results (through an index of songs), and tabulates the results.
while($row = mysql_fetch_row($result))
{
echo "<tr>";
// $row is array... foreach( .. ) puts every element
// of $row to $cell variable
foreach($row as $cell)
echo "<td>$cell</td>";
echo "</tr>\n";
}
What I want to do is for the first item in $row, link to that song using the $id. $id has been defined as $id = mysql_query("SELECT ID FROM $table ORDER BY `Title` ASC");
Ideally, the output will be something like:
----------------------------------------------------------------------
| Title | Author | Lyrics |
----------------------------------------------------------------------
|<a href="$ID">Title</a> | anon. | foo |
----------------------------------------------------------------------
How can I modify my foreach loop such that only on $row[0], it does something else?
Thank you!
So I have this neat little loop that basically goes through my SQL search results (through an index of songs), and tabulates the results.
while($row = mysql_fetch_row($result))
{
echo "<tr>";
// $row is array... foreach( .. ) puts every element
// of $row to $cell variable
foreach($row as $cell)
echo "<td>$cell</td>";
echo "</tr>\n";
}
What I want to do is for the first item in $row, link to that song using the $id. $id has been defined as $id = mysql_query("SELECT ID FROM $table ORDER BY `Title` ASC");
Ideally, the output will be something like:
----------------------------------------------------------------------
| Title | Author | Lyrics |
----------------------------------------------------------------------
|<a href="$ID">Title</a> | anon. | foo |
----------------------------------------------------------------------
How can I modify my foreach loop such that only on $row[0], it does something else?
Thank you!