Jump to content

dalton6275

New Members
  • Posts

    6
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

dalton6275's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I have an 'insert into database' code which i am trying to make the table the information is inserted to dependant on a URL variable i am carrying across from the previous page. My code is [code] if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {   $insertSQL = sprintf("INSERT INTO %s (Monthref, percentage) VALUES (%s, %s)",                        GetSQLValueString($_POST['sla'], "text"),                        GetSQLValueString($_POST['month'], "date"),                        GetSQLValueString($_POST['slapercent'], "int")); [/code] but it is not liking the 1st %s code in the 'INSERT INTO %s' Anyone know how i can remedy this???
  2. Hello Everyone, I am currently programming a online reporting system and I am trying to minus a total outage percentage from 100 but im not doing something correctly. The code i have is below. [code] <?php $colname_Recordset1 = "1"; if (isset($_GET['sla'])) {   $colname_Recordset1 = (get_magic_quotes_gpc()) ? $_GET['sla'] : addslashes($_GET['sla']); } mysql_select_db($database_Dalton, $Dalton); $query_Recordset1 = sprintf("SELECT * FROM incidents WHERE SLA = '%s'", $colname_Recordset1); $Recordset1 = mysql_query($query_Recordset1, $Dalton) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); $totalRows_Recordset1 = mysql_num_rows($Recordset1); ?> #sets up the recordset in Dreamweaver <?php do { ?>   <tr>     <td> <a href="fypincidentedit.php?recordID=<?php echo $row_Recordset1['ID_NO']; ?>"> <?php echo $row_Recordset1['ID_NO']; ?> </a> </td>     <td> <?php echo $row_Recordset1['severity']; ?> </td>     <td> <?php echo $row_Recordset1['title']; ?> </td>     <td> <?php echo $row_Recordset1['SLA']; ?> </td>     <td> <?php echo $row_Recordset1['AccentureResp']; ?> </td> # creates table showing all the rows from the query.      <? if ($row_Recordset1['AccentureResp'] = 'N') {           $outagecalc = $row_Recordset1['UNIX_TIMESTAMP(outage_end)'] - $row_Recordset1['UNIX_TIMESTAMP(outage_start)'];           $outagetime = $outagecalc / 60;         $outageeffect = ($outagecalc / 42320) * $row_Recordset1['percentage'];         $totouttime = $totouttime + $outageeffect;         };   ?> # calculations that i am trying to perform on each row in the table that has AccentureResp field set to 'N'.   <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?> </tr></table> [/code] What i am trying to do is set the calculations to perform on each row that has AccentureResp = 'N', but i dont think that i have the correct code for performing the loop as it is telling me that $totoutime = 0 everytime which lead me to believe that the loop is not working correctly. Anyone know where i am going wrong???
  3. yep, DATETIME format in MySQL. Only problem is i need the difference in minutes. Can i turn these datetimes into a number then perform the calculation like that?
  4. ah, but im not sure if thats the entire problem. I cant seem 2 be able to perform any kind of date calculation from these mysql sources to find the difference in minutes. Ill read the page and see if that helps but i think i need to edit the date values somehow!
  5. Hey everyone, Im trying to perform a date calculation to find the difference in minutes between 2 dates in MySQL. currently i have: [code] <?php while ($row=mysql_fetch_array($Recordset1)) { $outagetime = $row_Recordset1['outage_end'] - $row_Recordset1['outage_start']; echo number_format($outagetime, 3); ?> [/code] But i keep getting the result 0.000. I tried adding more decimals but it doesnt seem to be working and iv checked the 2 variables and there is clearly 90 minutes difference but the system keeps reporting 0.000. Im baffled. Any ideas
  6. Hey everyone, Just wondering if any1 can help me with this MySQL/PHP programming problem i have. I have a value in 2 fields in a MySQL table that i wish to perform calculations on in a PHP table. The first is 'outagestart' and 'outagefinish' - and i simply want to perform a calculation to find the difference and store it in a variable. The second is that i wish to perform another sum on this new variable by dividing it by the amounts of minutes in a month and then multiplying it by variable $percentofusers. Simple enuff if i had 1 figure, but i am using the SQL statement: "SELECT * FROM incidents WHERE AccentureResp = 'N'"; So i need the calculations to be performed on each individual row returned by this dynamic query and then store the total figure in a seperate variable. Phew! Complicated enough for me to explain. Any1 have any ideas how i can sort this???? Thanks in advance for any help offered
×
×
  • 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.