0

I'm trying to build a page where my users can paste in multiple item #s for that product and it will give them the parent model # for that particular item, where items are given individual identifiers.

However, my users paste there information into the textboxs, but it doesn't pull anything up. When I had one value to search it was able to find the items. My table structure is very simple.Fcsku varchar(45), fnsku varchar(45), updated time(45 are not important to this function).

Here is my query Updated:

<form action="" method="get">  
  Paste your ZZZ's here: <br><input type="text" name="item" id="textbox"/><br>
  <input type="text" name="item2" id="textbox2"/>
  <script>document.getElementById('textbox').focus()</script><br />  
  <input type="submit" value="Submit"/>  
</form>  
<?php
if (!empty($_REQUEST['item'])) {
    $item = mysql_real_escape_string($_REQUEST['item']);
    $item2 = mysql_real_escape_string($_REQUEST['item2']);     

    $sql = "select * from oak3_zzz_to_boo WHERE fcsku like '%".$item."%' or fcsku like '%".$item2."%'"; 
    $r_query = mysql_query($sql); 


    while ($row = mysql_fetch_array($r_query)) {  
        echo "<font color=red size=7>";
        echo '<center><br /> Parent ASIN: '.$row['fnsku']; 
        echo "</center></font>";
        echo "<br><br><br><br><br>";
    }    
}
?>
4
  • What's wrong with your code? Commented Dec 30, 2013 at 23:31
  • It does not pull any information when I try to have both of the multiple search boxes. Commented Dec 30, 2013 at 23:33
  • Or even if it could be one box, and it would search depending on how many seperate values were pasted would work for our purpose. Commented Dec 30, 2013 at 23:38
  • With updated code it appears to be working now! THANKS EVERYONE! But, would there be a way to search depending on how many seperate values were pasted into a single box? Commented Dec 30, 2013 at 23:40

1 Answer 1

1

This worked at my server:

<form action="" method="post">  
    Paste your ZZZ's here:<br />
    <input type="text" name="item" id="textbox" /><br />
    <input type="text" name="item2" id="textbox2"/><br /> 
    <input type="submit" value="Submit" name="submit"/>
    <script>document.getElementById('textbox').focus()</script>  
</form>

<?php
if (isset($_POST['submit'])) {
    $item = mysql_real_escape_string('%'.$_POST['item'].'%');
    $item2 = mysql_real_escape_string('%'.$_POST['item2'].'%');

    $sql = "SELECT * FROM oak3_zzz_to_boo WHERE fcsku LIKE '" . $item . "' OR fcsku LIKE '" . $item2 . "'";
    $r_query = mysql_query($sql); 
    while ($row = mysql_fetch_assoc($r_query)) {  
        echo "<font color=red size=7>";
        echo '<center><br />Parent ASIN: ' . $row['fnsku']; 
        echo "</center></font>";
        echo "<br /><br /><br /><br /><br />";
    }  
}
?>
Sign up to request clarification or add additional context in comments.

3 Comments

Thanks, I have made the adjustment right before you commented. I have it now showing data from item, but not item2. I think it may be related to <?php if (!empty($_REQUEST['item'])){ $item = mysql_real_escape_string($_REQUEST['item']); $item2 = mysql_real_escape_string($_REQUEST['item2']);
With updated code it appears to be working now! THANKS EVERYONE! But, would there be a way to search depending on how many seperate values were pasted into a single box?
@Spartacus38 - Ah, good. I cleaned the code a bit. Guessing you don't need it now tho. Please accept my answer. If you have another problem (after Googling and trying), post a new question :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.