简体   繁体   中英

PHP/MySQL multiple values in same column

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>";
    }    
}
?>

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 />";
    }  
}
?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM