Jump to content

dapcigar

Members
  • Posts

    58
  • Joined

  • Last visited

Everything posted by dapcigar

  1. oh really? so how do i do that? thanks in advance
  2. Yeah you are right. i named it $actual instead of $spent.. Thanks
  3. Am trying to get a current price, add it to what is in the database and update the table with the new value. Every time i do it, it won't do the addition but update the table with the current price. Please, what am i doing wrong? $sql2 = mysql_query("SELECT * FROM pbudget WHERE project_name = '$project' "); $budget = mysql_fetch_array($sql2); $actual = $budget['actual'] ; $actual = $budget['spent'] ; $tot = ($spent + $amount); $final = ($actual - $amount); //$final = ($actual + $amount); $r = mysql_query("UPDATE pbudget SET actual = '$final', spent ='$tot' WHERE project_name = '$project'") or die(mysql_error()); $que = mysql_query("UPDATE budget SET actual = '$final', spent ='$tot' WHERE category = '$cat'") or die(mysql_error());
  4. Nevermind, i fixed it. incase someone elese needs the solution MONTH(date) = MONTH(CURRENT_DATE)
  5. Hello all, Am trying to calculate some data and display the result of the current month in a chart form. i just don't know how to get the current month. this is not working.. <?php include('mysql_connect.php'); $date = 'MONTH(CURRENT_DATE())'; $status = 'paid'; //mysql_select_db("hyprops", $con); $query = mysql_query("SELECT sum(amount) 'amount', department FROM requisition WHERE status = '$status' AND date='$date' "); $category = array(); $category['name'] = 'department'; //$series1 = array(); //$series1['name'] = 'actual'; $series2 = array(); $series2['name'] = 'amount'; //$series3 = array(); //$series3['name'] = 'Highcharts'; while($r = mysql_fetch_array($query)) { $category['data'][] = $r['department']; // $series1['data'][] = $r['actual']; $series2['data'][] = $r['amount']; // $series3['data'][] = $r['highcharts']; } $result = array(); array_push($result,$category); //array_push($result,$series1); array_push($result,$series2); //array_push($result,$series3); print json_encode($result, JSON_NUMERIC_CHECK); mysql_close($con); ?> Please how can i solve this issue? Thanks in advance
  6. I was able to upload the files to the DB but now am trying to retrieve it from the table but it's not working. my code below <?php while($row = mysql_fetch_array($query1)) { (list($id, $name) = mysql_fetch_array($query1)); echo"<tr>"; echo"<td> $row[category]</td>"; echo"<td> $row[description]</td>"; echo"<td> $row[amount]</td>"; ?> <td> <a href="approved_req.php?id=<?php echo urlencode($id);?>" ><?php echo urlencode($name);?></a> </td> <?php echo"<td> $row[status]</td>"; ?> <td><a class="btn btn-success" <?php echo" href='invoice.php?id=$row[id]'> Pay </a></td>";?></a> <?php echo"</tr>"; } // } ?> </table> <?php if(isset($_GET['id'])) { // if id is set then get the file with the id from database //$con = mysql_connect('localhost', 'root', '') or die(mysql_error()); //$db = mysql_select_db('test', $con); $id = $_GET['id']; $query = "SELECT name, type, size, content " . "FROM requisition WHERE id = '$id'"; $result = mysql_query($query) or die('Error, query failed'); list($name, $type, $size, $content) = mysql_fetch_array($result); header("Content-length: $size"); header("Content-type: $type"); header("Content-Disposition: attachment; filename=$name"); ob_clean(); flush(); echo $content; mysql_close(); exit; } ?> Thanks in advance
  7. thanks guys but nothing seems to be working. Please, is there anyway i could send just make it work? any syntax that would point me to the right direction? Am a newbie
  8. Hello all, Am trying to display records from mysql using HIghchart but for some reasons, it is not bringing out any output, please help me look into my codes. :::::::::::::::::::::::::::::::::::::data1.php :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: <?php include('mysql_connect.php'); $dept = $_POST['department']; //include('mysql_connect.php'); $stat = 'paid'; $result = mysql_query ("select category, amount, actual from budget where department = '$dept' GROUP BY category ") or die(mysql_error()); $category = array(); $category['name'] = 'category'; $series1 = array(); $series1['name'] = 'actual'; $series2 = array(); $series2['name'] = 'amount'; //$series3 = array(); //$series3['name'] = 'Highcharts'; while($r = mysql_fetch_array($query)) { $category['data1'][] = $r['category']; $series1['data1'][] = $r['actual']; $series2['data1'][] = $r['amount']; // $series3['data'][] = $r['highcharts']; } $result = array(); array_push($result,$category); array_push($result,$series1); array_push($result,$series2); //array_push($result,$series3); print json_encode($result, JSON_NUMERIC_CHECK); header("Location: view_dept.php"); mysql_close($con); ?> :::::::::::::::::::::::::::::::::::::::: view_dept.php ::::::::::::::::::::::::::::::::: <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function() { var options = { chart: { renderTo: 'container', type: 'column', marginRight: 130, marginBottom: 25 }, title: { text: 'Chart for Department', x: -20 //center }, subtitle: { text: '', x: -20 }, xAxis: { categories: [] }, yAxis: { title: { text: 'Amount' }, plotLines: [{ value: 0, width: 1, color: '#808080' }] }, tooltip: { formatter: function() { return '<b>'+ this.series.name +'</b><br/>'+ this.x +': '+ this.y; } }, legend: { layout: 'vertical', align: 'right', verticalAlign: 'top', x: -10, y: 100, borderWidth: 0 }, series: [] } $.getJSON("data1.php", function(json) { options.xAxis.categories = json[0]['data1']; options.series[0] = json[1]; options.series[1] = json[2]; //options.series[2] = json[3]; chart = new Highcharts.Chart(options); }); }); </script> <script src="http://code.highcharts.com/highcharts.js"></script> <script src="http://code.highcharts.com/modules/exporting.js"></script> </head> <body> <div id="container" style="min-width: 400px; height: 400px; margin: 0 auto"></div> </body> thanks in advance
  9. I want to add the result of a query to another table but every time i click on it, it only saves the first record, please help me check out my code thanks <?php // hide errors error_reporting(0); /* Include the Pear::Pager file */ include('mysql_connect.php'); //include of db config file include ('paginate.php'); //include of paginat page $per_page = 5; // number of results to show per page $result = mysql_query("SELECT * FROM users"); $total_results = mysql_num_rows($result); $row=mysql_fetch_assoc($result); $total_pages = ceil($total_results / $per_page);//total pages we going to have //while ($row=mysql_fetch_assoc($result)){ //-------------if page is setcheck------------------// if (isset($_GET['page'])) { $show_page = $_GET['page']; //it will telles the current page if ($show_page > 0 && $show_page <= $total_pages) { $start = ($show_page - 1) * $per_page; $end = $start + $per_page; } else { // error - show first set of results $start = 0; $end = $per_page; } } else { // if page isn't set, show first set of results $start = 0; $end = $per_page; } // display pagination $page = intval($_GET['page']); $tpages=$total_pages; if ($page <= 0) $page = 1; ?> <?php // hide errors error_reporting(0); $reload = $_SERVER['PHP_SELF'] . "?tpages=" . $tpages; echo '<div class="pagination"><ul>'; if ($total_pages > 1) { echo paginate($reload, $show_page, $total_pages); } echo "</ul></div>"; // display data in table echo "<table class='table table-bordered'>"; echo "<thead><tr><th>First Name</th> <th>Last Name</th> <th>Department</th> <th>Status</th></tr></thead>"; // loop through results of database query, displaying them in the table for ($i = $start; $i < $end; $i++) { // make sure that PHP doesn't try to show results that don't exist if ($i == $total_results) { break; } // echo out the contents of each row into a table echo "<tr> "; echo '<td>' . mysql_result($result, $i, 'firstname') . '</td>'; echo '<td>' . mysql_result($result, $i, 'lastname') . '</td>'; echo '<td>' . mysql_result($result, $i, 'department') . '</td>'; echo ' <td><a href="add_team.php?id='.$row['id'].'"> Add Team Member </a></td>'; } echo "</tr>"; // } // close table> echo "</table>"; // pagination ?>
  10. Am trying to import a csv file into mysql. below is the code am using. <?php //connect to the database include('mysql_connect.php');//select the table // if ($_FILES[csv] > 0) { //get the csv file $file = $_FILES[csv][tmp_name]; $handle = fopen($file,"r"); //loop through the csv file and insert into database do { if ($data[0]) { mysql_query("INSERT INTO requisition (department, contact_last, contact_email) VALUES ( '".addslashes($data[0])."', '".addslashes($data[1])."', '".addslashes($data[2])."' ) "); } } while ($data = fgetcsv($handle,1000,",","'")); // //redirect header('Location: import.php?success=1'); die; } ?> <!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=iso-8859-1" /> <title>Import a CSV File with PHP & MySQL</title> </head> <body> <?php if (!empty($_GET[success])) { echo "<b>Your file has been imported.</b><br><br>"; } //generic success notice ?> <form action="" method="post" enctype="multipart/form-data" name="form1" id="form1"> Choose your file: <br /> <input name="csv" type="file" id="csv" /> <input type="submit" name="Submit" value="Submit" /> </form> </body> </html> ........................................................................................................................................... On page load, it gives some erros Notice: Use of undefined constant csv - assumed 'csv' in C:\wamp\www\orango\upload_data.php on line 7 Notice: Use of undefined constant size - assumed 'size' in C:\wamp\www\orango\upload_data.php on line 7 Notice: Undefined index: csv in C:\wamp\www\orango\upload_data.php on line 7 Notice: Use of undefined constant success - assumed 'success' in C:\wamp\www\orango\upload_data.php on line 43 I try to ignore the errors to see if it would work but it didn't save in the DB. please help me out
  11. Have actually tried this mailer on localhost and it worked perfectly. Now am trying to use it on online but it's giving this error SMTP-> ERROR: Failed to connect to server: Connection timed out (110) SMTP -> ERROR: Could not connect to SMTP host. Mailer Error: SMTP Error: Could not connect to SMTP Host. please how do i fix this? include "classes/class.phpmailer.php"; // include the class name $mail = new PHPMailer(); // create a new object $mail->IsSMTP(); // enable SMTP $mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only $mail->SMTPAuth = true; // authentication enabled $mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail $mail->Host = "smtp.gmail.com"; $mail->Port = 465; // or 587 $mail->IsHTML(true); $mail->Username = "hypropsict@gmail.com"; $mail->Password = "hyprops123"; $mail->SetFrom("hypropsict@gmail.com"); $mail->Subject = "Requisition Processed"; $mail->Body = "<b>Hello $firstname, your requisition has been processed and Approved.. <br/><br/>Come to the Account department to recieve your $text . <br/> Thank You </b>"; $mail->AddAddress($email); if(!$mail->Send()){ echo "Mailer Error: " . $mail->ErrorInfo; }
  12. Yeah, it worked.. thanks.. Ama ctually a newbie.. Will go over some tutorials on PDO.. Thanks again
  13. Am trying to update a table called "budget_request" and also inserting the data of that table into another table called "Budget". The Update works but it is not inserting into the other table. please help me out.. check my code below <?php $id = $_GET['id']; ?> <?php include('mysql_connect.php'); $q = mysql_query("UPDATE budget_request SET status = 'Approved' WHERE id = '$id'") or die(mysql_error()); // send the details to the budget database $query = mysql_query("SELECT * FROM budget_request WHERE id = '$id' ") or die (mysql_error()); $dat = mysql_fetch_array($query); $department = $dat['department']; $amount = $dat['amount']; // Add the data to the Budget DB $que = (" INSERT INTO budget (id, department, amount, actual) VALUES ( ' ','$department', '$amount', '$amount')" ) or die(mysql_error()); header("Location: add_budget.php"); ?>
  14. Phew!! that worked perfectly.. thanks
  15. Am trying to query my DB and use the result to create a chart. code pasted below; <?php $date = $_POST['Date']; //$date = '25/05/2010'; $date = str_replace('/', '-', $date); $new_date = date('Y-m-d', strtotime($date)); //echo $new_date; include('mysql_connect.php'); // Settings for the graph include "libchart/classes/libchart.php"; $chart = new VerticalBarChart(600, 520); $chart = new VerticalBarChart(); $dataSet = new XYDataSet(); $query1 = mysql_query ("select * from requisition where date = '$new_date' ") or die(mysql_error()); while($row = mysql_fetch_array($query1)) { //$amt = $row['amount']; // check each department and sum up all their data if ( $row['department'] = "ICT") { $total1 = $total1 + $row['amount']; //exit; } else if ( $row['department'] = "Supply Chain/ Asset Integrity") { $total2 = $total2 + $row['amount']; //exit; } else if ( $row['department'] = "Account") { $total3 = $total3 + $row['amount']; //exit; } else if ( $row['department'] = "Admin / Services ") { $total4 = $total4 + $row['amount']; //exit; } else if ( $row['department'] = "Business Development") { $total5 = $total5 + $row['amount']; //exit; } else if ( $row['department'] = "Manpower") { $total6 = $total6 + $row['amount']; //exit; } else if ( $row['department'] = "Maintenance") { $total7 = $total7 + $row['amount']; //exit; } else if ( $row['department'] = "HR") { $total8 = $total8 + $row['amount']; //exit; } else if ( $row['department'] = "Marine Logistics") { $total9 = $total9 + $row['amount']; //exit; } //$dataSet->addPoint(new Point($row['department'], $row['amount'])); } $dataSet->addPoint(new Point("ICT", $total1)); $dataSet->addPoint(new Point("Supply Chain", $total2)); $dataSet->addPoint(new Point("Account", $total3)); $dataSet->addPoint(new Point("Admin / Services", $total4)); $dataSet->addPoint(new Point("Business Development", $total5)); $dataSet->addPoint(new Point("Manpower", $total6)); $dataSet->addPoint(new Point("Maintenance", $total7)); $dataSet->addPoint(new Point("HR", $total8)); $dataSet->addPoint(new Point("Logistics", $total9)); $chart->setDataSet($dataSet); $chart->setTitle("Report By Date - $date"); $chart->render("generated/date.png"); header("Location: view_date.php"); //header ('lcoation : '); ?> ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: When i Try to view the result, it only displays the first one in the IF statement. please, what am i doing wrong? Thanks in advance
  16. Yeah, had to use a mail server and it worked.. was thinking i could do that without the mail server but i was wrong.. thanks for your help
  17. After trying to display all errors, i got this Warning: mail(): Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\wamp\www\hyprops\staff\staff\rec_proc.php on line 229
  18. Am trying to get an email address from the DB and send an alert but it's not working.. $search3 = mysql_query("SELECT email FROM users WHERE department = '$department' AND (position = '$position')") or die(mysql_error()); $acct1 = mysql_fetch_array($search3); $email = $acct1['email']; $to = $email; $subject = 'New Requisition Alert'; $message = 'You have a new message'; $headers = 'From: server@test.com' . "\r\n" . 'Reply-To: admin@test.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $message, $headers);
  19. Nevermind... Found the problem.. it was in the DB.. some of the passwords have widespaces..
  20. Am trying to redirect a user based on their login details. it works fine till it get to a particular department.. "Marine Logistics". when i try to log in with ID of someone in that department, it redirects to invalid login page. the code below. what am i missing? $sql1 = mysql_query("SELECT * FROM users WHERE username = '$username' AND password = '$password'"); $data = mysql_fetch_array($sql1); $department = $data['department']; if ($department== "Admin") { header("Location: admin/dash_admin.php"); exit; } else if ($department == "ICT" ) { if ($data['position'] == "HOD") { header("Location: ICT/HOD/hod_dash.php"); exit; } else{ header("Location: ICT/staff/staff_dash.php"); exit; } exit; } // check if user is in account department else if ($department == "Account" ) { if ($data['position'] == "HOD") { header("Location: account/HOD/account_dash.php"); exit; } else { header("Location: account/staff/staff_dash.php"); exit; } exit; } //check if user is in Supply chain/ Asset Integrity department else if ($department == "Supply Chain/ Asset Integrity" ) { if ($data['position'] == "HOD") { header("Location: supply_chain/HOD/hod_dash.php"); exit; } else{ header("Location: supply_chain/staff/staff_dash.php"); exit; } exit; } // check if user is in manpower department else if ($department == "Manpower" ) { if ($data['position'] == "HOD") { header("Location: manpower/HOD/hod_dash.php"); exit; } else{ header("Location: manpower/staff/staff_dash.php"); exit; } exit; } // check if user is in Business Development Department else if ($department == "Business Development" ) { if ($data['position'] == "HOD") { header("Location: business_development/HOD/hod_dash.php"); exit; } else{ header("Location: business_development/staff/staff_dash.php"); exit; } exit; } // check if user is in HR else if ($department == "HR" ) { if ($data['position'] == "HOD") { header("Location: HR/HOD/hod_dash.php"); exit; } else{ header("Location: HR/staff/staff_dash.php"); exit; } exit; } //check if user is in Marine Logistics Department else if ($department== "Marine Logistics" ) { if ($data['position'] == "HOD") { header("Location: logistics/HOD/hod_dash.php"); exit; } else{ header("Location: logistics/staff/staff_dash.php"); exit; } exit; } //check if user is from Maintenance Department else if ($department == "Maintenance" ) { if ($data['position'] == "HOD") { header("Location: Maintenance/HOD/hod_dash.php"); exit; } else{ header("Location: Maintenance/staff/staff_dash.php"); exit; } exit; } //check if user is from Admin/services Department else if ($department == "Admin / Services" ) { if ($data['position'] == "HOD") { header("Location: admin_services/HOD/hod_dash.php"); exit; } else{ header("Location: admin_services/staff/staff_dash.php"); exit; } exit; } } else{ header("Location: indexWrongPassOrUser.php"); exit; }
  21. Please i need help with something else.. Am loading data from the database to a dropdown list. but when i want to save it back to the DB, it is saving the ID and not the name. here is the HTML form <form class="form-horizontal" method="post" action="rec_proc.php?process=true"> <fieldset> <legend>Requisition Form</legend> <div class="control-group"> <label class="control-label" for="focusedInput">First Name:</label> <div class="controls"> <span class="input-xlarge uneditable-input"><?php echo $firstname ?></span> </div> </div> <div class="control-group"> <label class="control-label" for="focusedInput">Department :</label> <div class="controls"> <span class="input-xlarge uneditable-input"><?php echo $department ?></span> </div> </div> <div class="control-group"> <label class="control-label" for="selectError">Category :</label> <div class="controls"> <select id="selectError" data-rel="chosen" name="cat_name"> <?php while($row = mysql_fetch_array($select)){ extract($row);?> <option value="<?php echo $id;?>"><?php echo $cat_name; ?></option> <?php }?> </select> </div> </div> <div class="control-group"> <label class="control-label" for="focusedInput">Description :</label> <div class="controls"> <input class="input-xlarge focused" id="focusedInput" type="text" name="description" value=""> </div> </div> <div class="control-group"> <label class="control-label" for="appendedInput">Amount :</label> <div class="controls"> <div class="input-append"> <input id="appendedInput" size="16" type="text" name="amount"><span class="add-on">.00</span> </div> <span class="help-inline">Enter Amount</span> </div> </div> <div class="control-group"> <div class="controls"></div> </div> <div class="form-actions"> <button type="submit" class="btn btn-primary">Send Requisition</button> <button type="reset" class="btn">Cancel</button> </div> </fieldset> </form> ...................................................................................................................... Here is the code <?php if(isset($_GET['process'])){ $cat_name = $_POST['cat_name']; } $description = $_POST['description']; $amount= $_POST['amount']; $date = date('Y-m-d'); $status = "Pending "; include ('mysql_connect.php'); //insert into DB $sql = mysql_query("INSERT INTO requisition ( id, department, category, description, amount, date, username, firstname, lastname, status) VALUES ( NULL, '$department', '".$cat_name."', '$description', '$amount','$date', '$user', '$firstname', '$lastname', '$status' )") or die(mysql_error()); header ( 'location: staff_dash.php'); ?> i want it to save the category and not the ID.. how can i correct this? Thanks in advance
  22. Am loading data from the database to a dropdown list. but when i want to save it back to the DB, it is saving the ID and not the name. here is the HTML form <form class="form-horizontal" method="post" action="rec_proc.php?process=true"> <fieldset> <legend>Requisition Form</legend> <div class="control-group"> <label class="control-label" for="focusedInput">First Name:</label> <div class="controls"> <span class="input-xlarge uneditable-input"><?php echo $firstname ?></span> </div> </div> <div class="control-group"> <label class="control-label" for="focusedInput">Department :</label> <div class="controls"> <span class="input-xlarge uneditable-input"><?php echo $department ?></span> </div> </div> <div class="control-group"> <label class="control-label" for="selectError">Category :</label> <div class="controls"> <select id="selectError" data-rel="chosen" name="cat_name"> <?php while($row = mysql_fetch_array($select)){ extract($row);?> <option value="<?php echo $id;?>"><?php echo $cat_name; ?></option> <?php }?> </select> </div> </div> <div class="control-group"> <label class="control-label" for="focusedInput">Description :</label> <div class="controls"> <input class="input-xlarge focused" id="focusedInput" type="text" name="description" value=""> </div> </div> <div class="control-group"> <label class="control-label" for="appendedInput">Amount :</label> <div class="controls"> <div class="input-append"> <input id="appendedInput" size="16" type="text" name="amount"><span class="add-on">.00</span> </div> <span class="help-inline">Enter Amount</span> </div> </div> <div class="control-group"> <div class="controls"></div> </div> <div class="form-actions"> <button type="submit" class="btn btn-primary">Send Requisition</button> <button type="reset" class="btn">Cancel</button> </div> </fieldset> </form> ...................................................................................................................... Here is the code <?php if(isset($_GET['process'])){ $cat_name = $_POST['cat_name']; } $description = $_POST['description']; $amount= $_POST['amount']; $date = date('Y-m-d'); $status = "Pending "; include ('mysql_connect.php'); //insert into DB $sql = mysql_query("INSERT INTO requisition ( id, department, category, description, amount, date, username, firstname, lastname, status) VALUES ( NULL, '$department', '".$cat_name."', '$description', '$amount','$date', '$user', '$firstname', '$lastname', '$status' )") or die(mysql_error()); header ( 'location: staff_dash.php'); ?> i want it to save the category and not the ID.. how can i correct this? Thanks in advance
  23. Yeah.. that solved the problem.. thanks a lot..
×
×
  • 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.