Jump to content

Table Fetch Data Help

Recommended Posts


I have the following code works well

However, if there is more than one record in the search result it shows the table lables on every record rather than just the one

is it possible to have the table lables for just the result headings and not on each line after

 require "header.php";

	<link href="style.css" rel="stylesheet" type="text/css">

  <div class="wrapper-main">

        <div class="welcomelogged1">
          <p>Searching For A Starter<p>                  
        <form action="" method="post">
        	<select name="WeekComm" id="WeekComm">
			<option value="Enter Week No To Search">Enter Week No To Search</option>
			<option value="WC 6th April">WC 6th April</option>
			<option value="WC 13th April">WC 13th April</option>
			<option value="WC 20th April">WC 20th April</option>
			<input type="submit" name="Search" value="Search Starters">


$dBServername = "localhost";
$dBUsername = "root";
$dBPassword = "";
$dBName = "CandidateManagement";


$conn = mysqli_connect($dBServername, $dBUsername, $dBPassword, $dBName);

if (!$conn) {
    die("Connection failed: " . mysqli_connect_error());

if (isset($_POST['Search'])) 
	$WeekComm = $_POST['WeekComm'];

	$query = "SELECT * FROM contract where WeekComm='$WeekComm' ";
	$query_run = mysqli_query($conn,$query);

	while($row = mysqli_fetch_array($query_run))
			<form action="" method="POST">
						<td><label>Week Commencing</label></td>
						<td><label>First Name</label></td>
						<td><label>Last Name</label></td>
						<td><label>Start Date</label></td>
						<td><label>Client Name</label></td>	
				<td><input type="hidden" name="id" value="<?php echo $row['id'] ?>"></td>
				<td><input type="text" name="WeekComm" value="<?php echo $row['WeekComm'] ?>"></td>
				<td><input type="text" name="FirstName" value="<?php echo $row['FirstName'] ?>"></td>
				<td><input type="text" name="LastName" value="<?php echo $row['LastName'] ?>"></td>
				<td><input type="date" name="StartDate" value="<?php echo $row['StartDate'] ?>"></td>
				<td><input type="text" name="ClientName"value="<?php echo $row['ClientName'] ?>"></td>



I have attached a picture to show what i mean





Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.