Jump to content

Posting to MSSQL based on two criteria.


Butterbean

Recommended Posts

This is posting to any row in mssql that has a matching 'start_date'.  I would like it to post rows where start_date = '$start_date' and it also matches the 'meter_id' .  It should perform this check of both parameters before posting to mssql. 

<?php
$session_id = $_SESSION['id'];
$comm_id = $_GET['meter_id'];
$start_date = $_GET['start_date'];
$payment_date = $_POST['payment_date'];
$amount_paid = $_POST['amount_paid'];
$check_number = $_POST['check_number'];

$sql = "UPDATE [radiogates].[dbo].[ops_invoice_history] SET payment_date = '$payment_date', amount_paid = '$amount_paid', check_number = '$check_number' where start_date = '$start_date'";

$query = sqlsrv_query($conn, $sql);

Thank you for any help.

Link to comment
https://forums.phpfreaks.com/topic/293742-posting-to-mssql-based-on-two-criteria/
Share on other sites

thought this would work but did not.

$sql = "UPDATE [radiogates].[dbo].[ops_invoice_history] SET payment_date = '$payment_date', amount_paid = '$amount_paid', check_number = '$check_number' where start_date = '$start_date'& meter_id = '$meter_id' ";

Are you using $_POST or $_GET? Because in your first lines of code you are using both, which is odd.

 

Regarding your query, you should use double ampersands (&&) or better to just use "AND" for the logical operator. I don't believe a single & means anything.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.