Jump to content

Dynamic links in a table?


Solarpitch

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>";
Link to comment
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.
Link to comment
Share on other sites

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.