sparz14 Posted June 21, 2011 Share Posted June 21, 2011 Hello, Im a PHP newbie and im trying to create an application in my spare time. I'm having trouble finding info on this which probably has a very easy fix! Ok so i have a MySQL database with a bunch of tables in it. One table is called "driver". It contains the information of all people who drive a collection of Taxi's. In this instance im trying to display a list of all the names drivers and when someone clicks on them, it will display more detailed information of the driver including contact details, etc. I have gotten all of the driver's names to appear using a While loop. I'm just having trouble understanding how i can link these properly. On the page with the drivers names im displaying "fname" "mname" "lname". I would like to link them using "da" (unique numbers for each driver). I have a file named "checkuser.php"which displays the list of drivers. I want the individual driver details in "userdetails.php". Any help would be appreciated. Thanks Link to comment https://forums.phpfreaks.com/topic/239970-dynamic-linking/ Share on other sites More sharing options...
Nodral Posted June 21, 2011 Share Posted June 21, 2011 When you create your while loop, have it output as a form within the loopand include a hidden input field of the drivers id (da) once the user clicks on this, run a seperate sql query to return the driver details. <?php //has driver been selected from form? if(isset($_POST['submit'])){ // get details for selected driver $sql="SELECT * FROM driver WHERE id=" . $_POST['id']; $sql=mysql_query($sql); $row=mysql_fetch_array($sql); //echo all details................. } //get info for all drivers $sql="SELECT * FROM driver"; $sql=mysql_query($sql); //start form echo'<form method="POST" action="">'; while($driver=mysql_fetch_array($sql)){ //populate each line with hidden id field echo $driver['fname'] . " " . $driver['mname'] . " " . $driver['lname'] . '<input type="hidden" name="id" value="'$driver['id'] .'"><input type="submit" name="submit" value="Get Details">'; } //end form </form> Link to comment https://forums.phpfreaks.com/topic/239970-dynamic-linking/#findComment-1232673 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.