Jump to content

bigkev1983

Members
  • Posts

    13
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

bigkev1983's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. You beauties! Thanks guys - you're heroes! Kev
  2. Thanks - I must confess I tried using that PHP script but couldn't get it to work with my data. OK, so now I have two examples. The first is: http://88.208.206.63/riseoverseas/search-repeater.php?country=1 In this example, as you can see the region repeats correctly but with the same data for each one (code below - I left the select query at the top as well just in case that has something to do with it). <?php $searchquery = "SELECT * FROM `property` WHERE `country` = ".$_GET['country']; $searchresult = mysql_query($searchquery); while($searchrow = mysql_fetch_array($searchresult)) { ?> <table > <tr> <?php $searchresult_endRow = 0; $searchresult_columns = 3; // number of columns $searchresult_hloopRow1 = 0; // first row flag do { if($searchresult_endRow == 0 && $searchresult_hloopRow1++ != 0) echo "<tr>"; ?> <td> <table class="dsR23" border="0" cellspacing="0" cellpadding="0"> <tr> <td class="dsR24"> <div class="txt_titlesearch"> <img class="dsR13" src="images/property/<?php echo($searchrow['img01']); ?>" alt="" border="0" /><br /> <br /> <?php echo($searchrow['town']); ?></div> <div class="txt_bodysearch"> <p><?php echo($searchrow['title']); ?><br /> <?php echo($searchrow['price']); ?><br /> Projected yield <?php echo($searchrow['yield']); ?></p> </div> </td> </tr> </table> </td> <?php $searchresult_endRow++; if($searchresult_endRow >= $searchresult_columns) { ?> </tr> <?php $searchresult_endRow = 0; } } while ($row_searchresult = mysql_fetch_assoc($searchresult)); if($searchresult_endRow != 0) { while ($searchresult_endRow < $searchresult_columns) { echo("<td> </td>"); $searchresult_endRow++; } echo("</tr>"); }?> </table> <br /> <?php } ?> In the example below, the region repeats with the correct data but only repeats downward http://88.208.206.63/riseoverseas/search-repeater.php?country=1 Here's the code: <?php $searchquery = "SELECT * FROM `property` WHERE `country` = ".$_GET['country']; $searchresult = mysql_query($searchquery); while($searchrow = mysql_fetch_array($searchresult)) { ?> <table > <tr> <?php $searchrow_endRow = 0; $searchrow_columns = 3; // number of columns $searchrow_hloopRow1 = 0; // first row flag do { if($searchrow_endRow == 0 && $searchrow_hloopRow1++ != 0) echo "<tr>"; ?> <td> <table class="dsR23" border="0" cellspacing="0" cellpadding="0"> <tr> <td class="dsR24"> <div class="txt_titlesearch"> <img class="dsR13" src="images/property/<?php echo($searchrow['img01']); ?>" alt="" border="0" /><br /> <br /> <?php echo($searchrow['town']); ?></div> <div class="txt_bodysearch"> <p><?php echo($searchrow['title']); ?><br /> <?php echo($searchrow['price']); ?><br /> Projected yield <?php echo($searchrow['yield']); ?></p> </div> </td> </tr> </table> </td> <?php $searchrow_endRow++; if($searchrow_endRow >= $searchrow_columns) { ?> </tr> <?php $searchrow_endRow = 0; } } while ($row_searchrow = mysql_fetch_assoc($searchrow)); if($searchrow_endRow != 0) { while ($searchrow_endRow < $searchrow_columns) { echo("<td> </td>"); $searchrow_endRow++; } echo("</tr>"); }?> </table> <br /> <?php } ?> Go gentle on me, I'm a graphic designer by trade so a lot of this web stuff is very new for me right now
  3. ??? <?php $searchquery = "SELECT * FROM `property` WHERE `country` = ".$_GET['country']; $searchresult = mysql_query($searchquery); while($searchrow = mysql_fetch_array($searchresult)) { ?> <table > <tr> <?php $searchrow_endRow = 0; $searchrow_columns = 3; // number of columns $searchrow_hloopRow1 = 0; // first row flag do { if($searchrow_endRow == 0 && $searchrow_hloopRow1++ != 0) echo "<tr>"; ?> <td> <table class="dsR23" border="0" cellspacing="0" cellpadding="0"> <tr> <td class="dsR24"> <div class="txt_titlesearch"> <img class="dsR13" src="images/property/<?php echo($searchrow['img01']); ?>" alt="" border="0" /> <?php echo($searchrow['town']); ?></div> <div class="txt_bodysearch"> <p><?php echo($searchrow['title']); ?> <?php echo($searchrow['price']); ?> Projected yield <?php echo($searchrow['yield']); ?></p> </div> </td> </tr> </table> </td> <?php $searchrow_endRow++; if($searchrow_endRow >= $searchrow_columns) { ?> </tr> <?php $searchrow_endRow = 0; } } while ($row_searchrow = mysql_fetch_assoc($searchrow)); if($searchrow_endRow != 0) { while ($searchrow_endRow < $searchrow_columns) { echo("<td> </td>"); $searchrow_endRow++; } echo("</tr>"); }?> </table>
  4. Hey guys I'm putting together a results page, which you can see a sample of here: http://88.208.206.63/riseoverseas/search.php?country=1 I'd like the results to be in a GRID format and I used some code from the Internet to do this. Unfortunately, instead of the data appearing as a grid, the table just repeats downwards instead. This is the code for the table/repeat region. Can anyone please let me know where I'm going wrong here? <?php $searchquery = "SELECT * FROM `property` WHERE `country` = ".$_GET['country']; $searchresult = mysql_query($searchquery); while($searchrow = mysql_fetch_array($searchresult)) { ?> <table > <tr> <?php $searchrow_endRow = 0; $searchrow_columns = 3; // number of columns $searchrow_hloopRow1 = 0; // first row flag do { if($searchrow_endRow == 0 && $searchrow_hloopRow1++ != 0) echo "<tr>"; ?> <td> <table class="dsR23" border="0" cellspacing="0" cellpadding="0"> <tr> <td class="dsR24"> <div class="txt_titlesearch"> <img class="dsR13" src="images/property/<?php echo($searchrow['img01']); ?>" alt="" border="0" /><br /> <br /> <?php echo($searchrow['town']); ?></div> <div class="txt_bodysearch"> <p><?php echo($searchrow['title']); ?><br /> <?php echo($searchrow['price']); ?><br /> Projected yield <?php echo($searchrow['yield']); ?></p> </div> </td> </tr> </table> </td> <?php $searchrow_endRow++; if($searchrow_endRow >= $searchrow_columns) { ?> </tr> <?php $searchrow_endRow = 0; } } while ($row_searchrow = mysql_fetch_assoc($searchrow)); if($searchrow_endRow != 0) { while ($searchrow_endRow < $searchrow_columns) { echo("<td> </td>"); $searchrow_endRow++; } echo("</tr>"); }?> </table>
  5. Huggie my man - you are a genius! Just one last thing - if one of the fields i blank, it reeturns all results no matter what. Is there any way I can tell it to ignore a field if it's blank? Here's what I have now... $query_directory = "SELECT * FROM directory WHERE Name LIKE '%{$_POST['name']}%' OR Keywords LIKE '%{$_POST['keywords']}%' ORDER BY name";
  6. I don't belive it! Just tried it but got the following message... You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE Keywords LIKE '%%' ORDER BY name ASC LIMIT 0, 10' at line Any ideas? ???
  7. Thanks Huggie - you're a star. I tried your statament and it worked first time. Kev P.S. - If I want to get results from two different form inputs can I just do this?.... $query_directory = "SELECT * FROM directory WHERE Name LIKE '%{$_POST['name']}%' OR WHERE Keywords LIKE '%{$_POST['keywords']}%' ORDER BY name ASC";
  8. Hi Huggie - I tried this code... mysql_select_db($database_directory, $directory); $query_directory = "SELECT * FROM directory WHERE Name LIKE '%$_POST['name']%' ORDER BY id DESC"; $query_limit_directory = sprintf("%s LIMIT %d, %d", $query_directory, $startRow_directory, $maxRows_directory); $directory = mysql_query($query_limit_directory, $directory) or die(mysql_error()); $row_directory = mysql_fetch_assoc($directory) But got the following error: Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /homepages/16/d93745840/htdocs/m18directory/results.php on line 13 I also tried it without the sprintf (and brackets) in the $query_limit_directory line but same error. Any ideas? I thought it wouldn't be too difficult to have a results page displaying all results from a table where the name field is like what the user has typed in the form but it's proving tricky!
  9. Note sure what that means but I get thie following error: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '"%s ORDER BY id DESC LIMIT 0, 10' at line 1 ??? Here's the code I just used... mysql_select_db($database_directory, $directory); $colname_directory = $_POST['name']; $query_directory = sprintf('SELECT * FROM directory WHERE Name LIKE "%'."%s".'%" ORDER BY id DESC', $colname_directory); $query_limit_directory = sprintf("%s LIMIT %d, %d", $query_directory, $startRow_directory, $maxRows_directory); $directory = mysql_query($query_limit_directory, $directory) or die(mysql_error()); $row_directory = mysql_fetch_assoc($directory);
  10. Just tried that but still get the same error  ???
  11. Hello there I'm pretty new to PHP and mianly use Dreamweaver to come up with most of the code for search interfaces to be honest so I'm hoping you guys can help me. I have this select statement for my search results page: $query_directory = sprintf("SELECT * FROM directory WHERE Name LIKE '%".$_POST['name']."%' ORDER BY id DESC", $colname_directory); to get all records from the database whose name contains characters typed in by the user from the search form. However, it doesn't work and SQL just comes back with an error so I think the syntax must be wrong. The standard statement (below) DOES return results but obviously it doesn't do what I need it to as it forces the user to type in the whole name exactly: $query_directory = sprintf("SELECT * FROM directory WHERE Name = '".$_POST['name']."' ORDER BY id DESC", $colname_directory); Can anyone help me make the first statement work? Kev
  12. Thanks for replying. When I tried this, I didn't get an error message this time but unfortunately I don't get any results either.
  13. Hello there I'm pretty new to PHP and mianly use Dreamweaver to come up with most of the code for search interfaces to be honest so I'm hoping you guys can help me. I have this select statement for my search results page: $query_directory = sprintf("SELECT * FROM directory WHERE Name LIKE '%".$_POST['name']."%' ORDER BY id DESC", $colname_directory); to get all records from the database whose name contains characters typed in by the user from the search form. However, it doesn't work and SQL just comes back with an error. The standard statement (below) DOES return results but obviously it doesn't do what I need it to as it forces the user to type in the whole name exactly: $query_directory = sprintf("SELECT * FROM directory WHERE Name = '".$_POST['name']."' ORDER BY id DESC", $colname_directory); Can anyone help me make the first statement work? Kev
×
×
  • 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.