Hey all im basically a bit lost when it comes to how to do something in PHP.

Im new to php programming and any help would be greatly appreciated:

I have a query that displays a list of courses (In a while loop).. now all these courses belong to say a department, and what I want to do is, make a link; when this department_id is clicked upon, that will open a new window, take the variable (department_id) and display the record for this department - all its details etc..

So you would have

Course ID Course Name Dep ID

Test1 Testing TestDep

----------------

Upon clicking TestDep it would then display the details for 'TestDep' department in a new window or even the same. Just not sure how to go about it, as its very widely used looking at other online databases.

Cheers - oh and if you want my code to help, i'll post it here no worries


Edit - Just to clear it up, these courses may belong to different departments, and the department_id would be pulled out from the query displaying the course data

Simple. Add a href for each department with department_id. ie.,

while(get_all_records){
echo '<a href="department_details.php?id=id_of_the_department> departmentname</a>'; //lists all the departments
}

In department_details.php, get the id, fetch its details from the table.

$id = $_GET['id'];
$query = "select * from department where id='$id'";
//execute it and get the department details and print it.

Cheers,
Naveen

Thanks alot, had alot of trouble getting it to echo my rows of data with the correct link, due to so many "'s and single quotations, in end used print, and seems work fine.. hope doesnt mess anything else up, but all the links list correctly like... view_details.php?id=test1 and so on

Good. Now, in view_details.php, get the id value, query the table and print it !

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.