Jump to content

justlukeyou

Members
  • Posts

    957
  • Joined

  • Last visited

Posts posted by justlukeyou

  1. Hi,

     

    I tried this but I couldn't get it to work.  Could it be because I am using "$price =" twice?

     

    <?php
    
    $price = explode($_GET['price']);
    echo $price[0];
    echo "<br/>";
    echo $price[1];
    
    if( isset($_GET['price'])) {
    $price = explode($_GET['price']);
    $query = "SELECT * FROM productfeed WHERE price between '$price[0]' and '$price[1]' LIMIT 0, 10";
    $fetchdata = mysql_query($query) ;
    while($row = mysql_fetch_array($fetchdata)) {
    $id = $row['id'];
    $image = $row['awImage'];
    $link = $row['link'];
    $description = $row['description'];
    $fulldescription = $row['fulldescription'];
    $price = $row['price'];
    
    echo "<div class='productdisplayshell'>
    <div class='productdisplayoutline'>
    <div class='productborder'><center>
    <a href='$link' target='_blank'><img src='$image' width=\"95%\" /></a>
    </center> </div></div>
    <div class='productdescriptionoutline'>
    <div class='productdescriptionbox'>
    <a href='$link' target='_blank' >$description</a>
    </div>
    <div class='productfulldescriptionbox'>$fulldescription</div>
    </div>
    <div class='productpriceoutline'>
    <div class='productpricebox'>
    <center>&#163; $price</center>
    </div>
    <div class='productbuybutton'>
    <center><a href='$link' target='_blank' ><img src=/images/buybutton.png /></a></center>
    </div>
    </div>
    </div>";
    } echo 
    'Product is not available.  Please visit our <a href="http://www.ukhomefurniture.co.uk">Homepage</a>';
    }
    ?>

  2. Thanks,

     

    I tried using that.

     

    Do I need to set values to $lower_limit AND $upper_limit ?

     

    if( isset($_GET['price'])) {
    $price = $_GET['price'];
    $query = "SELECT * FROM productfeed WHERE price BETWEEN $lower_limit AND $upper_limit LIMIT 0, 10";
    $fetchdata = mysql_query($query) ;
    while($row = mysql_fetch_array($fetchdata)) {
    $id = $row['id'];
    $image = $row['awImage'];
    $link = $row['link'];
    $description = $row['description'];
    $fulldescription = $row['fulldescription'];
    $price = $row['price'];

  3. I see, so its using the query twice.

     

    I tried it with the following but this came back with the same response.  Nothing.

     

    $query = "SELECT * FROM productfeed WHERE price between '$price' LIMIT 0, 10";

     

    If I use the following and search for an individual price it does display an individual price but I can find the code to display a range.

     

    $query = "SELECT * FROM productfeed WHERE price like '%$price%' LIMIT 0, 10";

  4. I am trying to search between two range of numbers. So it displays everything from 1 and 300.

     

    phppricerange.php?price=1-300

     

    I have this code so far.  I found it based on date example which shows everything between two dates.  However, I dont seem to be able to get it to work for my code.

     

    <?php
    if( isset($_GET['price'])) {
    $price = $_GET['price'];
    $query = "SELECT * FROM productfeed WHERE price between '$price' and '$price' LIMIT 0, 10";
    $fetchdata = mysql_query($query) ;
    while($row = mysql_fetch_array($fetchdata)) {
    $id = $row['id'];
    $image = $row['awImage'];
    $link = $row['link'];
    $description = $row['description'];
    $fulldescription = $row['fulldescription'];
    $price = $row['price'];

     

    Can anyone advise please.  The strange thing is it isn't coming up with any errors.  Even if I use:

     

    price=1&300 or price=1-300

  5. I'm new to PHP so dont quote me on this but I would say that you can simplify this part:

     

    $query = "SELECT * " ;		$query .= "FROM pages ";		$query .= "WHERE id=" . $name . " ";		$query .= "LIMIT 1";			

     

    Down to something like:

     

    $query = "SELECT * FROM productfeed WHERE name like '%$name%' LIMIT 0, 1";

     

    So basically its in one line.

     

    Try and build it up stages and resave each attempt.  Sometimes I had 16 files of the slightly different variations before I could move on.

  6. I have two seperate piece of code.  One which sorts description and one which sorts price.  However, I am looking to almalgamate them into one.  I have tried the following however I appear to be way off. 

     

    I want to select a product description with one link and then select a price range.  However, I want the price range to read the description. 

     

    <?phpif( isset($_GET['description' ; 'price' ]))
    $description = $_GET['description' ; 'price'];
    $query = "SELECT * FROM productfeed WHERE description like '%$description%' LIMIT 0, 10";
    $query = "SELECT * FROM productfeed WHERE price like '%$price%' LIMIT 0, 10";
    $fetchdata = mysql_query($query) or die("query: $query<br>
    This has an error: " . mysql_error() . '<br>');while($row = mysql_fetch_array($fetchdata)) {
    $id = $row['id'];
    $image = $row['awImage'];
    $link = $row['link'];
    $description = $row['description'];
    $fulldescription = $row['fulldescription'];
    $price = $row['price'];
    

     

    <?phpif( isset($_GET['description']))
    $description = $_GET['description'];
    $query = "SELECT * FROM productfeed WHERE description like '%$description%' LIMIT 0, 10";
    $fetchdata = mysql_query($query) or die("query: $query<br>
    This has an error: " . mysql_error() . '<br>');while($row = mysql_fetch_array($fetchdata)) {
    $id = $row['id'];
    $image = $row['awImage'];
    $link = $row['link'];
    $description = $row['description'];
    $fulldescription = $row['fulldescription'];
    $price = $row['price'];
    

     

    <?phpif( isset($_GET['price']))
    $price = $_GET['price'];
    $query = "SELECT * FROM productfeed WHERE price like '%$price%' LIMIT 0, 10";
    $fetchdata = mysql_query($query) or die("query: $query<br>
    This has an error: " . mysql_error() . '<br>');while($row = mysql_fetch_array($fetchdata)) {
    $id = $row['id'];
    $image = $row['awImage'];
    $link = $row['link'];
    $description = $row['description'];
    $fulldescription = $row['fulldescription'];
    $price = $row['price'];
    

  7. Thanks kenrbnsn,

     

    If I put this code into my page will it only work on "red%widget"?

     

    Do I need to tell it to remove the % from whatever I put into the description.  So it would work on :

     

    phpproductdisplay.php?description=red%ball

     

    <?php$str = "red%widget";echo ucwords(str_replace('%',' ',$str));?>

     

    Would I use something like?

     

    <?php$str = "'description'";echo ucwords(str_replace('%',' ',$str));?>

     

  8. Lets say I have a 'Red Widget' and 'Red Ball' in my database.

     

    At the moment I am searching for:

     

    phpproductdisplay.php?description=red - this displays both items.

     

    However, if I search for:

     

    phpproductdisplay.php?description=red%widget

     

    This displays only the red widget which works fine.

     

    However, I want to display the search terms on my site and in the title.  So at the moment.  I am displaying "red%widget".  But I want to display "Red Widget".

     

    Is it possible to get 'Red Widget'?

  9. Very nice, excellent use of colours and professional in appearance. 

     

    Could maybe do with the footer links as a simple line on their own as it looks a little bit top heavy at the moment.  I also notice it has a 'top' button but on my screen it only applies to around 5 pixels so it comes across as little bit unecessary.

     

    Maybe you use a different graphical image on each page as the one you have looks very neat but does get repititive. 

     

    -- Very nice design, I think the lack of footer makes it appear top heavy but a very design.

  10. The Guardian newspaper claims that we are heading for another internet bubble.  Facebook = $60 bn, Twitter = $10 bn and $2m for a website which allows people to annouce that a friend or relative has died.

     

    Does anyone think that the current internet investment bubble could burst and if so could it seriously damage the legitimacy of the internet with many people viewing it as a folly instead a serious business case.

  11. I am currently working on my PHP/MySQL driven website.  However, I have read in recent weeks that there are a number of security measures which need to be taken and one of them is sanitising input to prevent html/MySQL injection into a database.  So I was wondering if there is an 'industry standard' for sanitising PHP.  For example, if a website only want there database to be searched by letters or numbers do they use a specific code?  I have found one based on numbers (for ID numbers) but I cant find on one based on letters.

     

    I found this but it is quite complicated and looks very different to the guide I found on YouTube.  so is there an industry standard which blocks people using any other code than numbers or letters?

     

    http://bobby-tables.com/php.html

     

    I was also wondering is there are anyother security measures I need to be aware of when using PHP?

  12. Hi,

     

    Yes but this isn't working. 

     

    If I have "red widget" in my database under 'description' but then search for:

     

    ?description=redwidget

    ?description=red-widget

    ?description=red

    ?description=widget

     

    All I get at the moment all I get is a blank screen.  However, I know that I have a 'red widget' in 'description' because I can display them using the ID number.  However, I am trying to do by using the description but I am getting very stuck on this.

     

    However, if I search for:

     

    php?description=description

     

    I get everything displayed from my database. 

     

  13. If I put the following -----here curlys in does something very wierd.  It only shows the description I am searching and cuts out everything else such as the image.

     

    Is it possible to get a code which overrights what is in the string because that is what I appear to be doing.

     

    <?php
    if( isset($_GET['description']))
    $description = $_GET['description'];
    $query = "SELECT * FROM productfeed WHERE description = '$description' LIMIT 0, 10";
    $fetchdata = mysql_query($query) or die("query: $query<br>This has an error: " . mysql_error() . '<br>');
    while($row = mysql_fetch_array($fetchdata)) {
    $id = $row['id'];
    $image = $row['awImage'];
    $link = $row['link'];
    $description = $row['description'];
    $fulldescription = $row['fulldescription'];
    $price = $row['price'];
    } -----here
    
    
    
    
    { -----here
    echo "<div class='productdisplayshell'>
    <div class='productdisplayoutline'>
    <div class='productborder'><center>
    <a href='$link' target='_blank'><img src='$image'/></a>
    </center> </div></div>
    <div class='productdescriptionoutline'>
    <div class='productdescriptionbox'>
    <a href='$link' target='_blank' >$description</a>
    </div>
    <div class='productfulldescriptionbox'>$fulldescription</div>
    </div>
    <div class='productpriceoutline'>
    <div class='productpricebox'>
    <center>&#38;#163; $price</center>
    </div>
    <div class='productbuybutton'>
    <center><a href='$link' target='_blank' ><img src=/images/buybutton.png /></a></center>
    </div>
    </div>
    </div>";
    } 
    ?> 

  14. Hi,

     

    Many thanks, I am trying to aichieve this:

     

    "phpdescriptionresults2.php?description=red-widget"  --- For this to display every 'red widget' in my database.

     

    Following is all the code I have:

     

    <?php
    if( isset($_GET['description']))
    $description = $_GET['description'];
    $query = "SELECT * FROM productfeed WHERE description = $description LIMIT 0, 10";
    $fetchdata = mysql_query($query) or die("query: $query<br>This has an error: " . mysql_error() . '<br>');
    while($row = mysql_fetch_array($fetchdata)) {
    $id = $row['id'];
    $image = $row['awImage'];
    $link = $row['link'];
    $description = $row['description'];
    $fulldescription = $row['fulldescription'];
    $price = $row['price'];
    
    
    
    echo "<div class='productdisplayshell'>
    <div class='productdisplayoutline'>
    <div class='productborder'><center>
    <a href='$link' target='_blank'><img src='$image'/></a>
    </center> </div></div>
    <div class='productdescriptionoutline'>
    <div class='productdescriptionbox'>
    <a href='$link' target='_blank' >$description</a>
    </div>
    <div class='productfulldescriptionbox'>$fulldescription</div>
    </div>
    <div class='productpriceoutline'>
    <div class='productpricebox'>
    <center>&#38;#163; $price</center>
    </div>
    <div class='productbuybutton'>
    <center><a href='$link' target='_blank' ><img src=/images/buybutton.png /></a></center>
    </div>
    </div>
    </div>";
    } 
    ?> 
    

  15. Hi,

     

    The title of field is 'description' as this is the one I am echoing so I know it works.

     

    I did try the following but it didn't do anything.  Is there anything else I can do to improve the situation?

     

    if( isset($_GET['productname']))
    $description = $_GET['productname'];
    $query = "SELECT * FROM productfeed WHERE productname = $description LIMIT 0, 10";$fetchdata = mysql_query($query) or die("query: $query<br>This has an error: " . mysql_error() . '<br>');

  16. Hi,

     

    Excluding the full domain name this (/test/phpdescriptionresults2.php?description=description) shows every items.  This (/test/phpdescriptionresults2.php?description=redwidget) shows the following error:

     

    query: SELECT * FROM productfeed WHERE description = redwidget LIMIT 0, 10

    This has an error: Unknown column 'redwidget' in 'where clause'.  I just cant see why only the "description" works instead of the actual product name.  Is it because I am using "description" twice.  In the echo and as a query?

     

    This is the full code I have currently:

     

    <?php
    if( isset($_GET['description']))
    $description = $_GET['description'];
    $query = "SELECT * FROM productfeed WHERE description = $description LIMIT 0, 10";
    $fetchdata = mysql_query($query) or die("query: $query<br>This has an error: " . mysql_error() . '<br>');
    while($row = mysql_fetch_array($fetchdata)) {
    $id = $row['id'];
    $image = $row['awImage'];
    $link = $row['link'];
    $description = $row['description'];
    $fulldescription = $row['fulldescription'];
    $price = $row['price'];
    
    
    
    
    
    
    echo "<div class='productdisplayshell'>
    <div class='productdisplayoutline'>
    <div class='productborder'><center>
    <a href='$link' target='_blank'><img src='$image'/></a>
    </center> </div></div>
    <div class='productdescriptionoutline'>
    <div class='productdescriptionbox'>
    <a href='$link' target='_blank' >$description</a>
    </div>
    <div class='productfulldescriptionbox'>$fulldescription</div>
    </div>
    <div class='productpriceoutline'>
    <div class='productpricebox'>
    <center>&#38;#163; $price</center>
    </div>
    <div class='productbuybutton'>
    <center><a href='$link' target='_blank' ><img src=/images/buybutton.png /></a></center>
    </div>
    </div>
    </div>";
    } 
    ?> 
    

  17. Actually, if I remove

     

    /* redundent line removed here */

     

    and enter back in the following it no longer replaces each description with "description" but now shows the correct description. 

     

    $description = $row['description'];

     

    However, it now shows every product in database when I use "phpdescriptionresults2.php?description=description" in the search bar but if use "phpdescriptionresults2.php?description=redwidget" it comes with the following error:

     

    query: SELECT * FROM productfeed WHERE productname = redwidget LIMIT 0, 10

    This has an error: Unknown column 'productname' in 'where clause'

     

    So I am back to where I was earlier.  At least I think I am!

  18. Hi,

     

    If I use the following code it displays everything in the database and changes the description of each $description to "description". 

     

    if( isset($_GET['description']))
    $description = $_GET['description'];
    $query = "SELECT * FROM productfeed WHERE description = $description LIMIT 0, 10";
    $fetchdata = mysql_query($query) or die("query: $query<br>This has an error: " . mysql_error() . '<br>');
    while($row = mysql_fetch_array($fetchdata)) {
    $id = $row['id'];
    $image = $row['awImage'];
    $link = $row['link'];
    /* redundent line removed here */
    $fulldescription = $row['fulldescription'];
    $price = $row['price'];

     

    However,

     

    if just add the following single commas likes this I get a blank screen so I'm quite puzzled as to whats doing.  Ive tried around 20 variations but this seems to be the closest I can get it.

     

    $query = "SELECT * FROM productfeed WHERE description = '$description' LIMIT 0, 10";

     

×
×
  • 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.