Jump to content

Archived

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

Solarpitch

Dynamic links in a table?

Recommended Posts

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>";

Share this post


Link to post
Share on other sites
Change the loop in the following way:

[code]<?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>";
}

?>[/code]


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

Orio.

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites

×

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.