Jump to content

RomeoX

New Members
  • Posts

    7
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

RomeoX's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Dear cags, thank you very much for your reply, if you don't mind sir to help me in fixing the code it would be great. thank you for ur coopeartion.
  2. Please guys I really need help. Home someone can help me.
  3. Hi everybody, Actually I stuck in updating a date field in my page that I don't know why it doesn't want to update. I'm retrieving a data from my DB and I I made one column has Textfield that I enter the new date so I press the submit and I want it to be updated. I named the Textfield name="retur[]" because as the data coming from DB so I used array but can't update. I'm also using CheckBox so I can point to which record I want to update. this is my code in my first page: <?php error_reporting (E_ALL ^ E_NOTICE); ?> <?php include 'functions.php'; $r= @mysql_query("SELECT * FROM bookoutonloan"); $count=@mysql_num_rows($r); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Return Page</title> <style type="text/css"> .style2 { color:#FFF; font-weight: bold; } .style4 { color:#999; font:Tahoma, Geneva, sans-serif} </style> <link href="my.css" rel="stylesheet" type="text/css" /> </head> <form id="form1" name="form1" action="returnbook6.php" method="POST" > <center> <table width="99%" height="97" border="1" bordercolor="#BECDBF"> <tr class="style2"> <td width="6%" height="27" bgcolor="#92B0D1">Borrow ID</td> <td width="6%" bgcolor="#92B0D1">Stud ID</td> <td width="6%" bgcolor="#92B0D1">Book ID</td> <td width="11%" bgcolor="#92B0D1">User ID</td> <td width="9%" bgcolor="#92B0D1">Library ID</td> <td width="7%" bgcolor="#92B0D1">Date Loaned</td> <td width="9%" bgcolor="#92B0D1">datereturned</td> <td width="6%" bgcolor="#92B0D1">Amount of Fine</td> <td width="4%" bgcolor="#92B0D1">check for delete</td> </tr> <?php while($row=mysql_fetch_array($r , MYSQL_ASSOC)) { // extract($row) ?> <tr> <td class="style4"><?php echo $row['borrowid']; ?></td> <td class="style4"><?php echo $row['stid']; ?></td> <td class="style4"><?php echo $row['bookid']; ?></td> <td class="style4"><?php echo $row['userid']; ?></td> <td class="style4"><?php echo $row['libraryid']; ?></td> <td class="style4"><?php echo $row['dateborrow']; ?></td> <td class="style4"><input name="retur[]" type="text" size="15" id="retur[]" /></td> <td class="style4">SR <?php echo $row['amountoffine']; ?></td> <td><input name="c[]" type="checkbox" id="c[]" value="<?php echo $row['borrowid']; ?>" /></td> </tr> <?php //value="<?php echo $row['datereturned']; " } ?> </table> <center> <p> <input name="checkfine" type="submit" value="Check For Fine" /> </p> </form> <body> <center> <p> </p> </center> </body> </html> My second page code <?php include 'functions.php'; $submit = $_POST['checkfine']; $returned = $_POST["retur"]; if (isset($submit)) { for($i=0;$i<count($_POST['c']);$i++) { for($b=0; $b<count($_POST['retur']); $b++) { $query = ("UPDATE bookoutonloan SET datereturned = '".$_POST['retur'][$b]."' where borrowid = '".$_POST['c'][$i]."' ") ; echo $query; $final = mysql_query($query) or die(mysql_error()); } } } ?> The result that output from these code that I tested on four records that I get from DB. The first three records I found that this is the output, borrowid 15-16-17 UPDATE bookoutonloan SET datereturned = '2010-04-04' where borrowid = '15' UPDATE bookoutonloan SET datereturned = '' where borrowid = '15' But when I enter the date on borrow=14 the last record I found that I got the output result opposite than the previous one, which I don't know why it happens like that and I got two updates one so the previous code of output, the second update remove the date so I found that the DB is empty but this last record the first update is empty and the second update is correct which entered and it will be set in the DB: UPDATE bookoutonloan SET datereturned = '' where borrowid = '14' UPDATE bookoutonloan SET datereturned = '2010-04-04' where borrowid = '14' Is there any mistake please help to fix my code and direct me. Thank you very much
  4. I really need your help guys. I need your brainstorm. I need a solution for my problem. I'm asking small editing coding. So please help me if you don't mind. Thanks
  5. Hi there, Actually my problem is I want to get the date difference if date return of book more than one month add $10 if not leave the amountoffine to $0 and if the loaner took the book and return it after 3 months I want the code to add by monthly $10 so after 3 months I want the result to be $30. Here is the code <?php include 'functions.php'; $submit = $_POST["checkfine"]; $borrowid = $_POST["borrowid"]; $bookid = $_POST["bookid"]; $returned = $_POST["returned"]; $datereturned = $_POST['datereturned']; if ($datereturned > 30 Days)) { $query = mysql_query("UPDATE bookoutonloan SET amountoffine = (amountoffine + 10) WHERE DATE_ADD(datereturned , INTERVAL 1 MONTH )> CURDATE() AND borrowid = '$borrowid'"); die("The Record of Fine Has Been Updated"); } ?> So I want to add an amount of Fine like if someone loan a book and return it after 1 month I want to add $10 in the column of amountoffine actually I stuck here. This is my Table in mysql as well CREATE TABLE `library`.`bookoutonloan` ( `borrowid` INT( 12 ) NOT NULL AUTO_INCREMENT PRIMARY KEY , `stid` INT( 12 ) NOT NULL, `bookid` INT( 12 ) NOT NULL, `userid` INT( 12 ) NOT NULL, `libraryid` INT( 12 ) NOT NULL, `dateborrow` DATE NOT NULL , `datedueforreturn` DATE NOT NULL , `datereturned` DATE NOT NULL , `amountoffine` INT( 12 ) ) ENGINE = MYISAM ; I want to check is "databorrow" larger than one month, if it's more than one month set $10 if not leave the column $0. But the code is adding $10 every time that I refresh the page and also there is an error in this code when I used IF condition. so if I have "dateborrow" = 2010-01-12 it should not add $10 in case if today is 2010-01-26 if the "dateborrow" =2009-12-04 it should add $10 and so one even if the "dateborrow" =2009-08-10 it should be now $50 so every month it will increase $10 so it will be now $50 I hope you get what I want and clear. Thanks
×
×
  • 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.