通过邮件发送表格中的复选框数据


sending checkbox data in table through mail

我试图通过邮件发送选定的复选框数据在表的结构,但得到以下错误:

implode(): Invalid arguments passed

static function mcontent($chkbox){
    $sql = "SELECT station,reach,language,rate FROM `radio_city` where chkid in (".implode(',', $chkbox).")";
    return DB::select($sql);
}

请帮助。谢谢Jyoti

View1:在通过邮件

发送数据时使用
<input type="hidden" name="checkbox" id="checkbox" >
              <input type="hidden" name="hiddamount" id="hiddamount">
              <input type="email" name="email" id="email">&nbsp;&nbsp;
              <input type="submit" id="submit" class="button" style="box-shadow: 5px 5px 3px #888888;" value="Email Plan" onsubmit="return validateForm();checkbox();"/>
function checkbox(){
  if (document.myForm.checkbox.checked){
    document.getElementById("error").innerHTML = "";
    return true;
  }
  else {
    document.getElementById("error").innerHTML = "Select your Plans";
  }
}

View2:在选择复选框

时使用
<td onchange="Process(this.options[this.selectedIndex].value)" class="chart_row" align="center" >
    <input type="checkbox" name="checkbox[<?php echo $i; ?>]" id="checkbox" value="<?php echo $chkid; ?>" data-price="<?php echo $total; ?>" onChange="updateTotal(this);">
</td>
<td id="station" class="chart_row" align="center"><?= $result->station ?></td>
<td id="reach" class="chart_row" align="center"><?= $result->reach ?></td>
<td id="language" class="chart_row" align="center"><?= $result->language ?></td>
<td id="rate" class="chart_row" align="center">Rs <?= $result->rate ?>/-</td>
<td id="duration" class="chart_row" align="center"><?= $duration ?></td>
<td id="frequency" class="chart_row" align="center"><?= $frequency ?></td>
<td id="hours" class="chart_row" align="center"><?= $hours ?></td>
<?php $totals += ($result->rate) * $duration * $frequency * $hours * $days/10; ?></div>
</tr>

控制器:

function mail() {
    $input = Input::get();
    if (isset($_GET['checkbox'])){
        $city = $_GET['city'];
        $duration = $_GET['duration'];
        $frequency = $_GET['frequency'];
        $hours = $_GET['hours'];
        $days = $_GET['days'];
        $total = $_GET['hiddamount'];
        $chkbox = $_GET['checkbox'];
        $mailrslt = Radio::mcontent($chkbox); 
        $cityname = Radio::getall($input);
        foreach($cityname as $cities){
            //modify table ans add css here if you want.
            $html_table ="<table><caption>City: ".$cities->city."</caption><thead style='color:A0A0A0'><th width='200' align='center' class='tabledata' style='background: #f9f9f9;color: #000000;;border-bottom: 1px solid #d6d6d6;border-right: 1px solid #d6d6d6;padding: 5px 10px;'>Station</th>
                                <th width='200' align='center' class='tabledata' style='background: #f9f9f9;color: #000000;;border-bottom: 1px solid #d6d6d6;border-right: 1px solid #d6d6d6;padding: 5px 10px;'>Reach</th>
                                <th width='200' align='center' class='tabledata' style='background: #f9f9f9;color: #000000;;border-bottom: 1px solid #d6d6d6;border-right: 1px solid #d6d6d6;padding: 5px 10px;'>Language</th>
                                <th width='200' align='center' class='tabledata' style='background: #f9f9f9;color: #000000;;border-bottom: 1px solid #d6d6d6;border-right: 1px solid #d6d6d6;padding: 5px 10px;'>Rate</th>
                                <th width='200' align='center' class='tabledata' style='background: #f9f9f9;color: #000000;;border-bottom: 1px solid #d6d6d6;border-right: 1px solid #d6d6d6;padding: 5px 10px;'>Jingle Lenght</th>
                                <th width='200' align='center' class='tabledata' style='background: #f9f9f9;color: #000000;;border-bottom: 1px solid #d6d6d6;border-right: 1px solid #d6d6d6;padding: 5px 10px;'>Frequency</th>
                                <th width='200' align='center' class='tabledata' style='background: #f9f9f9;color: #000000;;border-bottom: 1px solid #d6d6d6;border-right: 1px solid #d6d6d6;padding: 5px 10px;'>Hours/Day</th>
                                <th width='200' align='center' class='tabledata' style='background: #f9f9f9;color: #000000;;border-bottom: 1px solid #d6d6d6;border-right: 1px solid #d6d6d6;padding: 5px 10px;'>Days/Week</th></thead><tbody style='color: #000000;'>";}
                //whole query result is here
                                foreach($mailrslt as $key=>$row) {
                                $html_table .= "<tr>";
                //Iterate your data for table data.
                                foreach($row as $key2=>$row2){                    
                                $html_table .= "<td width='200' align='center' class='tabledata'>" . $row2 . "</td>";
                                        }
                //Database data ends here
                                $html_table .= "<td width='200' align='center' class='tabledata'>" . $duration . "</td>";
                                $html_table .= "<td width='200' align='center' class='tabledata'>" . $frequency . "</td>";
                                $html_table .= "<td width='200' align='center' class='tabledata'>" . $hours . "</td>";
                                $html_table .= "<td width='200' align='center' class='tabledata'>" . $days . "</td>";
                                        } //table rows ends here for displaying data
                                $html_table .= "</tr></tbody></table>";
                //contact details and total calculation done here
                                $html_table .= "<p>The total negotiable cost for your activity is <b>Rs ".$total."/-</b></p><div float='right'></p><u><b>For Best Rates</b></u></br> Call: Samir-+919686595443</br>Email: samir@themediaant.com</p></div>";
                                $to = $input['email'];//user email id from form.
            $from = 'help@themediaant.com';//from email ID
            $subject = 'Self Help Radio Planner';//subject
            $totals = 0;
            $message = $html_table;//assigning html_table variable to message.
            $contact_enquiry = new ContactEnquiry;
            $contact_enquiry->email = $from;
            $contact_enquiry->message = $message;
            $contact_enquiry->save();
//final mail function goes here
            $mail = Mail::send('emails.media_option_assistance', ['msg' => $message], function ($msg) use ($from, $to, $subject) {
                $msg->from($from, 'The Media Ant');
                $msg->to($to)->subject($subject);//->cc('servicing@themediaant.com');
            });
        //after successful mail redirect user to same page.
            return Redirect::to('/radio-plan/radioplan')->with('message','<b>Congratulations! You have succesfully sent the email');
    }       
}

模型:

static function mcontent($chkbox){
    $sql = "SELECT station,reach,language,rate FROM `radio_city` where chkid in (".implode(',', $chkbox).")";
    return DB::select($sql);
}

问题就在这里

$chkbox = $_GET['checkbox'];
$mailrslt = Radio::mcontent($chkbox); 

implode要求第二个参数(如果只提供一个参数,则第一个参数)为array。您向mcontent提供从输入得到的string。因此,当您在mcontent中达到implode时,您正在尝试将string转换为string

所以你必须创建一个array和一个或多个变量传递给你的函数,或者从函数中删除implode

我会尽量帮助更多,但老实说,我不太理解你的代码,这将是一个猜谜游戏