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?

Edited by stirrah
Link to comment
Share on other sites

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
}
Edited by AbraCadaver
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.