Jump to content

rguitar

Members
  • Posts

    5
  • Joined

  • Last visited

About rguitar

  • Birthday 02/07/1971

Profile Information

  • Gender
    Male

rguitar's Achievements

Newbie

Newbie (1/5)

1

Reputation

  1. Im inserting information in the first table then getting InsertID for the foreign key for the second table to tie the records together. The second table will not insert and if(isset($_POST['submit'])) { $date = $_POST['txt_date']; $hospital = $_POST['hospital_dd']; //prepare statement $stmt = $conn->stmt_init(); //sql $sql = "INSERT INTO Brucella (ClientName, PatientName,IDNumber,Age,AgeType,Sex,Doctor,Results,TestId) values (?,?,?,?,?,?,?,?,?)"; $sqlTest = "Insert Into BrucellaTest (DateReported, DateSubmitted, Technician, Samples) values (?,?,?,?)"; if($_POST['hospital_dd'] >= 1){ if(isset($_GET['TestId']) ){ $TheTestId = $_GET['TestId']; $sqlUpdate = "Update BrucellaTest set DateReported = ?, DateSubmitted = ?, Technician = ?, Samples=? where Id ='$TheTestId'"; $stmt->prepare($sqlUpdate); $stmt->bind_param('sssi',$_POST['date_reported'],$_POST['txt_date'],$_POST['tech'],$_POST['samples']); $stmt->execute(); $InsertId = $_GET['TestId']; }else { $stmt->prepare($sqlTest); $stmt->bind_param('sssi',$_POST['date_reported'],$_POST['txt_date'],$_POST['tech'],$_POST['samples']); $stmt->execute(); $InsertId = $stmt->insert_id; } } if($stmt->prepare($sql)){ //bind parameters $stmt->bind_param('ssssssssi', $_POST['hospital_dd'],$_POST['txt_patient_name'], $_POST['txt_id'],$_POST['txt_age'],$_POST['age_value'],$_POST['sel_sex'],$_POST['txt_doctor'],$_POST['sel_results'], '$InsertId'); $stmt->execute(); } } ?>
  2. thanks for all replies. I tested the code and it seems it only works if the javascript function returns true or false using the return statement in the function and using the return statement after onclick event. Although the function does respond to 'ok' and 'cancel' buttons (tested by using alert boxes) properly, the return statement is needed to prevent the redirect on 'cancel'
  3. ok, thanks for your quick reply.
  4. I have a table built from MySql database by PHP and I want to have the ability to delete a row by a delete button at the end of each row. When clicking the Cancel on confirm it continues to proceed with php code to delete the row. Could there be a problem with my $_GET['id'] and form method of POST? I thought I could mix them. I am trying to get the row id from the querystring to delete that row from database. my php: if(isset($_GET['id'])) { $stmt = $conn->stmt_init(); $sqlDelete = "delete from Brucella where Id = ?"; if($stmt->prepare($sqlDelete)){ $stmt->bind_param('i', $_GET['id']); $stmt->execute(); if ($stmt->affected_rows > 0 ) { header('Location: http://www.petlabsdiagnostics.com/brucella.php'); } my html: <form id="hemo" name="hemo" method="post" action=""> <table cellpadding="5" width="900" style="border-bottom:solid #000000 1px"> <tr> <td width="66"><a href="employee_workspace.php">Workspace</a></td> <td width="5">|</td> <td width="40"><a href="equine_test_list.php">Equine</a></td> <td width="5">|</td> <td width="40"><a href="feline_test_list.php">Feline</a></td> <td width="5">|</td> <td width="40"><a href="canine_test_list.php">Canine</a></td> <td width="5">|</td> <td width="40"><a href="canine_test_list.php">Canine</a></td> <td width="5">|</td> <td width="40"><a href="Library/brucella.php">Brucella</a></td> <td width="410" style="font-size:12px; text-align:right"><a href="logout.inc.php">Logout</a></td> </tr> </table> <div id = "mainContent"> <h2 class="title">Batch Brucella Canis Results</h2> <div id="client_info"> <br /> <table id="tb_header" cellpadding="1" cellspacing="2" width="700px" > <tr> <td width="175"><strong>Client Name</strong></td> <td width="175"><strong>Patient Name</strong></td> <td width="50"><strong>ID#</strong></td> <td width="50"><strong>Age</strong></td> <td width="50"><strong>Sex</strong></td> <td width="150"><strong>Doctor</strong></td> <td width="50"><strong>Results (pos/neg)</strong></td> </tr> <tr><td><input type="text" name="txt_client_name" id="txt_client_name" /></td> <td><input type="text" name="txt_patient_name" id="txt_patient_name"/></td> <td><input type="text" name="txt_id" id="txt_id" size="12" /></td> <td><input type="text" name="txt_age" id="txt_age" size="8" /></td> <td><select name="sel_sex"> <option value="">Select</option> <option value="Male">Male</option> <option value="Female">Female</option> </select></td> <td><input type="text" name="txt_doctor" id="txt_doctor" /></td> <td><select name="sel_results"> <option value="">Select</option> <option value="POS">POS</option> <option value="NEG">NEG</option> </select></td><td> <input type="submit" value="Submit" id="submit" class="btn" name="submit" /></td> </tr> <tr><td> </td></tr> <?php for($i = 0; $i < $numRows ; $i++) { $row = $result->fetch_assoc(); if($i % 2) { $RowColor="style='background-color:#ede4c5; border:solid 1px black;'"; } else { //$RowColor="style='background-color:#c2c290'"; $RowColor="style='background-color:#ffffff;border:solid 1px black;'"; }?> <tr><td <?php echo $RowColor ?>><?php echo $row['ClientName'] ?></td><td <?php echo $RowColor ?>><?php echo $row['PatientName'] ?></td><td <?php echo $RowColor ?>><?php echo $row['IDNumber'] ?></td><td <?php echo $RowColor ?>> <?php echo $row['Age'] ?></td><td <?php echo $RowColor ?>><?php echo $row['Sex'] ?></td><td <?php echo $RowColor ?>><?php echo $row['Doctor'] ?></td><td <?php echo $RowColor ?>><?php echo $row['Results'] ?></td><td><a href="brucella.php?id=<?php echo $row['Id'] ?>" onclick="warning();">Delete</a></td></tr> <?php } ?> my javascript: <script type="text/javascript"> function warning() { var r = confirm("Are you sure?"); if(r == true) { // do something return true; } else { // do something return false; } } </script>
  5. Your 12-1 timeslot does not satisfy the condition StartTime >= (12) as compared to the 11:30 in your post. The query is asking for both conditions to be satisfied with the AND. It does with 11-12 but not 12 -1.
×
×
  • 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.