Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

NEED HELP WITH PHP SEARCH

Status
Not open for further replies.

dadms

Technical User
Joined
Mar 8, 2003
Messages
67
Location
US
I will try to explain this the best I can....
My search form asks to return certain fields from the MySQL database and that works fine, all the record & fields come back. Fields are AUTHOR DATE CATEGORY TITLE INFORMATION

However in the results the INFORMATION field can be extremely long and take up a few pages per record. I would like my results to return AUTHOR DATE CATEGORY TITLE of all matching records and if the user determines that they would like to see a certain record they could click on a field to return the INFORMATION field. (even if I have to redirect them to another page). ANY SUGGESTIONS???
Check it out yourself:
Go to and enter MATT in the text box and you can see how much text is actually returned for each record.

PHP CODE
<HTML>
<HEAD>
<meta HTTP-EQUIV=&quot;Content-Type&quot; CONTENT=&quot;text/html; charset=windows-1252&quot;>
<meta http-equiv=&quot;Content-Language&quot; content=&quot;en-us&quot;>
<TITLE>INPUT FORM</TITLE>
</HEAD>
<BODY>
<center>
<table border=&quot;1&quot; cellpadding=&quot;5&quot; cellspacing=&quot;0&quot; bordercolor=&quot;#000000&quot;>
<tr>
<td width=&quot;60&quot;><b>AUTHOR</b></td>
<td width=&quot;100&quot;><b>DATE</b></td>
<td width=&quot;70&quot;><b>CATEGORY</b></td>
<td width=&quot;150&quot;><b>TITLE</b></td>
<td width=&quot;150&quot;><b>INFORMATION</b></td>
</tr>
<tr>
<td>

<?php

$dbh=mysql_connect (&quot;localhost&quot;, &quot;USER&quot;, &quot;PASSWORD&quot;) or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db (&quot;panao3_tierii&quot;);
?>

<?php
//error message (not found message)begins
$XX = &quot;No Record Found, to search again please close this window&quot;;
//query details table begins
$query = mysql_query(&quot;SELECT * FROM sbmtdfrms WHERE $metode LIKE '%$search%' LIMIT 0, 50&quot;);
while ($row = @mysql_fetch_array($query))
{
$variable1=$row[&quot;name&quot;];
$variable2=$row[&quot;date&quot;];
$variable3=$row[&quot;category&quot;];
$variable4=$row[&quot;title&quot;];
$variable5=$row[&quot;information&quot;];
//table layout for results

print (&quot;<tr>&quot;);
print (&quot;<td valign='top'>$variable1</td>&quot;);
print (&quot;<td valign='top'><pre>$variable2<pre></td>&quot;);
print (&quot;<td valign='top'>$variable3</td>&quot;);
print (&quot;<td valign='top'>$variable4</td>&quot;);
print (&quot;<td valign='top'><pre>$variable5</pre></td>&quot;);

print (&quot;</tr>&quot;);
}
//below this is the function for no record!!
if (!$variable1)
{
print (&quot;$XX&quot;);
}
//end
?>
</table>
</center>
</body>
 
Hope I've got the drift here..

Take the first (say) 50 bytes of the long field and display this as a link e.g.

<td><a href=&quot;newpage.php?id=1&quot;>first 50 bytes</a></td>

Which will display the first 50 bytes as a link, you may find that 50 bytes is enough anyway.

alternativy you coould use JavaScript to pop up a new window with the href as the parameter.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top