psychowolvesbane Posted February 21, 2008 Share Posted February 21, 2008 I have a search page which takes in 2 types of searches, Categories (list of product categories) and Criteria (input from a search bar), at the moment all the page does is show a blank screen so I must be missing an important php/html character somewhere, but i'm tried searching for it using Dreamweaver CS3 and it's useful colour coded formatting but I still can't see anything wrong with it. <?php $Category = $_GET['Category']; $Criterion = $_GET['Criterion']; ?> <html> <head> <title>Clothing Line</title> <link href="admin/stylesheetCL.css" rel="stylesheet"> <?php require('admin/jscript.inc') ?> </head> <body> <?php //require('admin/header.inc'); include "admin/connect_details.php"; require('menu.inc'); //require('search_results.inc');?> <div style="position:absolute; top:5px; left:200px; width:550px"> <?php echo $Category." is Category<br>"; echo $Criterion." is Criterion<br>"; If ($Category != "") { $conn = mysql_connect($Host,$Username,$Password) or die(mysql_error()); $db = mysql_select_db($Dbname, $conn); $sql = "SELECT ClothingCode,Description,Price FROM Clothing WHERE ItemType = '$Category' ORDER BY ClothingCode"; $rs = mysql_query($sql, $conn) or die('Problem with query: ' . $sql . '<br />' . mysql_error()); $Results1 = mysql_num_rows($rs); echo"<span class='errmsg'>There were $Results1 search results for $Category</span>"; echo $Results1." is Category results"; echo"<span class='head3'>Search results for category: $Category</span><br><br>"; ?> <table border="0" cellpadding="3"><tr> <th>Clothing Code</th> <th>Description</th> <th>Price</th></tr> <?php while($row = mysql_fetch_array($rs)) { $ClothingCode = $row['ClothingCode']; $Description = $row['Description']; $Price = number_format($row['Price'],2); echo "<tr style=\"color:seagreen; line-height:8pt\" onMouseOver=\"this.style.backgroundColor='lightgreen';this.style.color='darkgreen'; this.style.cursor='hand'\"onMouseOut=\"this.style.backgroundColor='white';this.style.color='seagreen'\" onClick=\"location.href='details.php?&ClothingCode=$row['ClothingCode']\".\"&Category=$Category'\"> <td>$ClothingCode</td><td>$Description</td><td align='right'>£$Price</td></tr>"; } mysql_close($conn); ?> </table> <?php } elseif ($Criterion != "") { $conn = mysql_connect($Host,$Username,$Password) or die(mysql_error()); $db = mysql_select_db($Dbname, $conn); $sql = "SELECT ClothingCode,Description,Price FROM Clothing WHERE"; $sql = $sql . " ClothingCode LIKE '%" . $Criterion . "%'"; $sql = $sql . " OR Description LIKE '%" . $Criterion . "%'"; $sql = $sql . " OR ItemType LIKE '%" . $Criterion . "%'"; $sql = $sql . " OR AvailableSizes LIKE '%" . $Criterion . "%'"; $sql = $sql . " OR AvailableColours LIKE '%" . $Criterion . "%'"; $sql = $sql . " ORDER BY ClothingCode"; $rs = mysql_query($sql,$conn) or die('Problem with query: ' . $sql . '<br />' . mysql_error()); $Results2 = mysql_num_rows($rs); echo $Results2." is Criterion results"; echo"<span class='errmsg'>There were $Results2 search results for $Criterion</span>"; echo"<span class='head3'>Search results for Clothing Code: $Criterion</span><br><br>"; ?> <table border="0" cellpadding="3"><tr> <th>Clothing Code</th><th>Description</th><th>Price</th></tr> <?php while($row = mysql_fetch_array($rs)) { $ClothingCode = $row['ClothingCode']; $Description = $row['Description']; $Price = $row['Price']; echo "<tr style=\"color:seagreen; line-height:8pt\"onMouseOver=\"this.style.backgroundColor='lightgreen'; this.style.color='darkgreen';this.style.cursor='hand'\"onMouseOut=\"this.style.backgroundColor='white'; this.style.color='seagreen'\"onClick=\"location.href='details.php?ClothingCode=$ClothingCode'\". \"&Criterion=$Criterion'\"> <td>$ClothingCode</td> <td>$Description</td> <td align=\"right\">£$Price</td> </tr>"; } mysql_close($conn); ?> </table> <?php } ?> </div> </body> </html> Link to comment https://forums.phpfreaks.com/topic/92270-search-page-problem/ Share on other sites More sharing options...
aebstract Posted February 21, 2008 Share Posted February 21, 2008 <?php require('admin/jscript.inc') ?> needs the ; ? <?php require('admin/jscript.inc'); ?> Link to comment https://forums.phpfreaks.com/topic/92270-search-page-problem/#findComment-472713 Share on other sites More sharing options...
psychowolvesbane Posted February 21, 2008 Author Share Posted February 21, 2008 Nope that wasn't it, I noticed thanks to the slightly better colour coded formatting from this site that the while loop from the Category search wasn't closing properly, so I just copied the Criterion while loop and made the necessary changes and it now works! I noticed that the closing bracket for the while loop was blue instead of green, but on Dream Weaver it doesn't have a colour formatting for brackets. Link to comment https://forums.phpfreaks.com/topic/92270-search-page-problem/#findComment-472722 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.