PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Thu Dec 14, 2017 8:07 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Results page
PostPosted: Mon Jan 16, 2012 5:22 am 
Offline
Forum Newbie

Joined: Mon Nov 14, 2011 7:08 am
Posts: 19
Hi,

I have a results page and i am now trying to output a linked image with a non-linked product title.

However my i am currently outputting all of the product titles then all of the product images.

Thanks,

Rob.

Here my code....

<?php

$hello = "";

if (isset($_COOKIE['lang'])) {
$stu = $_COOKIE['lang'];
} else {
$stu = "EN";
}
//echo $stu;

error_reporting(E_ALL);
ini_set('display_errors', '1');
$search_output = "";
if (isset($_POST['searchquery']))
{
$suffix = "";
$searchquery = preg_replace('#[^a-z 0-9?!]#i', '', $_POST['searchquery']);

$flow_rate_min = $_POST['flow_rate_min'];
$flow_rate_max = $_POST['flow_rate_max'];
$application = $_POST['application'];
$pipe_size = $_POST['pipe_size'];
$op_pressure = $_POST['op_pressure'];

$flow_search = false;
if ($flow_rate_min != "" && $flow_rate_max != "") $flow_search = true;

$flow_search_sql = "conditioners.flow_rate_min >=" . $flow_rate_min . " AND conditioners.flow_rate_max <= " . $flow_rate_max;

$text_search_sql = "(title$stu LIKE '%$searchquery%' OR body LIKE '%$searchquery%')";

$con_application_sql = "application$stu LIKE '%$application%'";

$con_op_pressure_sql = "op_pressure LIKE '%$op_pressure%'";

$con_pipe_size_sql = "pipe_size LIKE '%$pipe_size%'";

// remember to add $language on the end of each field which requires it.

$sqlCommand = "SELECT id, title$stu as title, application$stu, pipe_size, flow_rate_min, flow_rate_max, op_pressure, moc$stu, dimensions, weight, approvals$stu, supplied$stu, body, picture, link FROM conditioners";

$first_condition_added = false;

if ($flow_search != "")
{
$sqlCommand .= " WHERE ";
$sqlCommand .= $flow_search_sql;
$first_condition_added = true;
}

if ($searchquery != "")
{
if ($first_condition_added == false) $sqlCommand .= " WHERE ";
else
$sqlCommand .= " AND ";
$sqlCommand .= $text_search_sql;
$first_condition_added = true;
}

if ($application != "")
{
if ($first_condition_added == false) $sqlCommand .= " WHERE ";
else
$sqlCommand .= " AND ";
$sqlCommand .= $con_application_sql;
$first_condition_added = true;
}

if ($op_pressure != "")
{
if ($first_condition_added == false) $sqlCommand .= " WHERE ";
else
$sqlCommand .= " AND ";
$sqlCommand .= $con_op_pressure;
$first_condition_added = true;
}

if ($pipe_size != "")
{
if ($first_condition_added == false) $sqlCommand .= " WHERE ";
else
$sqlCommand .= " AND ";
$sqlCommand .= $con_pipe_size_sql;
$first_condition_added = true;
}

//echo $sqlCommand;

include_once("connect_to_mysql.php");
$query = mysql_query($sqlCommand) or die(mysql_error());
$count = mysql_num_rows($query);
if ($count < 2)
while ($row = mysql_fetch_array($query))
{
$url = "?q=node/{$row['link']}";
header( "Location: $url" );
}
if ($count > 1)
{
while ($row = mysql_fetch_array($query))
{
// $id = $row["nid"];
// $title = $row["title"];
// $search_output .= "$id - $title";

$search_output .= "<a href=\"?q=node/{$row['link']}\"><img class='toptrumps2' src='images/"."L".$row['picture'].".jpg'" . "</a>\n";
$hello .= '<div class="multiple_results">' . $row['title'] . '</div>';
} // close while
}
else
{
echo $no_output = "<hr />0 results for <strong>$searchquery</strong><hr />";
}
}

?>
<html>
<head>
</head>
<body>
<form action="http://www.bertgroup.co.uk/?q=node/114" method="post">
Search products:
<input class="product_search_boxes_1" name="searchquery" class="product_search_boxes" type="text" size="44" maxlength="88">

<br/>
Flow rate between :
<input class="product_search_boxes_2" name="flow_rate_min" type="text" size="5" maxlength="5">
<class id="and_text_product_search">and</class>
<input class="product_search_boxes_3" name="flow_rate_max" class="product_search_boxes" type="text" size="5" maxlength="5">
<br/>
Application :
<input class="product_search_boxes_4" name="application" class="product_search_boxes" type="text" size="20" maxlength="20">
<br/>
Pipe size :
<input class="product_search_boxes_5" name="pipe_size" class="product_search_boxes" type="text" size="20" maxlength="20">
<br/>
Operating pressure :
<input class="product_search_boxes_6" name="op_pressure" class="product_search_boxes" type="text" size="20" maxlength="20">
<br/>
<input name="myBtn" type="submit">
</form>
</br></br>
<?php
echo '<div class="multiple_results">';
echo $hello . " <br/> ";
echo $search_output . " <br/> ";
echo'</div>';
?>
<br/><br/>
</div>
</body>
</html>


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: Google [Bot], JSubira and 25 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group