Dear All,

I wish to print my records of following code in table format

echo "LOAN NO = &nbsp;$title<br>" ;
echo "NAME = &nbsp;$title1 <br>" ;
echo "ADDRESS = &nbsp;$title2 <br>" ;
echo "AREA OFFICE CODE = &nbsp;$title3 <br>" ;
echo "LINK AO = &nbsp;$title4 <br>" ;
echo "APPLICATION NO. = &nbsp;$title5 <br>" ;
echo "INTREST RATE = &nbsp;$title6 <br>" ;
echo "CURRENT OS = &nbsp;$title7 <br>" ;
echo "FUP = &nbsp;$title8 <br>" ;

I wish the output should come as 1 9*2 table with variable name and values.

Please modify the code for the same

<table border=1>
<tr>
<td>LOAN NO</td>
<td><?php=$title?></td>
</tr>
<tr>
<td>NAME</td>
<td><?php=$title1?></td>
</tr>
<tr>
<td>ADDRESS</td>
<td><?php=$title2?></td>
</tr>
.
.
.
.etc
</table>

it gives Parse error: parse error in C:\wamp\www\search.php on line "<table border=1>"

then post your code...

Don't put the above code in between php tags.

Dear Shanti,

i have a very basic knowledge of PHP . I am still getting the parse error, can u please modify in my existing code.

thanking in advance

======
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Search Result</title>
</head>

<body bgcolor="#C6DF95">

<b>

<?php

// Get the search variable from URL

$var = @$_GET ;
$trimmed = trim($var); //trim whitespace from the stored variable

// rows to return
$limit=10;

// check for an empty string and display a message.
if ($trimmed == "")
{
echo "<p>Please enter a search...</p>";
exit;
}

// check for a search parameter
if (!isset($var))
{
echo "<p>We dont seem to have a search parameter!</p>";
exit;
}

//connect to your database ** EDIT REQUIRED HERE **
mysql_connect("localhost","root","admin123"); //(host, username, password)

//specify database ** EDIT REQUIRED HERE **
mysql_select_db("mis") or die("Unable to select database"); //select which database we're using

$field = 'lnno';
// Build SQL Query
$query = "select * from loandata where $field = $trimmed
order by $field"; // EDIT HERE and specify your table and field names for the SQL query

$numresults=mysql_query($query);
$numrows=mysql_num_rows($numresults);

// If we have no results,

if ($numrows == 0)
{

echo "<p>Sorry, your search: &quot;" . $trimmed . "&quot; returned zero results</p>";
exit;

}

// next determine if s has been passed to script, if not use 0
if (empty($s)) {
$s=0;
}

// get results
$query .= " limit $s,$limit";
$result = mysql_query($query) or die("Couldn't execute query");

// display what the person searched for
echo "<p>You searched for LOAN NO: &quot;" . $var . "&quot;</p>";

// begin to show results set
echo "<h3>Results</h3>";
$count = 1 + $s ;

// now you can display the results returned
while ($row= mysql_fetch_array($result)) {
$title = $row["$field"];
$title1 = $row["mname"];
$title2 = $row["address"];
$title3 = $row["area_off"];
$title4 = $row["link_ao"];
$title5 = $row["appl_No"];
$title6 = $row["int_rate"];
$title7 = $row["curr_os"];
$title8 = $row["fup"];
$title9 = $row["area_name"];


echo "LOAN NO = &nbsp;$title <br>" ;
echo "NAME = &nbsp;$title1 <br>" ;
echo "ADDRESS = &nbsp;$title2 <br>" ;
echo "AREA OFFICE CODE = &nbsp;$title3 <br>" ;
echo "LINK AO = &nbsp;$title4 <br>" ;
echo "APPLICATION NO. = &nbsp;$title5 <br>" ;
echo "INTREST RATE = &nbsp;$title6 <br>" ;
echo "CURRENT OS = &nbsp;$title7 <br>" ;
echo "FUP = &nbsp;$title8 <br>" ;
echo "AREA OFFICE NAME = &nbsp;$title9 <br>" ;

$count++ ;
}

$currPage = (($s/$limit) + 1);

//break before paging
echo "<br />";


?>


</b>

</body>

</html>

i checked your code it is perfectly running..
Please post your error and code line numbers.

I need to print the following output in table format.Kindly modify this existin code for the same.


--

echo "LOAN NO = &nbsp;$title <br>" ;
echo "NAME = &nbsp;$title1 <br>" ;
echo "ADDRESS = &nbsp;$title2 <br>" ;
echo "AREA OFFICE CODE = &nbsp;$title3 <br>" ;
echo "LINK AO = &nbsp;$title4 <br>" ;
echo "APPLICATION NO. = &nbsp;$title5 <br>" ;
echo "INTREST RATE = &nbsp;$title6 <br>" ;
echo "CURRENT OS = &nbsp;$title7 <br>" ;
echo "FUP = &nbsp;$title8 <br>" ;
echo "AREA OFFICE NAME = &nbsp;$title9 <br>" ;


----

check this code:

echo "<table border=5 cellpadding=2 cellspacing=1>";
// now you can display the results returned
while ($row= mysql_fetch_array($result)) {
$title = $row["$field"];
$title1 = $row["mname"];
$title2 = $row["address"];
$title3 = $row["area_off"];
$title4 = $row["link_ao"];
$title5 = $row["appl_No"];
$title6 = $row["int_rate"];
$title7 = $row["curr_os"];
$title8 = $row["fup"];
$title9 = $row["area_name"];

echo "<tr><td>";
echo "LOAN NO </td><td> &nbsp;$title <br>" ;
echo "</tr></td>";
echo "<tr><td>";
echo "NAME </td><td> &nbsp;$title1 <br>" ;
echo "</tr></td>";
echo "<tr><td>";
echo "ADDRESS </td><td> &nbsp;$title2 <br>" ;
echo "</tr></td>";
echo "<tr><td>";
echo "AREA OFFICE CODE </td><td> &nbsp;$title3 <br>" ;
echo "</tr></td>";
echo "<tr><td>";
echo "LINK AO </td><td> &nbsp;$title4 <br>" ;
echo "</tr></td>";
echo "<tr><td>";
echo "APPLICATION NO. </td><td> &nbsp;$title5 <br>" ;
echo "</tr></td>";
echo "<tr><td>";
echo "INTREST RATE </td><td> &nbsp;$title6 <br>" ;
echo "</tr></td>";
echo "<tr><td>";
echo "CURRENT OS </td><td> &nbsp;$title7 <br>" ;
echo "</tr></td>";
echo "<tr><td>";
echo "FUP </td><td> &nbsp;$title8 <br>" ;
echo "</tr></td>";
echo "<tr><td>";
echo "AREA OFFICE NAME </td><td> &nbsp;$title9 <br>" ;

$count++ ;
}
echo "</table>";

thank you very much .... it worked perfectly !!!!!!!!!!!!

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.