0

im trying to figure out how i can do this.

i have a list of names being pulled from the database and when i click on a name i want another page to load with that names details.

I've done this before using ajax in an ajax driven contact book i made, but now i need to be able to take that persons name attach it to the $_GET and submit the form so another page loads with the persons name, just by having that persons name I can query my database.

Thats easy, but the trick here is that i have like 10 names being pulled from the database inside of a while loop.

so now I have ten tables with short details of the person along with their name. I want to have a click here for more details option. Thats whats confusing me, I don't want to use javascript just yet if at all possible. But without jquery I don't know how to grab the ID of the name. which is pointing towards the ajax route which i don't want to go into at this time.

any help would really be appreciated.

here is my while loop code with my attempt:

            <? while($project = mysql_fetch_assoc($pquery)){ ?>
             <form action="projectview.php" method="GET" id="viewproject">
                    <table border="0" align="right" style="border-bottom: 1px dashed #BDBDBD;" width="100%">
                    <tr><td colspan="2"><span><input type="submit" name="view" id="<?=$project['idProjects'];?>"><?=$project['project_name'];?><input type="hidden" name="<?=$project['idProjects'];?>"></span></td></tr>
                    <tr><td align="right" colspan="2"><span>post-production</span></td></tr>
                        <tr><td>Time:</td><td><?=daysDifference($project['end_date']);?> remaining</td></tr>
                        <tr><td>Budget:&nbsp;</td><td><?=$project['actual_budget'];?></td></tr>
                    <tr><td colspan="2"><?=$project['end_date'];?></td></tr>
                    </table>
              </form>  
                <br />
                <div style="padding: 3px;">&nbsp;</div>
             <? } ?>

2 Answers 2

1

I'm not completely sure what you're asking, but from what I can gather you want a list of names and each name has a "more info" link to a page that uses GET for parameters. For that you don't need to use forms, you can go with normal links and append the GET data to the link.

<?php while($project = mysql_fetch_assoc($pquery)){ ?>
    <?php echo $project[ 'project_name' ]; ?>
    <a href="projectview.php?projectId=<?php echo $project[ 'idProjects' ]; ?>">
        click here for more info
    </a>
<?php } ?>
Sign up to request clarification or add additional context in comments.

3 Comments

I agree, when you're not asking a user for any data, a simple link will be better.
hmmm I get it, on my other page how do I get the get parameter so I can use it in a variable?
The data is transferred just like in a form, for example $projectId = $_GET[ 'projectId' ]
0

It's not clear for me what is your problem. If you need to distinguish which form has been sent, you already have your hidden input. Just set a fixed name and change the value.

<input type="hidden" name="project" value="<?=$project['idProjects'];?>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.