phil drury
08-24-2005, 10:44 AM
Hi nice forum, right i have a problem im fairly new to mysql. I have built a searchable DB and i can display it in PHP the problem is the data it displays is only the shortened info. I need to add a link to display the rest of the row. For the life of me i cant work out / find out how to do it.
The link needs to know what row its on then display the row on a new page/pop up/ div tag.
i have a PRIMARY INDEX OF column Ref, The searchable fields are in a FULLTEXT index.
one more question! - How do you insert blocks of HTML into php or in an echo statement stop php from parseing punctuation?
Any help would be.................
Cheers Philo
function searchForm()
{
// Re-usable form
// variable setup for the form.
$searchwords = (isset($_GET['words']) ? htmlspecialchars(stripslashes($_REQUEST['words'])) : '');
$normal = (($_GET['mode'] == 'normal') ? ' selected="selected"' : '' );
$boolean = (($_GET['mode'] == 'boolean') ? ' selected="selected"' : '' );
echo '<form method="get" action="'.$_SERVER['PHP_SELF'].'">';
echo '<input type="hidden" name="cmd" value="search" />';
echo 'Search for: <input type="text" name="words" value="'.$searchwords.'" /> ';
echo 'Mode: ';
echo '<select name="mode">';
echo '<option value="normal"'.$normal.'>Normal</option>';
echo '<option value="boolean"'.$boolean.'>Boolean</option>';
echo '</select> ';
echo '<input type="submit" value="Search" />';
echo '</form>';
}
// Create the navigation switch
$cmd = (isset($_GET['cmd']) ? $_GET['cmd'] : '');
switch($cmd)
{
default:
echo '<h1>Ice Promotions</h1>';
searchForm();
break;
case "search":
searchForm();
echo '<h3>Search Results:</h3><br />';
$searchstring = mysql_escape_string($_GET['words']);
switch($_GET['mode'])
{
case "normal":
$sql = "SELECT TownCity, CountyState, HotelName, WebsitePhotoPermission, GeneralDescription,
MATCH(TownCity, HotelName, CountyState, WebsitePhotoPermission, GeneralDescription)
AGAINST ('$searchstring') AS score FROM icepro
WHERE MATCH(HotelName, CountyState, TownCity, WebsitePhotoPermission, GeneralDescription)
AGAINST ('$searchstring') ORDER BY score DESC";
break;
case "boolean":
$sql = "SELECT TownCity, CountyState, HotelName, WebsitePhotoPermission, GeneralDescription,
MATCH(TownCity, HotelName, CountyState, WebsitePhotoPermission, GeneralDescription)
AGAINST ('$searchstring') AS score FROM icepro
WHERE MATCH(HotelName, CountyState, TownCity, WebsitePhotoPermission, GeneralDescription, )
AGAINST ('$searchstring') ORDER BY score DESC";
break;
}
$sql2 = $query = "SELECT * FROM icepro ";
// echo $sql;
$result = mysql_query($sql) or die (mysql_error());
$result2 = mysql_query($sql2) or die (mysql_error());
while($row = mysql_fetch_object($result))
{
echo '<div id="display"> <img src="'.stripslashes(htmlspecialchars($row->WebsitePhotoPermission)).'"> <strong> '.stripslashes(htmlspecialchars($row->HotelName)).'</strong><br /><br />';
echo '<strong> Town: </strong>'.stripslashes(htmlspecialchars($row->TownCity)).'<br />';
echo '<strong> Description: </strong>'.stripslashes(htmlspecialchars($row->GeneralDescription)).'<br />';
echo '<strong> Post Code: </strong>'.stripslashes(htmlspecialchars($row->Postcode)).'<br />';
echo '<strong> County: </strong>'.stripslashes(htmlspecialchars($row->CountyState)).'<br />';
// echo include ('display1.php');
echo '<form name="form1" method="GET" action="">';
echo '<input name="press" value="more..." type="button">';
echo '</form>';
echo '</div>';
}
break;
}
?>
</body>
The link needs to know what row its on then display the row on a new page/pop up/ div tag.
i have a PRIMARY INDEX OF column Ref, The searchable fields are in a FULLTEXT index.
one more question! - How do you insert blocks of HTML into php or in an echo statement stop php from parseing punctuation?
Any help would be.................
Cheers Philo
function searchForm()
{
// Re-usable form
// variable setup for the form.
$searchwords = (isset($_GET['words']) ? htmlspecialchars(stripslashes($_REQUEST['words'])) : '');
$normal = (($_GET['mode'] == 'normal') ? ' selected="selected"' : '' );
$boolean = (($_GET['mode'] == 'boolean') ? ' selected="selected"' : '' );
echo '<form method="get" action="'.$_SERVER['PHP_SELF'].'">';
echo '<input type="hidden" name="cmd" value="search" />';
echo 'Search for: <input type="text" name="words" value="'.$searchwords.'" /> ';
echo 'Mode: ';
echo '<select name="mode">';
echo '<option value="normal"'.$normal.'>Normal</option>';
echo '<option value="boolean"'.$boolean.'>Boolean</option>';
echo '</select> ';
echo '<input type="submit" value="Search" />';
echo '</form>';
}
// Create the navigation switch
$cmd = (isset($_GET['cmd']) ? $_GET['cmd'] : '');
switch($cmd)
{
default:
echo '<h1>Ice Promotions</h1>';
searchForm();
break;
case "search":
searchForm();
echo '<h3>Search Results:</h3><br />';
$searchstring = mysql_escape_string($_GET['words']);
switch($_GET['mode'])
{
case "normal":
$sql = "SELECT TownCity, CountyState, HotelName, WebsitePhotoPermission, GeneralDescription,
MATCH(TownCity, HotelName, CountyState, WebsitePhotoPermission, GeneralDescription)
AGAINST ('$searchstring') AS score FROM icepro
WHERE MATCH(HotelName, CountyState, TownCity, WebsitePhotoPermission, GeneralDescription)
AGAINST ('$searchstring') ORDER BY score DESC";
break;
case "boolean":
$sql = "SELECT TownCity, CountyState, HotelName, WebsitePhotoPermission, GeneralDescription,
MATCH(TownCity, HotelName, CountyState, WebsitePhotoPermission, GeneralDescription)
AGAINST ('$searchstring') AS score FROM icepro
WHERE MATCH(HotelName, CountyState, TownCity, WebsitePhotoPermission, GeneralDescription, )
AGAINST ('$searchstring') ORDER BY score DESC";
break;
}
$sql2 = $query = "SELECT * FROM icepro ";
// echo $sql;
$result = mysql_query($sql) or die (mysql_error());
$result2 = mysql_query($sql2) or die (mysql_error());
while($row = mysql_fetch_object($result))
{
echo '<div id="display"> <img src="'.stripslashes(htmlspecialchars($row->WebsitePhotoPermission)).'"> <strong> '.stripslashes(htmlspecialchars($row->HotelName)).'</strong><br /><br />';
echo '<strong> Town: </strong>'.stripslashes(htmlspecialchars($row->TownCity)).'<br />';
echo '<strong> Description: </strong>'.stripslashes(htmlspecialchars($row->GeneralDescription)).'<br />';
echo '<strong> Post Code: </strong>'.stripslashes(htmlspecialchars($row->Postcode)).'<br />';
echo '<strong> County: </strong>'.stripslashes(htmlspecialchars($row->CountyState)).'<br />';
// echo include ('display1.php');
echo '<form name="form1" method="GET" action="">';
echo '<input name="press" value="more..." type="button">';
echo '</form>';
echo '</div>';
}
break;
}
?>
</body>