Update a specific record set in codeigniter - php

Hi i have been trying to update a specific record on my database. After getting it's id that's passed in url using "baseurl" so far I can pass the variable but cannot seem to update the record. Here's my controller class update_request_record.php which holds the function Update function that is used to fetch the entire record from the database, which the loads the Update_request_view_page.php which holds the form that will enable a user to update the required fields. so far I have encountered the problem of the form not displaying at all, please help.Thanks
<?php
class Update_Request_Record extends CI_Controller {
public function Update_Request_Record()
{
parent::__construct();
}
function Update()
{
$id = $this->uri->segment(3);
$this->load->database();
$query = $this->db->get_where('test_request', array('id' => $id));
return $query->result();
$this->load->view('update_request_view'.$query);
}
function Submit()
{
$this->load->model('update_requestmodel');
if($this->input->post('submit')){
$this->update_requestmodel->Update();
}
//redirect('home');
}
}
?>
Here's my Model
<?php
class Update_Requestmodel extends CI_Model {
// model constructor function
function __construct() {
parent::__construct(); // call parent constructor
$this->load->database();
}
function Update()
{
$new_data = array(
'applicant_name'=>$this->input->post('applicant_name'),
'applicant_address'=>$this->input->post('applicant_address')
);
$this->db->update('test_request', $new_data);
//redirect('home');
}
}
?>
This is from my list view page that passes the id of a record to the controller Update_request_record.php
<table class="list_header" bgcolor="#ffffff" border="0" width="960px" cellpadding="4px">
<?php foreach($query as $row): ?>
<tr>
<td style="border-right: dashed 1px #c0c0c0;text-align: center;border-bottom: solid 1px #c0c0c0;"><?php echo $row->id; ?>.</td>
<td style="text-align: left;border-bottom: solid 1px #c0c0c0;" ><?php echo $row->testing_reason;?></td>
<td style="text-align: left;border-bottom: solid 1px #c0c0c0;"><?php echo $row->applicant_name;?></td>
<td style="text-align: left;border-bottom: solid 1px #c0c0c0;"><?php echo $row->authorizer_name;?></td>
<td style="text-align: left;border-bottom: solid 1px #c0c0c0;"><?php echo $row->received_by;?></td>
<td style="text-align: left;border-bottom: solid 1px #c0c0c0;"><?php echo $row->test_required;?></td>
<td style="text-align: left;border-bottom: solid 1px #c0c0c0;"><?php echo $row->test_specification;?></td>
<td style="text-align: left;border-bottom: solid 1px #c0c0c0;"><?php echo $row->laboratory_number;?></td>
<td style="text-align: left;border-bottom: solid 1px #c0c0c0;"><?php echo $row->date;?></td>
<td style="text-align: left;border-bottom: solid 1px #c0c0c0;">Edit</td>
</tr>
<?php endforeach; ?>
</table>
Here's my form update_request_view.php
<div id="analysis_request" class="analysis_request" >
<?php echo validation_errors(); ?>
<?php echo form_open('update_request_record/Submit',array('name'=>'test_request_update_form'));?>
<table class="table_form" width="750px" height="500px" border="0" cellpadding="4px" align="center">
<tr>
<td colspan="7" align="center" style="padding:8px;border-bottom: solid 1px #bfbfbf;">
<b><h3>UPDATING TEST REQUEST FORM</h3></b>
</td>
</tr>
<tr>
<td align="center" style="border-right: dashed 1px #bfbfbf;"><b>1.</b></td>
<td colspan="2"><b>Name of Applicant</b></td>
<td colspan="4"><textarea rows="1" cols="50" name="applicant_name" value="<?php echo $query->applicant_name;?>"></textarea></td>
</tr>
<tr>
<td align="center" style="border-right: dashed 1px #bfbfbf;"></td>
<td colspan="2"><b>Address of Applicant</b></td>
<td colspan="4"><textarea rows="1" cols="50" name="applicant_address"></textarea></td>
</tr>
<tr>
<td style="border-top: dotted 1px #bfbfbf;text-align: center;" colspan="7" ><input type="submit" name="submit" value="Submit"></td>
</tr>
</table>
</form>
</div>
</div>

Post your $id from your form in an hidden input named id here, Then try this:
Add this line inside your form:
<?php echo form_hidden('id', $query->id) ?>
Then in your model do the following change:
$this->db->where('id', $this->input->post('id'));
$this->db->update('test_request', $new_data);

Just as a suggested improvement to your code to make it slightly more DRY, you could throw this into your model:
$column_mapping = array(
'db_col1' => 'input_field1'
//more columns/fields
);
foreach ($column_mapping as $k => $v) {
$new_data[$k] = $this->input->post($v);
}
Personally, I see a whole bunch of repeated code such as 'something' => $this->input->post('something'); and think "AHHHH!".

Related

how to while loop inside of a while loop as well as grouping the result if more than one of the result are matching

The code provided is while-loop, which work, part of the loop is to update database and to return the updated info back to loop that work too. The problem I am having is if the return result is more than one it should not loop that result only echo it once.
I have tried other ways of doing this, but nothing giving me the result I need, I have the amount of knowledge I have on PHP. If someone could please help me, there help would be greatly appreciated.
<?php
//////////////////////// non-spouse kid start ///////////////////////
$nonspouseKidSql=("SELECT * FROM familyTree WHERE memberEmail='$login_mem' AND familyRelationship='son' AND familySide='other' OR memberEmail='$login_mem' AND familyRelationship='daughter' AND familySide='other' OR fam
ilyEmail='$login_mem' AND familyRelationship='father' AND familySide='other' OR familyEmail='$login_mem' AND familyRelationship='mother' AND familySide='other'");
$nonspouseKidQuery=mysql_query($nonspouseKidSql)or die ("error 1 Sorry we have a mysql error!");
$num_rowsNonspouseKid=mysql_num_rows($nonspouseKidQuery);
if ($num_rowsNonspouseKid < 1){echo '';}
else{
while($getnonspouseKidRow=mysql_fetch_array($nonspouseKidQuery)){
$getnonspouseKidEmail = $getnonspouseKidRow['familyEmail'];
$getNSPEmail = $getnonspouseKidRow['memberEmail'];
$nonspouseKid_relationship = $getnonspouseKidRow['familyRelationship'];
if($getNSPEmail == $login_mem){$nonspouseKidEmail = $getnonspouseKidEmail;}elseif($getnonspouseKidEmail == $login_mem){$nonspouseKidEmail = $getNSPEmail;}
$sql=("SELECT * FROM members WHERE email='$nonspouseKidEmail'");
$query=mysql_query($sql)or die ("error 1 Sorry we have a mysql error!");
$num_rows=mysql_num_rows($query);
while($row=mysql_fetch_array($query)){
$familyNonspouseKid_id = $row["id"];
$familyNonspouseKid_firstName = $row["firstName"];
$familyNonspouseKid_lastName = $row["lastName"];
$familyNonspouseKid_email= $row["email"];
$familyNonspouseKid_profile_pic = $row["profile_pic"];
$familyNonspouseKid_status = $row["status"];
$familyNonspouseKid_gender = $row["gender"];
if($nonspouseKid_relationship=="son"){$familyNonspouseKid_relationship ='son';}elseif($nonspouseKid_relationship=="daughter"){$familyNonspouseKid_relationship ='daughter';}
$member_familyPicNonspouseSon='/home/users/web/b2072/moo.poryniticom/profilePic/'.$familyNonspouseKid_id.'/'.$familyNonspouseKid_profile_pic.'';
if($familyNonspouseKid_profile_pic!==""){
$member_familyPicNonspouseSon='<div id="connection_nonSpouseKid" class="connection_nonSpouseKid"></div><div id="memFamilyPic_nonSpouseKid" class="memFamilyPic_nonSpouseKid"><a href="headstoneViewMember.php?userName='.
$familyNonspouseKid_email.'" id="'.$familyNonspouseKid_id.'" class="display_familyInfo"><img src="/profilePic/'.$familyNonspouseKid_id.'/'.$familyNonspouseKid_profile_pic.'" style="padding: 1px 1px 1px 1px;"
class="memFamilyPic_border" width="60" height="60" border="0" alt="" /></a><div id="familyDisplayDiv'.$familyNonspouseKid_id.'" class="familyDisplayDiv" style="display:none">
<table width="100%">
<tr>
<td align="left" valign="middle"><span style=" font-size: 16px; color:#999999 ;">Your '.$familyNonspouseKid_relationship.'</span></td>
</tr>
<tr>
<td align="left" valign="middle"><span style=" font-size: 16px; color:#999999 ;">'.$familyNonspouseKid_firstName.' '.$familyNonspouseKid_lastName.'</span></td>
</tr>
</table>
</div>
</div>';
}else{
$member_familyPicNonspouseSon='<div id="connection_non-spouseKid" class="connection_nonSpouseKid"></div><div id="memFamilyPic_nonSpouseKid" class="memFamilyPic_nonSpouseKid"><a href="headstoneViewMember.php?userName='.
$familyNonspouseKid_email.'" id="'.$familyNonspouseKid_id.'" class="display_familyInfo"><img src="/profilePic/default/default_profilePic.png"style="padding: 1px 1px 1px 1px;" class="memFamilyPic_border" width="60"
height="60" border="0" alt=""/></a>
<div id="familyDisplayDiv'.$familyNonspouseKid_id.'" class="familyDisplayDiv" style="display:none">
<table width="100%">
<tr>
<td align="left" valign="middle"><span style=" font-size: 16px; color:#999999 ;">Your '.$familyNonspouseKid_relationship.'</span></td>
</tr>
<tr>
<td align="left" valign="middle"><span style=" font-size: 16px; color:#999999 ;">'.$familyNonspouseKid_firstName.' '.$familyNonspouseKid_lastName.'</span></td>
</tr>
</table>
</div>
</div>';
}
$member_familyPicNonspouseDaughter='/home/users/web/b2072/moo.poryniticom/profilePic/'.$familyNonspouseKid_id.'/'.$familyNonspouseKid_profile_pic.'';
if($familyNonspouseKid_profile_pic!==""){
$member_familyPicNonspouseDaughter='<div id="connection_nonSpouseKid" class="connection_nonSpouseKid"></div><div id="memFamilyPic_nonSpouseKid" class="memFamilyPic_nonSpouseKid"><a
href="headstoneViewMember.php?userName='.
$familyNonspouseKid_email.'" id="'.$familyNonspouseKid_id.'" class="display_familyInfo"><img src="/profilePic/'.$familyNonspouseKid_id.'/'.$familyNonspouseKid_profile_pic.'" style="padding: 1px 1px 1px 1px;"
class="memFamilyPic_border" width="60" height="60" border="0" alt="" /></a>
<div id="familyDisplayDiv'.$familyNonspouseKid_id.'" class="familyDisplayDiv" style="display:none">
<table width="100%">
<tr>
<td align="left" valign="middle"><span style=" font-size: 16px; color:#999999 ;">Your '.$familyNonspouseKid_relationship.'</span></td>
</tr>
<tr>
<td align="left" valign="middle"><span style=" font-size: 16px; color:#999999 ;">'.$familyNonspouseKid_firstName.' '.$familyNonspouseKid_lastName.'</span></td>
</tr>
</table>
</div>
</div>';
}else{
$member_familyPicNonspouseDaughter='<div id="connection_nonSpouseKid" class="connection_nonSpouseKid"></div><div id="memFamilyPic_nonSpouseKid" class="memFamilyPic_nonSpouseKid"><a
href="headstoneViewMember.php?userName='.
$familyNonspouseKid_email.'" id="'.$familyNonspouseKid_id.'" class="display_familyInfo"><img src="/profilePic/default/default_profilePic.png"style="padding: 1px 1px 1px 1px;" class="memFamilyPic_border" width="60"
height="60" border="0" alt=""/></a>
<div id="familyDisplayDiv'.$familyNonspouseKid_id.'" class="familyDisplayDiv" style="display:none">
<table width="100%">
<tr>
<td align="left" valign="middle"><span style=" font-size: 16px; color:#999999 ;">Your '.$familyNonspouseKid_relationship.'</span></td>
</tr>
<tr>
<td align="left" valign="middle"><span style=" font-size: 16px; color:#999999 ;">'.$familyNonspouseKid_firstName.' '.$familyNonspouseKid_lastName.'</span></td>
</tr>
</table>
</div>
</div>';
}
if($familyNonspouseKid_relationship =='son'){echo $member_familyPicNonspouseSon;}else{echo $member_familyPicNonspouseDaughter;}
}
?>
<?php
//////// non-spouse kid end //////////////////////////////
?>
<?php
//////////////// child parent not spouse start ////////
?>
<div id="connection_childParent" class="connection_childParent"></div>
<div id="memFamilyPic_childParent" class="memFamilyPic_childParent">
<?php
$getGender = $mem["gender"];
if($getGender=='male'){$parentGender='Mother';}else{$parentGender='Father';}
$parentNameSql=mysql_query("SELECT * FROM familyTree WHERE memberEmail='$nonspouseKidEmail' AND familyRelationship='mother' OR memberEmail='$nonspouseKidEmail' AND familyRelationship='father'")or die ("Sorry can't
get parent name!");
$parentNameRow=mysql_fetch_array($parentNameSql);
$parentName = $parentNameRow['familySide'];
$childParentSql=mysql_query("SELECT * FROM familyTree WHERE memberEmail='$login_mem' AND familyRelationship='childmother' AND child_Id='$familyNonspouseKid_id' OR memberEmail='$login_mem' AND
familyRelationship='childfather' AND child_Id='$familyNonspouseKid_id'")or die ("Sorry can't get child parent!");
$childParentRow=mysql_fetch_array($childParentSql);
if($childParentRow < 1){echo '<p id="'.$familyNonspouseKid_id.'" class="mysql_returnNonspouseKid" align="center" style="color: #999; font-size:13px;">Child '.$parentGender.'</p>';
}else if($childParentRow > 2){
$childParentEmail = $childParentRow['familyEmail'];
$familyChildParent_relationship = $childParentRow["familyRelationship"];
$childParent=("SELECT * FROM members WHERE email='$childParentEmail'");
$query=mysql_query($childParent)or die ("error 1 Sorry we have a mysql error!");
$num_rows=mysql_num_rows($query);
if($childParentRow > 2){
while($row=mysql_fetch_array($query)){
$familyChildParent_id = $row["id"];
$familyChildParent_firstName = $row["firstName"];
$familyChildParent_lastName=$row["lastName"];
$familyChildParent_email=$row["email"];
$familyChildParent_profile_pic = $row["profile_pic"];
$familyChildParent_status=$row["status"];
$member_familyPicChildParent='/home/users/web/b2072/moo.poryniticom/profilePic/'.$familyChildParent_id.'/'.$familyChildParent_profile_pic.'';
if($familyChildParent_profile_pic!==""){
$member_familyPicChildParent='<a href="headstoneViewMember.php?userName='.$familyChildParent_email.'" id="'.$familyChildParent_id.'" class="display_familyInfo"><img src="/profilePic/'.$familyChildParent_id.'/'.
$familyChildParent_profile_pic.'" style="padding: 1px 1px 1px 1px;" id="memFamilyPic_border'.$familyChildParent_id.'" class="memFamilyPic_border" width="60" height="60" border="0" alt="" /></a>';
}else{
$member_familyPicChildParent='<a href="headstoneViewMember.php?userName='.$familyChildParent_email.'" id="'.$familyChildParent_id.'" class="display_familyInfo"><img
src="/profilePic/default/default_profilePic.png"style="padding: 1px 1px 1px 1px;" id="memFamilyPic_border'.$familyChildParent_id.'" class="memFamilyPic_border" width="60" height="60" border="0" alt=""/></a>';
}
}
if($familyChildParent_relationship =='childmother' or $familyChildParent_relationship =='childfather'){echo $member_familyPicChildParent;}
}}else{}
?>
<div id="familyDisplayDiv<?php echo $familyChildParent_id; ?>" class="familyDisplayDiv" style="display:none">
<table width="100%">
<tr>
<td align="left" valign="middle"><span style=" font-size: 16px; color:#999999 ;">Your <?php echo $familyChildParent_relationship; ?></span></td>
</tr>
<tr>
<td align="left" valign="middle"><span style=" font-size: 16px; color:#999999 ;"><?php echo $familyChildParent_firstName; ?> <?php echo $familyChildParent_lastName; ?></span></td>
</tr>
</table>
</div>
</div>
<?php
}}
///////////////// child parent not spouse end //////////////
?>

How to add contents in new page using TCPDF?

I am using TCPDF stuff, I have created a PDF page with some Information. But i need to show some data to next page deliberately.
pdf -> AddPage();
above code is used to create a new page which i know. But i wanna add specific data to this particular page would be the problem.
Help me to come out on this issue.
I have written my code like this
while($row = mysql_fetch_array($query)){
$inv = $row["INVNUM"];
$weight = $row["WEIGHT"];
if($i<4){
if($row["SIZECODE"] == "02"){
$temp .= '<tr nobr="true">
<td class="size1" style="border:1px solid #000">'.$json_a[$i]["S"].'</td>
<td class="size2" style="border:1px solid #000">'.$json_a[$i]["M"].'</td>
<td class="size3" style="border:1px solid #000">'.$json_a[$i]["L"].'</td>
<td class="size4" style="border:1px solid #000">'.$json_a[$i]["XL"].'</td>
<td class="size5" style="border:1px solid #000">'.$json_a[$i]["2X"].'</td>
<td class="size6" style="border:1px solid #000">'.$json_a[$i]["3X"].'</td>
</tr>';
}
else if($row["SIZECODE"] == "03"){
$temp .= '<tr>
<td style="border:1px solid #000">'.$json_a[$i]["32"].'</td>
<td style="border:1px solid #000">'.$json_a[$i]["34"].'</td>
<td style="border:1px solid #000">'.$json_a[$i]["36"].'</td>
<td style="border:1px solid #000">'.$json_a[$i]["38"].'</td>
<td style="border:1px solid #000">'.$json_a[$i]["40"].'</td>
<td style="border:1px solid #000">'.$json_a[$i]["42"].'</td>
</tr>';
}
$i = $i+1;
}
else{
$pdf ->AddPage();
$i = 0;
$temp.='<tr nobr="true">
<td colspan="18" style="border:1px solid #000">All sales are Final.</td>
<td colspan="2" style="border:1px solid #000">SUB TOTAL:</td>
<td style="border:1px solid #000"></td>
<td style="border:1px solid #000"></td>
</tr>
<tr>
<td colspan="18" rowspan="2" style="border:1px solid #000">Number # : '.$rowFix["Num"].' </td>
</tr>
<tr>
<td colspan="2">TOTAL DUE: $</td>
<td style="border:1px solid #000"></td>
<td style="border:1px solid #000"></td>
</tr>';
}
}
I have to bring the table rows to the next page when the $i value greater than 4.
$pdf->AddPage('P', 'A4');
$pdf->Cell(0, 0, 'A4 PORTRAIT', 1, 1, 'C');
First, output the content for the first page. Then:
pdf -> AddPage();
Then, output for the second page. Anything sent after this command will be outputted onto the second page.

HTML table not displaying with a php while loop inside of it

I am creating a table that loops information from my database. I created the table with html and added styling via an external css sheet. The table format is not displaying in any way. None of the borders are displaying and the 100% width is not working. Could my while loop be causing this affect?
<table class="tableproduct">
<tr>
<th class="thproduct">Product ID</th>
<th class="thproduct">Product Name</th>
<th class="thproduct">Price</th>
<th class="thproduct">Category</th>
<th class="thproduct">Description</th>
</tr>
<?php
while($row = mysqli_fetch_assoc($q)) : ?>
<tr>
<td class="tdproduct"><?php echo $row['product_id']; ?> </td>
<td class="tdproduct"><?php echo $row['name']; ?> </td>
<td class="tdproduct"><?php echo $row['price']; ?> </td>
<td class="tdproduct"><?php echo $row['category']; ?> </td>
<td class="tdproduct"><?php echo $row['description']; ?> </td>
</tr>
</table>
<?php endwhile; ?>
.tableproduct {
width: 100%;
border: 1px solid black;
}
.tdproduct {
border: 1px solid black;
}
.thproduct {
height: 100px;
border: 1px solid black;
}
I ended up resolving this.
I had to put an if statement with the while loops and it created the results I was looking for.
I added this to the while loop:
if( $result ){
while($row = mysqli_fetch_assoc($result)) :

Change main view position codeigniter

I have some problem with position off my tables.
here you can see what is looking now:
http://postimg.org/image/auv0lum57/
My controller:
?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class Manage_products extends CI_Controller {
public function __construct()
{
parent::__construct();
$this->load->model('Products_model');
$this->load->library('form_validation');
}
public function index()
{
session_start();
$this->data['products'] = $this->Products_model->get_all();
$this->data['title'] = 'Product Management';
$this->data['message'] = $this->session->flashdata('message');
$this->load->view('main_view', $this->data);
$this->load->view('manage_products', $this->data);
}
view off manage_products
Products
table, td, th
{
border:1px solid green;
}
th
{
background-color:green;
color:white;
}
#infoMessage p{
padding: .8em;
margin-bottom: 1em;
border: 2px solid #ddd;
background: #FFF6BF;
color: #817134;
border-color: #FFD324;
text-align: center;
}
</style>
</head>
<body>
<table width="700" border="0" align="center">
<tr>
<td><h2>Parduotuvės </h2></td>
</tr>
<tr>
<td><div id="infoMessage"><?php echo $message;?></div></td>
</tr>
<tr>
<td><input name="New" type="button" value="Pridėti naują" onclick="window.location='product/add'" /></td>
</tr>
</table>
<form name="frmproduct" method="post">
<input type="hidden" name="rid" />
<input type="hidden" name="command" />
<table width="700" align="center">
<tr>
<th width="150"><strong>Parduotuvės pavadinimas</strong></th>
<th><strong>Prekės identifikatorius</strong></th>
<th><strong>Nuoroda</strong></th>
<th><strong>Redaguoti</strong></th>
<th><strong>Ištrinti</strong></th>
</tr>
<?php
foreach ($products as $product){
$product_id = $product['id'];
?>
<tr>
<td><?php echo $product['pavadinimas'] ?></td>
<td><?php echo $product['prekesid'] ?></td>
<td><?php echo $product['linkas'] ?></td>
<td><a href='product/edit/<?php echo $product_id ?>'>Redaguoti</a></td>
<td>
<?php
echo anchor('product/delete/'.$product_id, 'Delete', array('onClick' => "return confirm('Ar tikrai norite ištrinti?')"));
?>
</td>
</tr>
<?php
}
?>
</table>
</form>
</body>
</html>
I think problem is with line 22. I must load main_view, but my table must be in main_view, not in bottom. How to fix this problem?
I think I under stood correct try something like
return $this->load->view('name', null, true) or $this->load->view('name', $data, true)
could try and use null or true, return for tables.

PHP Table Hyperlink

I have a table that returns information from mysql. However, I want to hyperlink each postcode so that when the user clicks on one it will redirect them to an appropriate page. Here is the code that is in the table:
<table style="border:2px solid black; border-collapse:collapse;" cellspacing="2" cellpadding="2" align="center">
<tr align="center" width="auto">
<td bgcolor="#66CCFF" style="border:2px solid black;"><b> Consultation Date </b></td>
<td bgcolor="#66CCFF" style="border:2px solid black;"><b> Patient Health Care Number </b></td>
<td bgcolor="#66CCFF" style="border:2px solid black;"><b> Location </b></td>
<td bgcolor="#66CCFF" style="border:2px solid black;"><b> Post Code </b></td>
<td bgcolor="#66CCFF" style="border:2px solid black;"><b> Update Record </b></td>
</tr>
<?php
$i=0;
while ($i < $num) {
$f1=mysql_result($result,$i,"Consultation Date");
$f2=mysql_result($result,$i,"Patient HCN");
$f3=mysql_result($result,$i,"Location");
$f4=mysql_result($result,$i,"Post Code");
?>
<tr>
<td align="center" bgcolor="#FFFFFF" style="border:2px solid black;"><?php echo $f1; ?></td>
<td align="center" bgcolor="#FFFFFF" style="border:2px solid black;"><b><?php echo $f2; ?></b></td>
<td align="center" bgcolor="#FFFFFF" style="border:2px solid black;"><?php echo $f3; ?></td>
<td align="center" bgcolor="#FFFFFF" style="border:2px solid black;"><?php echo "<a href=\"coveragehcp.php?patient= ". $f2 ."\">"?><b><?php echo $f4; ?></b></td>
<td align="center" bgcolor="#FFFFFF" style="border:2px solid black;"><?php echo "<button onclick=\"window.location.href='hcp_form_update.php?patient=$f2'\">"?>Update Record</button></td> <!-- This button redirects the user to the auto-populated form that holds the patients information which allows the user to update it -->
</tr>
<?php
$i++;
}
?>
However when the user click on the link below I want it to redirect them to another page according to the post code clicked.
<td align="center" bgcolor="#FFFFFF" style="border:2px solid black;"><?php echo "<a href=\"coveragehcp.php?patient= ". $f2 ."\">"?><b><?php echo $f4; ?></b></td>
What I would do is to use the post code as a parameter in the GET, and then use the $_GET['postcode'] to achieve which page should be presented for the user.
so your PHP code for the link would look something like:
<a href=\"coveragehcp.php?patient= ".$f2."&postcode=".$f4."\">"?><b><?php echo $f4; ?></b></td>
and on the coveragehcp.php page use this
$postcode = $_GET['postcode'];
if(!empty($postcode))
{
if($postcode == 90210) {
//Echo beverly hills page
}
else {
//Echo default page
}
}

Categories