jpglotzer Posted May 12, 2011 Share Posted May 12, 2011 Hi people, I've been having trouble with this for a while now. Basically, i have this website: http://el07jpg.info . You can log in with username:doctor1 password:password1 Once you've logged on, u can click on "Patients". Then, if you click on a patient, it shows their info. Then at the bottom, I have links to glucose readings and heart rate readings... but when I click on either of those links, it goes back to the main page, showing all the patients.. The weird thing is that I got this to work for the first step, u click on the <a href> link of a patient, and it brings you to their page. Then I've done the EXACT same thing to link to the glucose or heart rate readings of that specific patient, but it doesn't work. I really can't see what i've done wrong. Although I noticed in the address bar, when I click on glucose readings for example, the url is http://el07jpg.info/index.php?op=patients&id=&reading=glucose (id should be equal to a number, like id=4, but there's no number... Any help would be much appreciated! Cheers! Code for op_patients.php page: <?php //Page if a set of records is selected from a single patient's page if ($_REQUEST[reading]+0) { $GLOBALS['html']['css'][]="default.css"; $reading_source=$_REQUEST[reading]+0; $sql="select * from {$reading_source}_readings where patientRFID='{$patient[patientRFID]}' "; $results=mysql_select_assoc($sql); if (!$results){ $GLOBALS[err][]="No records exist!"; exit; } $GLOBALS['html']['title']="Patient: {$patient[first_name]} {$patient[last_name]}'s {$reading_source} readings "; echo $reading_source; } //Page if a single patient is selected if ($_REQUEST[id]+0) { $GLOBALS['html']['css'][]="default.css"; $id=$_REQUEST[id]+0; $sql="select * from patients where doctorID='{$_SESSION[user][id]}' and patientID='$id' "; $patient=mysql_select_assoc($sql); if (!$patient){ $GLOBALS[err][]="The patient can't be found!"; exit; } $GLOBALS['html']['title']="Patient: {$patient[last_name]}, {$patient[first_name]} "; $output.=" <br> <table border='1' cellpadding='5' cellspacing='5' width='600'> <tr><td rowspan=6><img src=\"$patient[photo]\"> </td> <th>Name: </th><td>{$patient[first_name]} {$patient[last_name]} </td></tr> <tr><th>D.O.B: </th><td>{$patient[dob]} </td></tr> <tr><th>Email: </th><td>{$patient} </td></tr> <tr><th>Phone Number: </th><td>{$patient[phone_no]}</td></tr> <tr><th>Address: </th><td>{$patient[address]}</td></tr> <tr><th><br> Comments:<br> </th> <td>{$patient[comments]} </td></tr> </table> <table border='1' cellpadding='5' cellspacing='5' width='600'> <tr><th colspan=3><br>Medical Readings<br><br></th></tr> <tr> <td align='center' width='300'> <a href='index.php?op=patients&id={$v[patientID]}&reading=glucose'>Glucose Readings</a> </td> <td colspan=2 align='center' width='300'> <a href='index.php?op=patients&id={$v[patientID]}&reading=heart'>Heart Rate Readings</a> </td> </tr> </table> "; echo $output; exit; } //Main Page showing all patients $GLOBALS['html']['title']="Patients"; $GLOBALS['html']['css'][]="default.css"; if(!$_SESSION[user][id]) { $er="Access Denied! Please Log in."; echo "<div style='color:red;'>$er</div>"; } else { $sql="select * from patients where doctorID='{$_SESSION[user][id]}' order by last_name"; $d=mysql_getarray_assoc($sql); $output=''; foreach ($d as $v){ $output.=" <tr><td> <a href='index.php?op=patients&id={$v[patientID]}'>{$v[last_name]}, {$v[first_name]}</a> </td></tr> "; } echo " <table width=80% align=left border='1' cellpadding='5' cellspacing='5' width='100%'> <tr><th class=popupheader align='left'> Patient Name<br><br> </th></tr> $output </table> "; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/236274-link-to-fill-page-with-different-data/ Share on other sites More sharing options...
btherl Posted May 13, 2011 Share Posted May 13, 2011 <a href='index.php?op=patients&id={$v[patientID]}&reading=glucose'>Glucose Readings</a> You can probably use $id here instead of $v[patientID]. I can see $id being used in the select query already. Quote Link to comment https://forums.phpfreaks.com/topic/236274-link-to-fill-page-with-different-data/#findComment-1214764 Share on other sites More sharing options...
jpglotzer Posted May 13, 2011 Author Share Posted May 13, 2011 Oh yea, true, I've changed that now, and the url now has id="x"... but nothing gets displayed on the page. No idea how to fix this! Quote Link to comment https://forums.phpfreaks.com/topic/236274-link-to-fill-page-with-different-data/#findComment-1214783 Share on other sites More sharing options...
btherl Posted May 13, 2011 Share Posted May 13, 2011 reading is a string, but your code has "$_REQUEST[reading]+0", which is typically used as a method of turning a string into an integer. So the first thing to do is remove the "+0" from each spot where you use $_REQUEST['reading']. Quote Link to comment https://forums.phpfreaks.com/topic/236274-link-to-fill-page-with-different-data/#findComment-1214785 Share on other sites More sharing options...
jpglotzer Posted May 13, 2011 Author Share Posted May 13, 2011 Awesome! it's working now! I really need to start properly understanding what I'm coding rather than copying and pasting things... Thanks a lot! Quote Link to comment https://forums.phpfreaks.com/topic/236274-link-to-fill-page-with-different-data/#findComment-1214791 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.