Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/476.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
php mysql表中的提交按钮_Php_Javascript_Jquery - Fatal编程技术网

php mysql表中的提交按钮

php mysql表中的提交按钮,php,javascript,jquery,Php,Javascript,Jquery,我所拥有的: <table class="sortable table table-hover table-bordered"> <thead> <tr> <th>CPU</th> <th>Speed</th> <th>Cores</th> <th>TDP</th> <th>Preformace</t

我所拥有的:

<table class="sortable table table-hover table-bordered">
  <thead>
  <tr>
    <th>CPU</th>
    <th>Speed</th>
    <th>Cores</th>
    <th>TDP</th>
    <th>Preformace</th>
    <th>Overclocing</th>
    <th>Price</th>
    <th>Buy</th>
  </tr>
  </thead>
  <tbody>
  <?php $i=0 ;
    do {
    $preformace = $row_Procesory['Preformace'];
    $over = $row_Procesory['Overclocing'];
    $i++; ?>
    <tr>
    <td><?php echo $row_Procesory['CPU']; ?></td>
    <td><?php echo $row_Procesory['Speed']; ?></td>
    <td><?php echo $row_Procesory['Cores']; ?></td>
    <td><?php echo $row_Procesory['TDP']; ?></td>
    <td><?php echo "
    <script type='text/javascript'>
    $(document).ready(function() {
    $('#progressbarP$i').height(10).progressbar({
                                    value : 1
                                    });
    $('#progressbarP$i .ui-progressbar-value').animate(
    {width: '$preformace%'},{queue: false});
    });
    </script>
    <div id='progressbarP$i' title='$preformace'></div>  
    ";?></td>

    <td><?php echo "
    <script type='text/javascript'>
    $(document).ready(function() {
    $('#progressbarO$i').height(10).progressbar({
                                    value : 1
                                    });             
    $('#progressbarO$i .ui-progressbar-value').animate({
        width: '$over%'
        }, 1000);
    });
    </script>
    <div id='progressbarO$i' title='$over'></div>  
    ";?></td>

    <td><?php echo $row_Procesory['Price']; ?></td>
    <!-- BUTTON SECTION -->
   <td><?php echo "<button class='btn btn-success' type='button' align='CENTER'>Add</button>";?></td>
  </tr>
    <?php } while ($row_Procesory = mysql_fetch_assoc($Procesory)); ?>
</tbody>
</table>

中央处理器
速度
核心
TDP
预制面
超频
价格
购买

如果我理解你的问题,这里有些东西可以帮助你

<table class="sortable table table-hover table-bordered">
  <thead>
  <tr>
    <th>CPU</th>
    <th>Speed</th>
    <th>Cores</th>
    <th>TDP</th>
    <th>Preformace</th>
    <th>Overclocing</th>
    <th>Price</th>
    <th>Buy</th>
  </tr>
  </thead>
  <tbody>
  <?php $i=0 ;
    do {
    $preformace = $row_Procesory['Preformace'];
    $over = $row_Procesory['Overclocing'];
    $i++; ?>
    <tr>
    <td><?php echo $row_Procesory['CPU']; ?></td>
    <td><?php echo $row_Procesory['Speed']; ?></td>
    <td><?php echo $row_Procesory['Cores']; ?></td>
    <td><?php echo $row_Procesory['TDP']; ?></td>
    <td><?php echo "
    <script type='text/javascript'>
    $(document).ready(function() {
    $('#progressbarP$i').height(10).progressbar({
                                    value : 1
                                    });
    $('#progressbarP$i .ui-progressbar-value').animate(
    {width: '$preformace%'},{queue: false});
    });
    </script>
    <div id='progressbarP$i' title='$preformace'></div>  
    ";?></td>

    <td><?php echo "
    <script type='text/javascript'>
    $(document).ready(function() {
    $('#progressbarO$i').height(10).progressbar({
                                    value : 1
                                    });             
    $('#progressbarO$i .ui-progressbar-value').animate({
        width: '$over%'
        }, 1000);
    });
    </script>
    <div id='progressbarO$i' title='$over'></div>  
    ";?></td>

    <td><?php echo $row_Procesory['Price']; ?></td>
    <!-- BUTTON SECTION -->
   <td><?php echo "<button class='btn btn-success pro_btn' processor = '".$row_Procesory['CPU']."'  type='button' align='CENTER'>Add</button>";?></td>
  </tr>
    <?php } while ($row_Procesory = mysql_fetch_assoc($Procesory)); ?>
</tbody>
</table>
如果不想使用该属性,可以执行类似操作

var name = $(this).closest('tr').find('td:first').text();

我希望这能有所帮助:)

捕获点击事件并找到最近的“tr”,然后找到该“tr”的第一个“td”。这将是这样的:

$(this).closest('tr').find('td:first').text();
或者得到你的按钮,这将是td,他们td的父母。这将是最后一次获得第一个td

$(this).parent().parent().find('td:first').text();
或者只需向按钮添加一个附加属性,然后获取值

$(this).attr('processor');

请制作一个JSFIDLE,这样我们就可以从我的mysql服务器上获得更多的动态信息。它将是jsfiddle中的一个简单表。是的,我知道,但作为HTML和JS测试它会更容易。看看我的答案谢谢,我明天会试试。我不知道我可以建立自己的属性。不,你可以,明天告诉我结果。虽然你可以建立自己的属性,但不推荐。HTML5为用户定义的属性保留了
数据XXX
,您应该使用它。jQuery使用
.data()
方法支持这一点:
$(this).data('processor')
相当于
$(this).attr('data-processor')
@Barmar谢谢您的评论,我知道,因为HTML5,我展示了两种方式,感谢您刚才提供的精彩信息provided@Sedz很好,我使用了
数据处理器='$Procesor'
atribute,然后使用
$(this.data('processor')谢谢酒吧招待和塞兹诺,他的比你的早几分钟。你现在说不出来,因为时代总是这样。但如果你们的答案在两分钟之内,我绝不会做出这样的评论。不知道,当我开始回答这个问题时,并没有任何答案。但无论如何,下次在提交答案之前会刷新问题。
$(this).attr('processor');