Sophia_1 0 Junior Poster in Training

Hi everyone...have this table as header and i want to display it in all 2 tabs ie Quarter tabs.Currently, the header detail is only displayed in Quater 1 tab...and eventhough i've use include (header.php) in Quarter 2 tab, the header detail is not displayed.Please advise how to display the same header in Quarter 2 as well. Below are the codes. Thanks alot.

header.php

<?php
session_start();

    $_SESSION['Userid']; // it will print the userid value


$_SESSION['Username']; // it will print the userid value

?>
<html>
<head>
<title>Database</title>
<link rel="stylesheet" type="text/css" href="style.css"/>
</head>
<body>
<form name="<?php echo $_SERVER['PHP_SELF']?>" method="post" action="">
<div id="header">

     <?php

$connection = mysql_connect("localhost","pqa","") or die("Database connection failed!<br>");
$result=mysql_select_db("pq") or die("Database could not be selected!");

    $Targetid =0;


if (isset($_GET['Targetid'])) {
$Targetid = $_GET['Targetid'];
$_SESSION['Targetid']=$Targetid;

$query="Select * from general_ipd where Userid='".$_SESSION['Userid']."' and Targetid= '$Targetid'";//'".$_POST['Targetid']."'";
$result=mysql_query($query);
if($row=mysql_fetch_array($result))

{

echo "<input type='hidden' name='hidden' value='".$row['Userid']."'><br>";
echo "KRA:<input type='text' name='KRA' value='".$row['Kra']."'><br>";
echo "KPI:<input type='text' name='KPI' value='".$row['Kpi']."'><br>";
echo "Target:<input type='text' name='Target' value='".$row['Target']."'><br>";
echo "<input type='hidden' name='hidden' value='".$Targetid."'><br>";

}




}

?>
</div>
<div id="navigation">

    <ul>


<li><a href="#ipdprogress1.php">Quarter 1</a></li>
<li><a href="#ipdprogress2.php?">Quarter 2</a></li>
</ul>

</div>
</form>
</body>
</html>

progress2.php

<?php include ('config.php');?>
<?php include('header.php');?>
<div id="container">
<div id="content">
<div id="contentleft">
<?php
error_reporting(E_ALL ^ E_NOTICE);
$_SESSION['Targetid'];
$_SESSION["Progressid"];
$conn = mysql_connect("localhost","pqa","");
mysql_select_db("pq",$conn);

if(count($_POST)>0) {

mysql_query("UPDATE progress set Quanprogress2='" . $_POST["Quanprogress2"] . "', Qualprogress2='" . $_POST["Qualprogress2"] . "',
WHERE Progressid='" . $_SESSION["Progressid"] . "'");
$message = "Record Modified Successfully";

}

$result = mysql_query("SELECT * FROM progress WHERE Progressid='" . $_SESSION["Progressid"] . "'");
$row= mysql_fetch_array($result);
?>
<html>
<head>
<title>Add New User</title>
<link rel="stylesheet" type="text/css" href="styles.css" />
</head>
<body>
<form name="<?php echo $_SERVER['PHP_SELF']?>" method="post" action="">
<div style="width:500px;">
<div class="message"><?php if(isset($message)) { echo $message; } ?></div>
<div align="right" style="padding-bottom:5px;"><a href="list_progress2.php" class="link"><img alt='List' title='List' src='images/list.png' width='15px' height='15px'/> List Progress</a></div>
<p><b>1.Target</b></p>
a.i.Quantitative Progress (e.g. average,numerical,%,sum): <input type="hidden" name="Progressid" class="txtField" value="<?php echo $row['Progressid']; ?>"><input type="text" name="Quanprogress2" class="txtField" value="<?php echo $row['Quanprogress2']; ?>"><br>
a.ii.Qualitative Progress: <input type="text" name="Qualprogress2" class="txtField" value="<?php echo $row['Qualprogress2']; ?>"><br>
</div>
</div>
</div>
</form>
<?php

//}

?>
</body>
</html>
<?php include('ipdfooter.php');?>

Dani AI

Generated

A few likely causes for the header only showing in Quarter 1 are visible in the code you posted: the header is only rendered when $_GET['Targetid'] exists, the nav links use fragment identifiers (the leading #), and header.php contains full HTML markup while the page that includes it also outputs its own <html>/<body>—all of which can prevent the header from appearing consistently. Also the form-processing file has an SQL syntax problem (an extra comma before WHERE) and relies on session variables that may not be set.

Fix plan (practical, easy steps):

  • Put session_start() once at the very top of every page (before any output). Don’t rely on includes starting the session after HTML has already been sent.
  • Turn header.php into a header fragment only (no DOCTYPE, <html>, <head> or <body>). Let each page supply the surrounding HTML. That avoids duplicate tags and makes includes predictable.
  • Make the header logic accept a Targetid from session as well as GET. Example flow: if $_GET['Targetid'] set, assign it to $_SESSION['Targetid']; otherwise use the session value. That ensures the header can render when users navigate between pages.
  • Fix navigation links so they are real page URLs (for example, ipdprogress2.php?Targetid=123) instead of # fragments—fragments do not load a different PHP page.
  • In progress2.php ensure $_SESSION['Progressid'] is set before using it, and remove the stray comma in the UPDATE statement. Enable error reporting or echo mysql_error() during development to see SQL errors. For security and future-proofing, move off the deprecated mysql_* extension and use mysqli or PDO with prepared statements.

Quick debug checklist:

  • View page source to confirm header HTML is being output.
  • var_dump($_SESSION) to verify session values.
  • Click the Quarter 2 link and watch the URL (does it include Targetid?).
  • Turn on display errors to catch SQL syntax issues.

These steps address the specific problems in the snippets you posted and will make the header show consistently across both quarters. —

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.