Jump to content

Making query-result a link to new query


stirrah

Recommended Posts

Hello!

 

I have made a query and displaying this - it's working.

But I want this query-result to be a link (href) to another query that I want to display.

 

My query right now is: 

    	<ul>
            <?php
             $test = mysql_query("SELECT * FROM `huvudProject` WHERE `categoryProject` = 1");
                while($row = mysql_fetch_assoc($test))
                  {
                  echo "<li>" . $row['huvudProjectName'] . "</li>";
                  }
            ?>


    	</ul>

I want the 'huvudProjectName' be the name of a link. How can I do this? Also, I want this link to do a query when I click it for this:

SELECT * FROM `project` WHERE `projectHuvudId` = 1

And then show the result somewhere. Is this possible?

Link to comment
https://forums.phpfreaks.com/topic/282281-making-query-result-a-link-to-new-query/
Share on other sites

have you researched what the html syntax is of a href link and attempted to solve this yourself?

 

its a pretty basic task and someone posting the solution would allow you to see what it looks like, but that doesn't teach you how to define what you want and do the coding to accomplish it.

Well make it a link to another page like project.php and pass it the 1 parameter but I'm not sure where you get the 1 one the original page.  Is there a projectHuvudId column in the huvudProject table or does the 1 come from the categoryProject column?

echo "<li><a href='http://www.testlink.com/project.php?id=" . $row['projectHuvudId'] . "'>" . $row['huvudProjectName'] . "</a></li>";
//project.php

if(isset($_GET['id'])) {
    $id = (int)$_GET['id'];
    //SELECT * FROM `project` WHERE `projectHuvudId` = $id
}

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.