Jump to content

[SOLVED] Display only single record set title on page


yandoo

Recommended Posts

Hi,

 

I have created a recordset where records are displayed on a page. The records are displayed across the screen like so:

 

 

Loan ID Client Name Student Name  Laptop Name Username Date Complete Description

123  Mrs Conway D Stevenson STULAP01 twanstall 2007-01-24 Y 

 

Loan ID Client Name Student Name  Laptop Name Username Date Complete Description

124  Mrs Conway J Farkins STULAP02 twanstall 2007-01-24 Y 

 

Thing is i only need the record titles to be displayed ONCE at the top of the page as they will just be repeated on each record.

 

How do i make this work???

 

Here is the code i have for it:

 


echo"<table width=\"700\" border=\"1\" class=\"border_bottom\"> \n";
		echo "<tr> \n";

		echo "<td width=\"100\">";
		echo "<strong>Loan ID</strong>"; 
		echo "</td>";
		echo "<td>";
		echo "<strong>Client Name</strong>";
		echo "</td>";
		echo "<td>";
		echo "<strong>Student Name </strong>";
		echo "</td>";
		echo "<td>";
		echo "<strong>Laptop Name</strong>";
		echo "</td>";
		echo "<td>";
		echo "<strong>Username</strong>";
		echo "</td>";
		echo "<td>";
		echo "<strong>Date</strong>";
		echo "</td>";
		echo "<td>";
		echo "<strong>Complete</strong>";
		echo "</td>";
		echo "<td>";
		echo "<strong>Description</strong>";
		echo "</td>";


		echo "<tr>";
		echo "<td width=\"75\" style =\"text-align: left\""; ?> <em><a href="search_loan_details.php?recordID=<?php echo $result['LoanID']; ?>"><?php 
		echo $result['LoanID']; ?> </a></em> <?php 
		echo " </td>";


		echo "<td>";
		echo "<em>";
		echo $result['Client'];
		echo "</em>";
		echo "</td>";




		echo "<td>";
		echo "<em>";
		echo $result['StudentName'];
		echo "</em>";
		echo "</td>";




		echo "<td>";
		echo "<em>";
		echo $result['LaptopName'];
		echo "</em>";
		echo "</td>";




		echo "<td>";
		echo "<em>";
		echo $result['Username'];
		echo "</em>";
		echo "</td>";




		echo "<td>";
		echo "<em>";
		echo $result['Date'];
		echo "</em>";
		echo "</td>";




		echo "<td>";
		echo "<em>";
		echo $result['Complete'];
		echo "</em>";
		echo "</td>";




		echo "<td>";
		echo "<em>";
		echo $result['Description'];
		echo "</em>";
		echo "</td>";


		echo "<tr> \n";
		echo "<td> </td> \n";
		echo "</td> \n";
		echo "</tr> \n";
		echo "</table> \n";
		echo"<br>";
	}
} else echo 'no result';

 

 

 

Any help be brilliant, thank you :)

 

Hi. Sorry but I think I cant really tell you what is the problem until you post what is $result.

 

Is it an array or a reslut of mysql query?

 

And anyways this should be the template for your thing:

 

<table>

<tr><td>PUT HERE YOUR TITLES</td></tr>

<?

to read an array or whatever $result is you need to create a loop like so:

 

while(){

echo "<tr></td>INFO YOU WANT TO DISPLAY</td></tr>

}

?>

 

</table>

Missed out bit of code...oooops

 

These 2 lines of code are above the exisitng code:

 

if (mysql_num_rows($res) > 0) {

while($result = mysql_fetch_array($res)) {

 

thanks

 

 

The $result is an array of tables that are used to search for a record that the inputs and is diaplayed on this page....

 

thanks :)

Heres what ive done so far as i managed to get onloy single title of record on page any other records apart from the first dont go in line underneath, they like eery where all round the page....

 

How do i make it so next table row of records follow previous???

 

heres my code so far:

 



if (mysql_num_rows($res) > 0) {


echo"<table width=\"700\" border=\"1\" class=\"border_bottom\"> \n";
		echo "<tr> \n";

		echo "<td>";
		echo "<strong>Loan ID</strong>"; 
		echo "</td>";
		echo "<td>";
		echo "<strong>Client Name</strong>";
		echo "</td>";
		echo "<td>";
		echo "<strong>Student Name </strong>";
		echo "</td>";
		echo "<td>";
		echo "<strong>Laptop Name</strong>";
		echo "</td>";
		echo "<td>";
		echo "<strong>Username</strong>";
		echo "</td>";
		echo "<td>";
		echo "<strong>Date</strong>";
		echo "</td>";
		echo "<td>";
		echo "<strong>Complete</strong>";
		echo "</td>";
		echo "</tr>";
	while($result = mysql_fetch_array($res)) {



		echo "<tr>";
		echo "<td width=\"75\" style =\"text-align: left\""; ?> <em><a href="search_loan_details.php?recordID=<?php echo $result['LoanID']; ?>"><?php 
		echo $result['LoanID']; ?> </a></em> <?php 
		echo " </td>";


		echo "<td>";
		echo "<em>";
		echo $result['Client'];
		echo "</em>";
		echo "</td>";




		echo "<td>";
		echo "<em>";
		echo $result['StudentName'];
		echo "</em>";
		echo "</td>";




		echo "<td>";
		echo "<em>";
		echo $result['LaptopName'];
		echo "</em>";
		echo "</td>";




		echo "<td>";
		echo "<em>";
		echo $result['Username'];
		echo "</em>";
		echo "</td>";




		echo "<td>";
		echo "<em>";
		echo $result['Date'];
		echo "</em>";
		echo "</td>";




		echo "<td>";
		echo "<em>";
		echo $result['Complete'];
		echo "</em>";
		echo "</td>";




		echo "</tr> \n";

		echo "</table> \n";
		echo"<br>";
	}
} else echo 'no result';



Well im not entirely sure from your question, but i think the problem is that you close the table inside of your loop. You need to close the table outside of it:

 

<?php
if (mysql_num_rows($res) > 0) {


echo"<table width=\"700\" border=\"1\" class=\"border_bottom\"> \n";
		echo "<tr> \n";

		echo "<td>";
		echo "<strong>Loan ID</strong>"; 
		echo "</td>";
		echo "<td>";
		echo "<strong>Client Name</strong>";
		echo "</td>";
		echo "<td>";
		echo "<strong>Student Name </strong>";
		echo "</td>";
		echo "<td>";
		echo "<strong>Laptop Name</strong>";
		echo "</td>";
		echo "<td>";
		echo "<strong>Username</strong>";
		echo "</td>";
		echo "<td>";
		echo "<strong>Date</strong>";
		echo "</td>";
		echo "<td>";
		echo "<strong>Complete</strong>";
		echo "</td>";
		echo "</tr>";
	while($result = mysql_fetch_array($res)) {



		echo "<tr>";
		echo "<td width=\"75\" style =\"text-align: left\""; ?> <em><a href="search_loan_details.php?recordID=<?php echo $result['LoanID']; ?>"><?php 
		echo $result['LoanID']; ?> </a></em> <?php 
		echo " </td>";


		echo "<td>";
		echo "<em>";
		echo $result['Client'];
		echo "</em>";
		echo "</td>";




		echo "<td>";
		echo "<em>";
		echo $result['StudentName'];
		echo "</em>";
		echo "</td>";




		echo "<td>";
		echo "<em>";
		echo $result['LaptopName'];
		echo "</em>";
		echo "</td>";




		echo "<td>";
		echo "<em>";
		echo $result['Username'];
		echo "</em>";
		echo "</td>";




		echo "<td>";
		echo "<em>";
		echo $result['Date'];
		echo "</em>";
		echo "</td>";




		echo "<td>";
		echo "<em>";
		echo $result['Complete'];
		echo "</em>";
		echo "</td>";
		echo "</tr> \n";


	}
echo "</table> \n";
echo"<br>";
} else echo 'no result';

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.