私信  •  关注

suresh bambhaniya

suresh bambhaniya 最近创建的主题
suresh bambhaniya 最近回复了
5 年前
回复了 suresh bambhaniya 创建的主题 » 包含mysql的递归函数在php中不起作用[duplicate]

每次函数调用自身时,它都需要能够将返回值传递到调用堆栈上。你错过 返回

function stockToDate($base_date, $i) {

  include "../lib/dbconn.php" ;     

  $today = date("Y-m-d") ;
  $base_date = date("Y-m-d", strtotime($base_date . "-1day")) ; 


  $q  = " SELECT txn_date "
      . "   FROM tworking_ymd   "  
      . "  WHERE txn_date = '$base_date' " ;
  $r = mysqli_query($dbc, $q) ;

  if(mysqli_num_rows($r) == 1){

    $row = mysqli_fetch_row($r);    
    return $row[0] ;

  } else {


    $i = $i + 1 ;
    if($i > 10) {
        return $today ;

    } else {

        return stockToDate($base_date, $i) ;       
    }    
  }  
}
5 年前
回复了 suresh bambhaniya 创建的主题 » 如何使用jquery将HTML表单数据插入HTML表?

这是完整的例子

<!DOCTYPE html>
<html>
<head>
<title>Try update table</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script>

function addData(){
    $("#resultTable tr:last").after('<tr><td>'+$('input[name="taskDone"]:checked').val()+'</td><td>'+$('#description').val()+'</td><td>'+$('#taskType').children("option:selected").val()+'</td></tr>');
    return false;
}

</script>

</head>
<body>

    <table id="resultTable">
    <tr>
      <th>S.N</th>
      <th>Task</th>
      <th>Description</th>
      <th>Complete</th>
      <th>Type</th>
    </tr>
  </table>

    <form id="first_form" method="post" onsubmit="return addData();">
      Given Task : <input type="text" id="first_name" name="task" value="">
      <br><br> Description: <input type="text" id="description" name="description" value=""><br>
      <br> Complete: <input type="radio" name="taskDone" value="yes" checked> Yes
      <input type="radio"  name="taskDone" value="no"> No<br> <br> Task Type:
      <select id="taskType">
        <option value="regular">Regular</option>
        <option value="Meeting">Meeting</option>
        <option value="coding">Coding</option>
        <option value="documentation">Documentation</option>
        <option value="support">Support</option>
      </select> <br> <br>
      <input type="submit"  value="submit" button class="button">
    </form>

</body>
</html>