Jump to content

Setting up a "middle" page


mikebyrne

Recommended Posts

At present I have a search facility that displays the results on a page called searchresults.php

 

login.php

<label for="searchfield" class="t10nw"></label><br /><br /><br /><br /><br /><br />
<form name="ex2" method="post" action="searchresults.php">

<select name="cat" onChange="setAction(this.options[this.selectedIndex].value);"> 
<option value="CD" selected="selected" >CDs</option>
<option value="DVD" >DVDs</option>
<option value="Game" >Games</option>
</select>



<input type="text" name="searchfield" size="22" maxlength="40" id="srchdrop" />
<input type="submit" name="searchme" value="Search Now! »" id="gosrch" />

</td></tr>
</form>

 

searchresults.php

<?PHP

if (isset($_POST['searchme'])) {

include("adminconnect.php");

$tbl_name = "product";

$cat = mysql_real_escape_string($_POST['cat']);
$input =mysql_real_escape_string($_POST['searchfield']);

$query = "SELECT * FROM product WHERE Producttype = '$cat' AND Productname LIKE '%$input%'";

$result = mysql_query($query) or die ("error in the query" . mysql_error()); if (mysql_num_rows($result) > 0) { while($row = mysql_fetch_array($result)) { echo "Title ".$row['ProductName']."\n<br> <img src=\"".$row['Image']."\"></img>\n<br>
Amount in stock ".$row['Stockamount']."\n<br> Price ".$row['Price']."\n<br>
Description: ".$row['Description']."\n<br>";
     }
} else {
    echo "No search results found";
}
} else {
    echo "No search terms entered.";
}

?>

 

Would it be possible to display only the resulting names and have links from these name that will display every detail like searchresults.php currently does.

 

The primary key in my table is ProductNo

 

An example of what I mean can be seen here:

 

http://www.cdwow.ie/searchresults_cd.php?searchfield=duffy

 

 

Link to comment
https://forums.phpfreaks.com/topic/99434-setting-up-a-middle-page/
Share on other sites

The output I want to use should look like this but I dont know how to apply it to my varibles

 

<tr class="alternate" id="pc1035249">
    <td>
        <div class="quickview" onclick="new QuickView(10, 1035249, this);" title="Open product details"></div>
        <div class="prodimage" style="display:none;">
            <a href="/detail_results_10.php?product_code=1035249"><img src="http://images-cache.cd-wow.com/images/../EUK/CD/awaiting75.jpg" alt="Music From Midnight Mass (Duffy, Liverpool Met. Brass Ens.)" /></a>  
        </div>
        <a href="/detail_results_10.php?product_code=1035249" class="t11bb">VARIOUS COMPOSERS</a>

            </td>
    <td>
        <a href="/detail_results_10.php?product_code=1035249" class="t11ns">Music From Midnight Mass (Duffy, Liverpool Met. Brass Ens.)</a>
    </td>
    <td>
        <a href="/detail_results_10.php?product_code=1035249" class="t11br">EUR 14.94</a>
    </td>
    <td>

        <img src="http://images-cache.cd-wow.com/images/testdev/cdw_tdev_atc_v1_red.gif" class="cartimg" border="0" title="VARIOUS COMPOSERS - Music From Midnight Mass (Duffy, Liverpool Met. Brass Ens.) - Add to cart!" alt="VARIOUS COMPOSERS - Music From Midnight Mass (Duffy, Liverpool Met. Brass Ens.) - Add to cart!" height="16" width="60" onclick="window.open('product_warning.php?product_code=10:1035249&PAGE_REFERRER=%2Fsearchresults_cd.php%3FPHPSESSID%3D2c1671dd717974e685d46218c8fa862f%26searchfield%3Dduffy', '_blank','location=no,menubar=no,resizable=yes,scrollbars=no,toolbar=no,titlebar=no,width=360,height=520')" onmouseover="style.cursor='pointer';window.status='/?product_code=product_warning.php&PAGE_REFERRER=%2Fsearchresults_cd.php%3FPHPSESSID%3D2c1671dd717974e685d46218c8fa862f%26searchfield%3Dduffy'" onmouseout="window.status=''" />    </td>
</tr>

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.