简体   繁体   English

PHP / MySQL在同一列中有多个值

[英]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). Fcsku varchar(45), fnsku varchar(45), updated time(45此功能不重要Fcsku varchar(45), fnsku varchar(45), updated time(45 )。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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