Jump to content

ahaberman25

Members
  • Posts

    28
  • Joined

  • Last visited

Everything posted by ahaberman25

  1. You can use implode foreach($update_data as $field=>$data) { $update[] = '`' . $field . '` = \'' . $data . '\''; } mysql_query("UPDATE `admin` SET " . implode(', ', $update) . " WHERE `id` = $session_user_id");
  2. How come this wont work? $check = mysql_query($data); if (mysql_num_rows($check) > 0) { echo 'yes'; $res = mysql_query("SELECT * FROM $tbl_name WHERE id='$id'"); while($row = mysql_fetch_array($res) && $deal = mysql_fetch_array($check)) { echo "<p>You have earned " . $deal['name'] . " worth " . $deal['value'] ." dollars.</p>"; // Send notification email. $to = $row['email']; // this is your Email address $from = "andrew@websbydrew.com"; // this is the sender's Email address // $first_name = $_POST['first_name']; // $last_name = $_POST['last_name']; $subject = "You have earned a free ??? "; $subject2 = "Copy of reward notification"; $message = "You have earned " . $deal['name'] . " worth " . $deal['value'] ." dollars."; $message2 = "customer " . $row['name'] . " has earned a free " . $deal['name']; $headers = "From:" . $from; $headers2 = "From:" . $to; mail($to,$subject,$message,$headers); mail($from,$subject2,$message2,$headers2); // sends a copy of the message to the sender echo "Notification has been sent to " . $row['email']; // You can also use header('Location: thank_you.php'); to redirect to another page. // You cannot use header and echo together. It's one or the other. } it will only use $deal[]
  3. Figured it out thanks guys $data = "SELECT * FROM deals LEFT JOIN customers ON deals.admin_id = customers.admin_id WHERE deals.visits = customers.visits AND customers.id = $id"; $check = mysql_query($data); if (mysql_num_rows($check) > 0)
  4. I just need to use the query in a if statement to send an email. How do you do that?
  5. Well the check is only when someone is "checked in" so It should only send an email to the one person checking in defined by $id
  6. okay I think this is returning the proper data now. how do i do a if ($data === true){ } do i set the query true false like other queries? mysql_result(mysql_query("SELECT deals.email, deals.visits FROM deals LEFT JOIN customers ON deals.admin_id = customers.admin_id WHERE deals.visits = customers.visits"), 0) == 1) ? true : false;
  7. All I am trying to do is check 2 tables to see if column deals in table customers matches column deals in table deals where admin_id equals the same in both, than send an email if it is equal to each other. I am having issues trying to get this to work.
  8. ive updated it to this, i think its closer but not completely there. $admin_id = $user_data['id']; $data = "SELECT * FROM customer, deals WHERE `admin_id` = $admin_id"; $info = mysql_fetch_array( $data ); while($info = mysql_fetch_array( $data )) { if ($info['customer.visits'] == $info['deals.visits']) { $res = mysql_query("SELECT * FROM $tbl_name WHERE id='$id'"); while($row = mysql_fetch_array($res)) { echo "<p>You have earned " . $row['visits'] . " punch.</p>"; // Send notification email. $to = $row['email']; // this is your Email address $from = "andrew@websbydrew.com"; // this is the sender's Email address // $first_name = $_POST['first_name']; // $last_name = $_POST['last_name']; $subject = "You have earned a free ??? "; $subject2 = "Copy of reward notification"; $message = "You have " . $row['visits'] . " visits left"; $message2 = "id " . $row['id'] . " has " . $row['visits'] . " visits"; $headers = "From:" . $from; $headers2 = "From:" . $to; mail($to,$subject,$message,$headers); mail($from,$subject2,$message2,$headers2); // sends a copy of the message to the sender echo "Notification has been sent to " . $row['email']; // You can also use header('Location: thank_you.php'); to redirect to another page. // You cannot use header and echo together. It's one or the other. } } } }
  9. checkin.php <?php ob_start(); include 'core/init.php'; protect_page(); // get value of id in URL querystring $id = isset($_GET['id']) ? $_GET['id'] : null; $tbl_name = "customers"; // Table name if (!empty($id)) { // Retrieve user from database $sql = "SELECT * FROM $tbl_name WHERE id='$id'"; $result = mysql_query($sql); $user = mysql_fetch_array($result); if (empty($user)) { // You have no user, do something here to alert the user of this... echo '<h1>Your Membership is no longer active.</h1>' . PHP_EOL; } else { ?> <form name="form1" id="mainForm" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <input type="hidden" name="id" value="<?php echo $id; ?>"/> <input type="submit" value="CHECK IN"> </form> <?php } } if (!empty($_POST['id'])) { $id = $_POST['id']; $query = "UPDATE $tbl_name SET `visits` = `visits` + 1 WHERE id = '$id'"; mysql_query($query); $admin_id = $user_data['id']; $check_deal = "SELECT * FROM deals WHERE `admin_id` = $admin_id"; $check_visits = ""; $req_visits = "SELECT * FROM customers WHERE `admin_id` = $admin_id AND `visits` = $check_visits"; if ($visits = $check_visits) { $res = mysql_query("SELECT * FROM $tbl_name WHERE id='$id'"); while($row = mysql_fetch_array($res)) { echo "<p>You have earned " . $row['visits'] . " punch.</p>"; // Send notification email. $to = $row['email']; // this is your Email address $from = "andrew@websbydrew.com"; // this is the sender's Email address // $first_name = $_POST['first_name']; // $last_name = $_POST['last_name']; $subject = "You have earned a free ??? "; $subject2 = "Copy of reward notification"; $message = "You have " . $row['visits'] . " visits left"; $message2 = "id " . $row['id'] . " has " . $row['visits'] . " visits"; $headers = "From:" . $from; $headers2 = "From:" . $to; mail($to,$subject,$message,$headers); mail($from,$subject2,$message2,$headers2); // sends a copy of the message to the sender echo "Notification has been sent to " . $row['email']; // You can also use header('Location: thank_you.php'); to redirect to another page. // You cannot use header and echo together. It's one or the other. } } } ?> init.php <?php session_start(); //error_reporting(0); require 'database/connect.php'; require 'functions/general.php'; require 'functions/users.php'; if (logged_in() === true) { $session_user_id = $_SESSION['id']; $user_data = user_data($session_user_id, 'id', 'username', 'password', 'fname', 'lname', 'email', 'qr_img'); if (user_active($user_data['username']) === false) { session_destroy(); header('Location: index.php'); exit(); } } $errors = array(); ?>
  10. I have done an entire site out of php with several queries the logic on this is just driving me nuts.
  11. I need to check values from 2 different tables and make sure the admin_id match then do if (value1 = value2) { //do something } this is what I have so far. $admin_id = $user_data['id']; $visits = "SELECT * FROM customers WHERE `admin_id` = $admin_id AND `visits` == $check_visits"; $check_visits = "SELECT * FROM deals WHERE `visits` >= $visits AND `admin_id` = $admin_id"; if ($visits = $check_visits) { send email }
  12. Just launched a new ecom site King Soap. We sell all natural/vegan/goat milk soap on a subscription per month with incentives to invite people to get soap as well. We are in pre-launch and trying to find bugs and curtain things that are just not right on the site whether is formatting or code issues. There is php/jquery/javascript/and html. Let us know what you think. King Soap
  13. One of the issues might be that the code is in the wrong spot, which just putting the relevent code wouldnt do anything in this case. I put in all the information that I had for the issue. I have tried for 2 days going over the code over and over trying to figure out of I left something out or if something is incorrect. The downloads are checked for viruses and what not by the server so that shouldnt be an issue, plus HTML files cant carry anything. This site is full of stuck up people that wont answer a question unless you write a novel on what you did to fix the issue and the code snippet is 3 lines or less. There is 3 different sections of the page where the code is inserted and wouldnt make sense if I only posted a snippet of code. Ill find somwhere else and not help anyone else on here.
  14. I give up I help people when I can but I rarely get an answer on this site.
  15. I am trying to calculate BMI using a sample of code I have used before, It works in the version I previously had but when I try to apply it to some new code that I am making it is no longer working. Is there something im missing? Code is attached before and after before: berlinbmi.html after: berlin test.html Thanks for any help that can be given. berlinbmi.html berlin test.html
  16. I have done both of those, I cant find either or, nor can I find the option. I normally have no issue with this sort of thing but it is a way out of date addon.
  17. I work for a company using the google calendar plug-in (http://wordpress.org...alendar-plugin/) Although it has not been updated for awhile I am just trying to change the view in the backend from AGENDA to MONTH. If there is a way that someone out there knows of please let me know. I found the hard code when searching the HTML and could change it successfully there but I cannot figure out from the backend or php code where to make this change. I will upload the php code for the plug-in, hopefully it will help. Google_Calendar.php
  18. last question....is there an easy way to pass the var to a new window to display it using this function function results() { if ( total <= 6 ) { window.open('http://www.cre82morrow.com'); }else if ( total == 7 || total == 8 ) { window.open('http://www.apple.com'); }else { window.open('http://www.chrome.com'); } }; /* based on results opens a window */ each of the new windows are going to be local pages like results1.html
  19. Now its updating the total exponentially. Instead of the proper increments. if the var=0 is inside the function it works right? <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <link rel="stylesheet" type="text/css" href="css/style.css" /> <script src="js/jquery-1.8.2.js"></script> <script src="js/jquery.validate.js"></script> <script type="text/javascript">// <![CDATA[ var total = 0; function updateTotal(){ for(var i=1; i<10; i++){ if(!isNaN(jQuery('#txt'+i).val())){ total = (parseInt(total) + parseInt(jQuery('#txt'+i).val())); } } jQuery('#total').text(total); }; function handleChange(input) { if (input.value < 1) input.value = 0; if (input.value > 3) input.value = 3; }; function results() { if ( total <= 6 ) { window.open('http://www.cre82morrow.com'); }if ( total == 7 || total == 8 ) { window.open('http://www.apple.com'); }else { window.open('http://www.chrome.com'); } }; </script> <title>Epsworth Sleep Quiz</title> <style> input { float: right; } #quizcontainer { width: 600px; } </style> </head> <body id="main-content"> <div id="quizcontainer"> <!-- start form --> <form id="myform" onsubmit=""> <fieldset> <legend><h3>Take the Sleep Disorder Self-Quiz Epworth Sleepiness Scale</h3></legend> <p><span style="font-size: 10pt;">How likely are you to doze off or fall asleep in the following situations, in contrast to just feeling tired? This refers to your usual way of life in recent times. Even if you have not done some of these things recently, try to work out how they would have affected you. Use the following scale and enter the number for each situation.</span></p> <div> <p style="text-align: left; margin-left: 180px;"><strong>0</strong> = no chance of dozing<br /> <strong>1</strong> = slight chance of dozing<br /> <strong>2</strong> = moderate chance of dozing<br /> <strong>3</strong> = high chance of dozing</p> </div> <h3><span style="text-decoration: underline; float:left;">SITUATION</span></h3> <h3><span style="text-decoration: underline; float:right;">Chance of dozing</span></h3> <br /> <br /> Sitting and reading <input onchange="handleChange(this);" onkeyup="updateTotal();" type="text" class="qi" name="txt1" id="txt1" size="5" tabindex="1" value="0" /> <br /> <br /> Watching TV <input onchange="handleChange(this);" onkeyup="updateTotal();" type="text" class="qi" name="txt2" id="txt2" size="5" tabindex="2" value="0" /> <br /> <br /> Sitting inactive in a public place (Such as a theatre or a meeting) <input onchange="handleChange(this);" onkeyup="updateTotal();" type="text" class="qi" name="txt3" id="txt3" size="5" tabindex="4" value="0" /> <br /> <br /> As a passenger in a car for an hour without a break <input onchange="handleChange(this);" onkeyup="updateTotal();" type="text" class="qi" name="txt4" id="txt4" size="5" tabindex="5" value="0" /> <br /> <br /> Lying down to rest in the afternoon when time permits <input onchange="handleChange(this);" onkeyup="updateTotal();" type="text" class="qi" name="txt5" id="txt5" size="5" tabindex="6" value="0" /> <br /> <br /> Sitting and talking to someone <input onchange="handleChange(this);" onkeyup="updateTotal();" type="text" class="qi" name="txt6" id="txt6" size="5" tabindex="7" value="0" /> <br /> <br /> Sitting quietly after lunch without alcohol <input onchange="handleChange(this);" onkeyup="updateTotal();" type="text" class="qi" name="txt7" id="txt7" size="5" tabindex="8" value="0" /> <br /> <br /> In a car, while stopped for a few minutes in traffic <input onchange="handleChange(this);" onkeyup="updateTotal();" type="text" class="qi" name="txt8" id="txt8" size="5" tabindex="9" value="0" /> <br /> <br /> <div style="display: block clear:both;"> <div style="color: #00658f; font-size: 16px; float: left;"><strong>TOTAL SCORE</strong></div> </div> <div style="color: #00658f; font-size: 16px;"><strong><span name="span" id="total" style="float: right;"> </span></div> <div style="clear:both;"></div> <div class="form_element cf_button" style="float: right;"><input value="Calculate Score" name="submit" type="button" onclick="results();" /></div> </fieldset> </form> </div><!-- close quizcontainer --> <div id="result"> </div> </div><!-- close container --> </body> </html>
  20. How can I use a var established in another function: function updateTotal(){ var total = 0; for(var i=1; i<10; i++){ if(!isNaN(jQuery('#txt'+i).val())){ total = (parseInt(total) + parseInt(jQuery('#txt'+i).val())); } } jQuery('#total').text(total); }; function handleChange(input) { if (input.value < 1) input.value = 0; if (input.value > 3) input.value = 3; }; function results() { if ( total <= 6 ) { window.open('http://www.cre82morrow.com'); }if ( total == 7 || total == 8 ) { window.open('http://www.apple.com'); }else { window.open('http://www.chrome.com'); } }; The var total used in updateTotal() I am trying to use it again in function results, for some reason its not grabbing the var again. It only works if I put the if statement in the original function updateTotal()
  21. I should have posted the entire snippet of code as well sorry sleep.html
  22. Ok so I did some homework and I figured out most of my previous issue, now I am down to a little problem that I am having issues with. I am using the code: <script type="text/javascript"> function updateTotal(){ var total = 0; for(var i=1; i<10; i++){ if(!isNaN(jQuery('#txt'+i).val())){ total = (parseInt(total) + parseInt(jQuery('#txt'+i).val())); } } jQuery('#total').html(total); if (total <= 6 ) { document.write("<p>Congratulations, you are getting enough sleep!"); } else if (total == 7 || total == { document.write("<p>Your score is average</p>"); } else { document.write("<p>Seek the advice of a sleep specialist without delay</p>"); } } </script> <script> $(document).ready(function() { $('form input:text').change(function() { $('#total').val(this.value).text(total); }); }); // end ready </script> and the image posted is the output. I need it to add up all the numbers in the text fields and spit them out. Right now it only wants to write that its a <span> tag.
  23. it is basically this test http://www.stanford.edu/~dement/epworth.html but i need to make it interactive where the person will input the number that corosponds with their answer and then at the end it will at it up and give the correct answer.
×
×
  • 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.