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?

 

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!!!

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.