Jump to content

cutielou22

Members
  • Posts

    81
  • Joined

  • Last visited

Posts posted by cutielou22

  1. Well, I want to make it so a user can have there own events and they show up in the calendar. The calendar you can "flip" through the months to look at the months coming up. I want the days of events to be highlighted a certain color.

    Since you say my " ajax code sends the date": then how do I grab that information and compare it with the calendar? That is what I don't get.

  2. So I added data-day, but that must up all dates in the calendar. What would data-day be linked to - I have nothing called that right now.

    Is the ajax I have now correct then (and in the correct spot)? - is json_encode() correct also? I am completely new to this. Just using Google. 

     

  3. Okay. So I have done only ajax forms. So I am getting a little confused while researching . . . what I have added:

    Underneath:

    generateCalendar(currentDate);

    I added (still in the same function as generateCalendar - not sure if correct either):

       $.ajax({
                type: "POST",
                dataType: 'json',
                url: "cal_events.php",
                async: false,
                data: {date: currentDate},
                contentType: "application/json; charset=utf-8",
                success: function (msg) {
                    console.log(msg);                
                }
        });

     

    Then I created the page cal_events.php with this code:

    $share_with = user_shared($user);
    
    $stmt2 = $mysqli->prepare("SELECT date, status FROM pto_tracker WHERE account = ? ORDER BY date");
    $stmt2->bind_param('i', $share_with);
    $stmt2->execute();
    $stmt2->store_result();
    $count = $stmt2->num_rows;
    $stmt2->bind_result($date, $status);
    $stmt2->fetch();
    $stmt2->close();
    
    $current_date = cleansafely($_POST['date']);
    
    if (($count >= 1) && ($current_date == $date)){
    	
    		if ($status == "pending") {
    			
    			$background_color = "#f0cb11";
    			$status_show = "<span class=\"label plain\">Pending</span>";
    			
    		}
    		
    		if ($status == "approved") {
    			
    			$background_color = "#4CAF50";
    			$status_show = "<span class=\"label green\">Approved</span>";
    			
    		}
    		
    		if ($status == "denied") {
    			
    			$background_color = "#c62d1f";
    			$status_show = "<span class=\"label red\">Denied</span>";
    		
    		}
    	
    	$array .= $date . $status_show;
    	
    }
    
    	$out = array_values($array);
        json_encode($out);
    	
    	//echo json_encode($array, JSON_FORCE_OBJECT);

    I am not sure how to go about actually finding the dates on the calendar to the ones in table.

  4. I have a javascript calendar and I want to make it so when a event is added to a mysql table it can be seen on the calendar. I know you can't put SELECT and other mysql stuff in a script so how can I do this?

    HTML:

    <div id="main" class="container">
      <span class="jumbotron">
        <h1 class="text-center">
          <a id="left" href="#"> 
            <i class="fas fa-chevron-left"></i>
          </a>
          <span id="month"></span>
          <span id="year"></span>
           <a id="right" href="#"> 
            <i class="fas fa-chevron-right"></i>
            </a>
    	</h1>
        </span>
    
      <span class="row">
        <span class="col-sm-10 col-sm-offset-1"></span>
      </span>
       <table class="table"></table>
    </div>

    JAVASCRIPT for calendar:

    $(document).ready(function() {
      var currentDate = new Date();
      function generateCalendar(d) {
        function monthDays(month, year) {
          var result = [];
          var days = new Date(year, month, 0).getDate();
          for (var i = 1; i <= days; i++) {
            result.push(i);
          }
          return result;
        }
        Date.prototype.monthDays = function() {
          var d = new Date(this.getFullYear(), this.getMonth() + 1, 0);
          return d.getDate();
        };
        var details = {
          // totalDays: monthDays(d.getMonth(), d.getFullYear()),
          totalDays: d.monthDays(),
          weekDays: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
          months: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
        };
        var start = new Date(d.getFullYear(), d.getMonth()).getDay();
        var cal = [];
        var day = 1;
        for (var i = 0; i <= 6; i++) {
          cal.push(['<tr>']);
          for (var j = 0; j < 7; j++) {
            if (i === 0) {
              cal[i].push('<td>' + details.weekDays[j] + '</td>');
            } else if (day > details.totalDays) {
              cal[i].push('<td>&nbsp;</td>');
            } else {
              if (i === 1 && j < start) {
                cal[i].push('<td>&nbsp;</td>');
              } else {
                cal[i].push('<td class="day">' + day++ + '</td>');
              }
            }
          }
          cal[i].push('</tr>');
        }
        cal = cal.reduce(function(a, b) {
          return a.concat(b);
        }, []).join('');
        $('table').append(cal);
        $('#month').text(details.months[d.getMonth()]);
        $('#year').text(d.getFullYear());
        $('td.day').mouseover(function() {
          $(this).addClass('hover');
        }).mouseout(function() {
          $(this).removeClass('hover');
        });
      }
      $('#left').click(function(e) {
        $('table').text('');
        if (currentDate.getMonth() === 0) {
          currentDate = new Date(currentDate.getFullYear() - 1, 11);
          generateCalendar(currentDate);
        } else {
          currentDate = new Date(currentDate.getFullYear(), currentDate.getMonth() - 1)
          generateCalendar(currentDate);
        }
    	
    	 e.preventDefault();
      });
      $('#right').click(function(e) {
        $('table').html('<tr></tr>');
        if (currentDate.getMonth() === 11) {
          currentDate = new Date(currentDate.getFullYear() + 1, 0);
          generateCalendar(currentDate);
        } else {
          currentDate = new Date(currentDate.getFullYear(), currentDate.getMonth() + 1)
          generateCalendar(currentDate);
        }
    	
    	 e.preventDefault();
      
      });
      
      generateCalendar(currentDate);
    });

    Not sure if needed, but I provided all the code. For the sake of my question lets say I have database table called "current_events" and I want to show all events on the calendar in a different color.

  5. For example, if they just won a game and received a trophy for it. It takes them to a page to update the database with the trophy they just won and perhaps their score. It then redirects immediately back to the game in a die(header(Location: link.com/here.php?note=You+won+a+trophy.+<img src=trophylink.png>)).

  6. Here is a example link: https://site.com/this_here/page.php?note=W+srchttp:>e+have+some+text+here.

    That shows up fine like it is supposed to, but when I want a image to show up with in it - in html - it makes the whole page wonky.

    Example Problem: https://site.com/this_here/page.php?note=We+have+some+text+here.+<img src=imagelink.png>

    I have it on any page that is now set to show an image link that. I used to not have problems with this and now I do. The 'note' text comes from a $_GET and is not decoded or anything - which you shouldn't do I know.

    I tested by taking out one "<" thinking that was the problem. And that made it so the page wasnt wonky but then you know just the text appeared.

    I also tested leaving in both "<>" from the img tag and taking out the "=". That also makes it so the page isnt wonky anymore. Does just the same as taking out a "<>".

    This seems like a really weird error to me, but maybe there is something I should or shouldn't be doing that I am not thinking of.
     

  7.  

    and now im getting Fatal error: Call to undefined method mysqli_stmt::bind()   :-\

     

    You should be using bind_param.

     

    Instead of . .

     

    $stmt->bind("ss",$description,$name) or die( "could not bind parameters");

     

    Use  . . .

    $stmt->bind_param("ss",$description,$name) or die( "could not bind parameters");

  8. Not sure what is going on I tried everything (well, that I could think of) . . . any ideas are welcome (hopefully new ones - getting frustrated :/)

    if ($mysqli->prepare("INSERT INTO solcontest_entries (title, image,content, user, contest) VALUES ($title, $image, $content, $userid, $contest")) {
    $stmt2 = $mysqli->prepare("INSERT INTO `solcontest_entries` (title, image, content, user, contest) VALUES (?, ?, ?, ?, ?)");
    $stmt2->bind_param('sssss', $title, $image, $content, $userid, $contest);
    $stmt2->execute();
    $stmt2->store_result();
    $stmt2->fetch();
    $stmt2->close();
    } else {
    			
    	die(mysqli_error($mysqli));
    
    }
    

    Error I get from die mysqli_error: "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' of the site's lead ad, user_61609201, contest_1' at line 1"

     

    I have also tried $mysqli->query no change occured. I added the "if else die" statement because it was giving no errors, but not adding it to the database.

     

    It gives the error where $content is supposed to be inserted.

     

    Various combos and singles I tried for the variable:

    //$content =  cleansafely($_POST['content']);
    //$content = mysqli_real_escape_string ($mysqli, $_POST['content']);
    //$content = cleansafely($content);
    $content = $_POST['content'];
    

    If any more information is needed please let me know.

  9. Opps. My bad. Here you go:

    --
    -- Table structure for table `bom_terms`
    --
    
    CREATE TABLE `bom_terms` (
      `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
      `account` int(7) unsigned NOT NULL,
      `money` decimal(5,2) NOT NULL,
      `timeframe` varchar(100) COLLATE latin1_general_ci NOT NULL,
      `startdate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
      `enddate` datetime NOT NULL,
      PRIMARY KEY (`id`)
    ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=3 ;
    
    --
    -- Dumping data for table `bom_terms`
    --
    
    INSERT INTO `bom_terms` (`id`, `account`, `money`, `timeframe`, `startdate`, `enddate`) VALUES(1, 567892, '20.00', 'Every Week', '2013-01-04 00:44:51', '2013-02-06 12:33:26');
    INSERT INTO `bom_terms` (`id`, `account`, `money`, `timeframe`, `startdate`, `enddate`) VALUES(2, 567892, '40.00', 'Every 2 Weeks', '2013-02-06 17:34:34', '0000-00-00 00:00:00');
    
  10. Alright, here you are - I removed the first 3 id's, but that shouldn't matter:

    --
    -- Table structure for table 'bom_transaction'
    --
    
    CREATE TABLE bom_transaction (
      id int(11) unsigned NOT NULL AUTO_INCREMENT,
      account int(7) unsigned NOT NULL,
      `type` tinyint(1) unsigned NOT NULL DEFAULT '0',
      amount decimal(5,2) unsigned NOT NULL,
      reason varchar(250) COLLATE latin1_general_ci NOT NULL,
      repayplan tinyint(1) unsigned NOT NULL,
      repaid tinyint(1) unsigned NOT NULL,
      transid varchar(40) COLLATE latin1_general_ci NOT NULL,
      `date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
      PRIMARY KEY (id)
    ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=10 ;
    
    --
    -- Dumping data for table 'bom_transaction'
    --
    
    INSERT INTO bom_transaction (id, account, `type`, amount, reason, repayplan, repaid, transid, `date`) VALUES(4, 567892, 1, '10.00', '', 0, 0, '', '2013-01-25 02:58:59');
    INSERT INTO bom_transaction (id, account, `type`, amount, reason, repayplan, repaid, transid, `date`) VALUES(5, 567892, 1, '10.00', '', 0, 0, '', '2013-02-01 02:59:20');
    INSERT INTO bom_transaction (id, account, `type`, amount, reason, repayplan, repaid, transid, `date`) VALUES(6, 567892, 1, '90.00', '', 0, 0, '', '2013-02-06 02:59:38');
    INSERT INTO bom_transaction (id, account, `type`, amount, reason, repayplan, repaid, transid, `date`) VALUES(7, 567892, 1, '20.00', '', 0, 0, '', '2013-02-20 02:59:51');
    INSERT INTO bom_transaction (id, account, `type`, amount, reason, repayplan, repaid, transid, `date`) VALUES(8, 567892, 2, '46.00', 'Vengenz Birthday Party/T-Shirts', 1, 0, '', '2013-02-23 03:00:19');
    INSERT INTO bom_transaction (id, account, `type`, amount, reason, repayplan, repaid, transid, `date`) VALUES(9, 567892, 1, '100.00', '', 0, 0, '', '2013-03-06 03:00:41');
    
  11. How about you try not having the mail() command as a variable. Like below:

     

    <?php
    //simple captcha
    if(isset($_POST['answer']) && $_POST['answer']!='14') { echo "<script>alert('You provided a wrong answer for the Security Question')</script>"; 
    echo "<a href='contact.php'>Please return to the Form and try again.</a><br /><br />\n";
    
    
     //simple captcha
    $field_name = $_POST['name'];
    $field_email = $_POST['email'];
    $field_phone = $_POST['phone'];
    $field_preferred = $_POST['preferred'];
    $field_datepicker = $_POST['datepicker'];
    $field_passengers = $_POST['passengers'];
    $field_pickup = $_POST['pickup'];
    $field_drop = $_POST['drop'];
    $field_message = $_POST['message'];
    
    if(!ereg("^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$", $field_email))
       {
        echo "That is not a valid <b>email</b> address. Please return to the" . " <a href='contact.php'>previous page and try again.</a>";
        exit;
       }
    
       if(empty($_POST['name']) || strlen(trim($_POST['name'])) ==0)
       {
        echo "Your <b>name</b> was not entered into the field. Please return to the" . " <a href='contact.php'>previous page and try again.</a>";
       }
       else if(empty($_POST['email']) || strlen(trim($_POST['email'])) ==0)
       {
        echo "Your <b>email</b> was not entered into the field. Please return to the" . " <a href='contact.php'>previous page and try again.</a>";
       }
       else if(empty($_POST['message']) || strlen(trim($_POST['message'])) ==0)
       {
        echo "You <b>message</b> was not entered into the field. Please return to the" . " <a href='contact.php'>previous page and try again.</a>";
       }
       else if(empty($_POST['pickup']) || strlen(trim($_POST['pickup'])) ==0)
       {
        echo "Your <b>pickup</b> location was not entered into the field. Please return to the" . " <a href='contact.php'>previous page and try again.</a>";
       }
       else if(empty($_POST['drop']) || strlen(trim($_POST['drop'])) ==0)
       {
        echo "Your <b>drop off</b> location was not entered into the field. Please return to the" . " <a href='contact.php'>previous page and try again.</a>";
       }
       else
       {
    
    $mail_to = 'test@test.com';
    $subject = 'New Message from '.$field_name;
    
    $body_message = 'From: '.$field_name."\n";
    $body_message .= 'E-mail: '.$field_email."\n";
    $body_message .= 'Phone: '.$field_phone."\n";
    $body_message .= 'Preferred Method: '.$field_preferred."\n";
    $body_message .= 'Appointment Date: '.$field_datepicker."\n";
    $body_message .= 'Number of Passengers: '.$field_passengers."\n";
    $body_message .= 'Pick Up Location: '.$field_pickup."\n";
    $body_message .= 'Drop Off Location: '.$field_drop."\n";
    $body_message .= 'Message: '.$field_message."\n";
    
    $headers = 'From: '.$field_email."\r\n";
    $headers .= 'Reply-To: '.$field_email."\r\n";
    
    if (mail($mail_to, $subject, $body_message, $headers)) { ?>
    <script language="javascript" type="text/javascript">
    alert('Thank you for the message. We will contact you shortly.');
    window.location = 'index.htm';
    </script>
    <?php
    }
    else { ?>
    <script language="javascript" type="text/javascript">
    alert('Message failed. Please, send an email to techsuppor');
    window.location = 'index.htm';
    </script>
    <?php
    }
    }
    }
    ?>
    

     

    Let me know if it works! :)

  12. Try:

    require_once ('connection.php');
    //First Query and Output
    
    $result = mysql_query("CALL C01_Client_Summary_ByAccount(1, '2012-02-27', '2013-03-29');");
     
        while($row=mysql_fetch_array($result))
        {
    echo $row['CommisionPercentage'];
         }
    //END First Query and Output
       
    //Second Query and Output
    $new2 = mysql_query("CALL C01_Client_Summary_ByBetType(1, '2012-02-27', '2013-03-29');");
    
        while($row2=mysql_fetch_array($new2))
        {
    echo $row2['Turnover'];
         }
    //END Second Query and Output
    

     

    I changed the 2nd query's variable by adding a "2" behind it.

  13. I need some help with the following code. I want it to go through the "bom_terms" table in which $money and $timeframe should be found based on the start date and end date comparisons I am having trouble with.

     

    Full Transactions code:

     

    /* Transactions */
    echo "<h2>Transactions - <a href=\"../transactions/add.php?account=$account\">Add</a></h2>";
    
    if($stmt = $mysqli->prepare("SELECT type, amount, reason, repayplan, repaid, transid, date FROM bom_transaction WHERE account = ? ORDER BY id"));
    {
    $stmt->bind_param('i', $account);
    $stmt->execute();
    $stmt->store_result();
    $count = $stmt->num_rows;
    $stmt->bind_result($type, $amount, $reason, $repayplan, $repaid, $transid, $date);
    
    	if ($count == "0") {
         echo "<i>No transactions were found.</i><br>";
    	}
    
    while ($stmt->fetch()){
    	if ($type == "0") {$type = ""; $color = "";}
    	if ($type == "1") {$type = "Added"; $color = "green";}
    	if ($type == "2") {$type = "Removed"; $color = "red";}
    	if ($type == "3") {$type = "Repaid"; $color = "";}
    	
    	if ($repayplan == "0") {$repayplan = "No";}
    	if ($repayplan == "1") {$repayplan = "Yes";}
    	
    	if ($repaid == "0") {$repaid = "No";}
    	if ($repaid == "1") {$repaid = "Yes";}
    	
    	$stmt2 = $mysqli->prepare("SELECT money, timeframe FROM bom_terms WHERE account = ? AND startdate <= '2013-01-03 21:00:00' AND enddate >= '2013-02-20 21:00:00'");
    	$stmt2->bind_param('i', $account);
    	$stmt2->execute();
    	$stmt2->store_result();
    	$stmt2->bind_result($money, $timeframe);
    	$stmt2->fetch();
    	$stmt2->close();
    	
    	$date2 = date("M d, Y", strtotime($date));
    	
        echo "<font color=\"$color\">$type $$amount</font> $money/$timeframe $reason $repayplan $repaid $date2 <a href=\"../transactions/edit.php?transid=$transid\">Edit</a><br>";
    
    }
    $stmt->close();
    }
    
    echo "<br>";
    

     

    Part of Coding Asking About (From the above):

    	$stmt2 = $mysqli->prepare("SELECT money, timeframe FROM bom_terms WHERE account = ? AND startdate <= '2013-01-03 21:00:00' AND enddate >= '2013-02-31 21:00:00'");
    	$stmt2->bind_param('i', $account);
    	$stmt2->execute();
    	$stmt2->store_result();
    	$stmt2->bind_result($money, $timeframe);
    	$stmt2->fetch();
    	$stmt2->close();
    

     

    What's it's doing:

    It's making all results from the "bom_terms" table the same when at least 2 of the results should be different (meaning from a different row of the "bom_terms" table). - Right now it is grabbing the last result found from the table. Not sure why however. 

     

    Some tests/theories I tried made it so it did show a different row, but they were still all shown as the same.

     

    Example (what it is doing now):

    ---Example---

    Added $10.00 40.00/Every 2 Weeks No No Jan 31, 2013 Edit
    Added $90.00 40.00/Every 2 Weeks No No Feb 05, 2013 Edit
    Added $20.00 40.00/Every 2 Weeks No No Feb 19, 2013 Edit
    Removed $46.00 40.00/Every 2 Weeks Vengenz Birthday Party/T-Shirts Yes No Feb 22, 2013 Edit
    Added $100.00 40.00/Every 2 Weeks No No Mar 05, 2013 Edit

    ---END Example---

     

    NOTE: The 40.00/Every 2 Weeks is the result from the "bom_terms" table.

     

    Example (what I want it to do):

    ---Example---

    Added $10.00 20.00/Every Week No No Jan 31, 2013 Edit
    Added $90.00 20.00/Every Week No No Feb 05, 2013 Edit
    Added $20.00 20.00/Every Week No No Feb 19, 2013 Edit
    Removed $46.00 40.00/Every 2 Weeks Vengenz Birthday Party/T-Shirts Yes No Feb 22, 2013 Edit
    Added $100.00 40.00/Every 2 Weeks No No Mar 05, 2013 Edit

    ---END Example---

     

    NOTE: The 40.00/Every 2 Weeks and 20.00/Every Week are the results that would be from the "bom_terms" table.

     

    I am hoping there is just a simple problem/error I don't see. .. . . Hopefully you can understand what I am asking and having trouble with - I had a hard time trying to come up with a good way to explain it - this is the best way I could come up with.

  14. Another thing. I see that you are defining links ($link1, $link2, etc) using the process

    $link1 = addplus($member1);

     

    Question: if $member1 is anything other than an empty value, will the returned value ever be empty? The reason I ask is you have a ton of conditional statements such as

    if ((!empty($member1)) && (!empty($link1)))

     

    But, if $link1 would only be empty if $member1 is empty then you only need to check the member variable

    Yeah, you have a point there. haha

  15. Oh man. I feel stupid. I fixed it. . . .When I finished reading your last reply I thought of adding an else statement afterwards. Not sure why I did not think of this. Something so simple.

     

    So it now works. Thanks for the help anyways. I appreciate it. :)

     

    Added After if Statement:

    
    
    else {$allteammembers = "";}
    
  16. So what - EXACTLY - are you wanting to do differently if $placement is empty?

     

    If placement is empty I want  $allteammembers to be empty also.

     

    Right now it is showing the last known result used for $allteammembers and putting it on all the other results found.

  17. Line 49 is the line I was referring to about moving.

    if ((!empty($member1)) && (!empty($link1))) {$allteammembers = "<b>Team Members: </b>$member1 $member2 $member3 $boat2<br><span style=\"padding-left: 20px\">Caught: $channels2$flatheads2$blue2</span><br><br>";} else {$allteammembers = "";}
    

    The above can be moved, but does not need too is what I am seeing now (from what your comments state in your reply). - So it will always go through even if there is no placement.

     

    I want it to work like line 60. Which is structured exactly the same.

    if ((!empty($teammember1)) && (!empty($link5))) {$teammemberspictured = "<b>Team Members Pictured: </b>$teammember1 $teammember2 $teammember3<br>";} else {$teammemberspictured = "";}
    

     

    I never used JOIN in mysql successfully before. Would that maybe fix the problem like you suggested?

    I'm googling it now. :)

×
×
  • 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.