Jump to content

Recommended Posts

Hi

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

<?php
 require "header.php";
?>

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

  <div class="wrapper-main">

        <div class="welcomelogged1">
          <p>Searching For A Starter<p>                  
        </div>
        <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>
			</select>
			<input type="submit" name="Search" value="Search Starters">
        </form>

 <?php

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

mysqli_report(MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT);


$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">
				<table>
					<Tr><td><label></label></td>
						<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><label>Action</label></td>						
					</Tr>
					<tr>
				<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>
			</tr>
			</form>
		<?php
	}

			}

 

I have attached a picture to show what i mean

 

 example.jpg.1ede5cbd26c13cbef575443a848968fb.jpg

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/311383-table-fetch-data-help/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

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

Guest
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.