rendered paste body<?php
if ( !mysql_select_db("ypeceb2m_files", $con) )
{
die( "unable to select database" );
}
$searchtext = ( isset( $_POST['search'] ) ) ? $_POST['search'] : NULL;
if ( !empty( $searchtext ) )
{
$searchtext_temp = explode( ',', $searchtext );
$query_where = NULL;
foreach( $searchtext_temp as $searchtext_temp_tag )
{
if ( !empty( $query_where ) )
{
$query_where .= ' OR ';
}
$query_where .= "tags.tag = '". mysql_real_escape_string( $searchtext_temp_tag ) ."'";
}
$query = "SELECT * FROM files,tags where tags.id = files.id AND ( $query_where )";
if ( !$result = mysql_query( $query, $con ) )
{
die( 'Unable to run query: '. mysql_error() );
}
while ( $row = mysql_fetch_assoc( $result ) )
{
echo "Name: {$row['name']} <br />";
echo "Description: {$row['description']} <br />";
echo "Location: <a href='{$row['location']}'>{$row['location']}</a> <br /> ";
echo "Tags: ";
if ( !empty( $row['tag'] ) )
{
$tags = explode(',', $row['tag']);
@foreach($tags as $b)
{
echo "<a href = 'tag.php?tag=$b'>$b</a> ";
}
}
echo "<br />";
echo "Uploaded by: {$row['author']}";
echo "<br /> <br />";
}
mysql_free_result( $result );
}
else
{
echo "You must enter tags";
}
?>