Jump to content

Passing parameters with <a href> link with current data from an array


jcjst21

Recommended Posts

I'm creating sort of a Course Information program.

When a user logs into the program.  They are given a list of each class they are taking.

This is given from an array file.

I have stored this class information in $data.

Then, each class is a link listed on the page, if the student clicks on this link, they shoudl be able to see their course information for that particular class.

I want to be able to pass what that person clicked on, plus their username through a hyperlink.

how would i do this?

what i have is

<a href="courseInfo.php?course=$data[$i]&student=$username>

now see where it says $data[$i] that would be the name of the course that the array pointer is on...

i need to pass that value...

how would i do that?

 

Link to comment
Share on other sites

typically you would have the users in one table related to their courses in another table. You would have them log into the application and then they would be transferred to their course page where it would query the courses table and based on the courses the student is taking you would loop through the list and show the links:

 

<?php
while ($data = mysql_fetch_array($result))
{
?>
<a href="courseInfo.php?course=<?= $data[0] ?>&student=<?= $username?>">link goes here</a>
<?php
}
?>

 

The $data[0] is assuming that you will change this number to whatever the column id is that you need. Hope this helps!!!

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.