Jump to content


Photo

Dynamic links in a table?


  • Please log in to reply
2 replies to this topic

#1 Solarpitch

Solarpitch
  • Members
  • PipPipPip
  • Advanced Member
  • 708 posts
  • LocationDublin, Ireland

Posted 15 October 2006 - 05:28 PM

Hey guys,

I'm developing a golf store site and I need help with the following...

I have a page that displays a list of driver names ie. Taylormade, Ping, Cobra etc...

The page that displays these pulls the names from the database and displays them in a table. What I would like to have is when the table is being populated with the driver names, have a dynamic link created which each driver that will then display all the different models of that driver.

Example:

Taylormade    view models>>
Ping              view models>>
Cobra            view models>>  etc...

Here's a quick example of the code that displays the driver names in the table...

<th>Make</th>

</tr>";while($row = $result->fetch_assoc())
  {
  echo "<tr>";
  echo "<td>" . $row['make'] . "</td>";

  echo "</tr>";


Guys . . . I would love some help with this please,
Thanks,

Gerard.
  }
echo "</table>";
Welcome to 9AM Monday, the furthest point away from 5PM Friday.

#2 Orio

Orio
  • Staff Alumni
  • Advanced Member
  • 2,491 posts

Posted 15 October 2006 - 06:08 PM

Change the loop in the following way:

<?php

while($row = $result->fetch_assoc())
{
  echo "<tr>";
  echo "<td>" . $row['make'] . "</td>";
  echo "<td><a href=\"viewmodels.php?mod=". $row['make'] ."\">View Models</a></td>"
  echo "</tr>";
}

?>


Then make a file called viewmodels.php that pulls out the models.
Just be careful with SQL-Injections.

Orio.
Think you're smarty?

(Gone until 20 to November)

#3 Solarpitch

Solarpitch
  • Members
  • PipPipPip
  • Advanced Member
  • 708 posts
  • LocationDublin, Ireland

Posted 15 October 2006 - 06:43 PM

Thanks a million . . worked like a charm. I thought it was something along the lines of that alright, but I kept doing it in a JSP syntax :)

Cool avatar by the way!
Welcome to 9AM Monday, the furthest point away from 5PM Friday.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users