Jump to content

cutielou22

Members
  • Posts

    81
  • Joined

  • Last visited

Everything 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. 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");
  6. 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.
  7. Yes thank you. It is working perfectly now. Sorry about not posting my attempt. (Noted for next time.)
  8. I am guessing you already went to sleep. But it is not urgent. No rush needed.
  9. Yes, that is the result I wanted - I have yet to test your code though. I will let you know tonight or tomorrow if it works for me. EDIT: Could you convert it back over to mysqli? I tried changing it myself, but I am not getting the same results as you.
  10. 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');
  11. 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');
  12. $timeframe is not the only one that is different. Both $timeframe and $money are different. Compare my examples of results more closely to get a better understanding. By the way, there is not 1 row. Right now there is 2 rows in the table - and in the near future there will be more.
  13. 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 = '[email protected]'; $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!
  14. 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.
  15. 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.
  16. Yeah, you have a point there. haha
  17. 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 = "";}
  18. 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.
  19. 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.
  20. So are you saying to just move $allteammembers out of the "if statement"? Because I tried that. That does not work. I get the exact same problem. And no - I do not want to exclude or skip records that do not have a $placement.
  21. What it is doing: Right now it is taking the last known team members ($allteammembers) on all the rest of the results that do not have any team members. - So it should show nothing. What I want it to do: To show nothing for $allteammembers when there is no data found. - Like the way I think I have it coded. The Full Code Going Through Database: if ($stmt = $mysqli->prepare("SELECT title, caption, category, image, placement, teammember1, teammember2, teammember3, otherpeople, downloads, views FROM photogallery WHERE year = ? AND timeofday = ? AND status = 1 ORDER BY category, placement")) { $stmt->bind_param('is', $year, $timeofday); $stmt->execute(); $stmt->store_result(); $stmt->bind_result($title, $caption, $category, $image, $placement, $teammember1, $teammember2, $teammember3, $otherpeople, $downloads, $views); while($stmt->fetch()) { if ((!empty($placement))) { $stmt2 = $mysqli->prepare("SELECT boat, teammember1, teammember2, teammember3, channel, flathead, blue, total, bigfish, totalweight FROM tourneyresults WHERE year = ? AND timeofday = ? AND placement = ?"); $stmt2->bind_param('isi', $year, $timeofday, $placement); $stmt2->execute(); $stmt2->store_result(); $stmt2->bind_result($boat, $member1, $member2, $member3, $channels, $flatheads, $blue, $total, $bigfish, $weight); $stmt2->fetch(); $stmt2->close(); $link1 = addplus($member1); $link2 = addplus($member2); $link3 = addplus($member3); if ((!empty($member1)) && (!empty($link1))) {$member1 = "<a href='$mainurl/fisher/$link1'>$member1</a>";} if ((!empty($member2)) && (!empty($link2))) {$member2 = "and <a href='$mainurl/fisher/$link2'>$member2</a>";} if ((!empty($member3)) && (!empty($link3))) {$member3 = "and <a href='$mainurl/fisher/$link3'>$member3</a>";} if ($boat) {$boat2 = "~ Boat #$boat";} else {$boat2 = "";} if ($channels) {$channels2 = "$channels Channel(s)";} else {$channels2 = "";} if ($flatheads) {$flatheads2 = " | $flatheads Flathead(s)";} else {$flatheads2 = "";} if ($blue) {$blue2 = " | $blue Blue(s)";} else {$blue2 = "";} 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 = "";} } $link5 = addplus($teammember1); $link6 = addplus($teammember2); $link7 = addplus($teammember3); if ((!empty($teammember1)) && (!empty($link5))) {$teammember1 = "<a href='$mainurl/fisher/$link5'>$teammember1</a>";} if (!empty($teammember2) && !empty($link6)) {$teammember2 = "and <a href='$mainurl/fisher/$link6'>$teammember2</a>";} if (!empty($teammember3) && !empty($link7)) {$teammember3 = "and <a href='$mainurl/fisher/$link7'>$teammember3</a>";} if ((!empty($teammember1)) && (!empty($link5))) {$teammemberspictured = "<b>Team Members Pictured: </b>$teammember1 $teammember2 $teammember3<br>";} else {$teammemberspictured = "";} if ((!empty($otherpeople)) && (((!empty($teammember1)) && (!empty($link5))) || ((!empty($member1)) && (!empty($link1))))) {$otherpeople2 = "<b>Other People in This Photo:</b> $otherpeople<br>";} if (!empty($otherpeople) && ((empty($teammember1)) && (empty($link5))) && ((empty($member1)) && (empty($link1)))) {$otherpeople2 = "<b>People in This Photo:</b> $otherpeople<br>";} if (($category == "0") || (empty($category))) {$category2 = "No Category";} if (($category == "1")) {$category2 = "First Place Winner";} if (($category == "2")) {$category2 = "2nd-5th Place Winners";} if (($category == "3")) {$category2 = "6th-12th Place Winners";} if (($category == "4")) {$category2 = "13th-20th Place Winners";} if (($category == "5")) {$category2 = "13th-24th Place Winners";} if (($category == "6")) {$category2 = "Big Fish Winners";} if (($category == "7")) {$category2 = "Take Off";} if (($category == "8")) {$category2 = "Weigh In";} if (($category == "9")) {$category2 = "Scoreboard";} if (($category == "10")) {$category2 = "Prizes from Drawing";} if (($category == "11")) {$category2 = "Kids Prizes and Face Painting";} if (($category == "12")) {$category2 = "Morning Meeting";} if (($category == "13")) {$category2 = "Sign Up";} if (($category == "14")) {$category2 = "Spectators";} if (($category == "15")) {$category2 = "Misc.";} if (($category == "16")) {$category2 = "Extra Photos";} if ($timeofday == "night") {$subfolder = "NightTourney";} else {$subfolder = "year";} ECHO<<<END <div class="gallery" id="container"> <div id="left"> <img src="$mainurl/images/$subfolder/$year/$image"> </div> <div id="bottom"> $category2 | <a href="$mainurl/images/year/$year/$image" class='links'>Download Image</a> | $downloads downloads | $views views | Report Error | Add A Comment </div> <div id="right"> <h3>$title</h3> $allteammembers $teammemberspictured $otherpeople2 <p>$caption</p> </div> </div> END; } $stmt->close(); } Snippet Not Working Correctly: 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 = "";} I would like to know how to fix it and why it is doing it exactly? All my ideas failed. :/
  22. I agree with not running a query for every single file. I didn't think of that. But the code you gave doe's work thank you for the help and suggestions.
  23. On Notepad++ you can use FTP to automatically upload and edit files on your website. First off, in Notepad++ look in the top menu for "Plugins". From there you should see in the dropdown menu "NppFTP" Hover over that and click "Show NppFTP Window". That will add it to the screen - if not already showing. Now to add your FTP details do the following: Click the Setting icon in the NppFTP window/area. Choose "Profile Settings". Click "Add new" in bottom left corner. Now enter your FTP details. If you do not know this information you will need to go to your webhost and find something like "FTP details" in your cpanel. Also: .php files will show the coding. Change the file to .html if you want to test the result.
  24. Ran some extra tests and changed coding slightly (getting different results): if ($handle = @opendir("../../images/year/$year/")) { $blacklist = array('.', '..', 'index.php', 'index.html'); while (false !== ($file = readdir($handle))) { if (!in_array($file, $blacklist)) { if($stmt = $mysqli->prepare("SELECT id, image, title, caption, secureid FROM photogallery WHERE image = ? AND year = ? AND timeofday = ?")) { $stmt->bind_param('sis', $file, $year, $timeofday); $stmt->execute(); $stmt->store_result(); $stmt->bind_result($id, $image, $title, $caption, $photoid); $stmt->fetch(); $stmt->close(); } if ((isset($id)) && (isset($photoid)) && (isset($image))){ $idcheck = "<font color=\"green\">Found in Database</font>"; $admin = "<a href=\"../edit/photos.php?photoid=$photoid\">Edit</a>"; $details = "<b>$title</b> $caption"; } else { $idcheck = "<font color=\"red\">Not Found in Database</font>"; $admin = "<a href=\"../add/photos.php?image=$file&year=$year&timeofday=$timeofday\">Add</a>"; $details = ""; } echo "$file $image $details $idcheck $admin<br>"; } } closedir($handle); } else {echo "This image directory was not found.";} What It is Doing: Right now it is only reading the first file through the database and adding those results to the others file in the directory. EXAMPLE: This is what it is doing now. BoatDock2004.jpg BoatDock2004.jpg Take Off Found in Database Edit Weigh-in2004.jpg BoatDock2004.jpg Take Off Found in Database Edit FirstPlace2004.jpg BoatDock2004.jpg Take Off Found in Database Edit What I Want It To Do: I want it to show all the results regardless if found in the database or not and with the correct information (right now it is not showing the correct information afterwards as shown in the example above). EXAMPLE: Notice how image files are now matching up. (They do not necessarily need to match up maybe return blank if not found in the database.) BoatDock2004.jpg BoatDock2004.jpg Take Off Found in Database Edit Weigh-in2004.jpg Weigh-in2004.jpg NOT Found in Database Edit FirstPlace2004.jpg FirstPlace2004.jpg NOT Found in Database Edit
  25. Here is The Code: if ($handle = @opendir("../../images/year/$year/")) { $blacklist = array('.', '..', 'index.php', 'index.html'); while (false !== ($file = readdir($handle))) { if (!in_array($file, $blacklist)) { $stmt = $mysqli->prepare("SELECT id, image, title, caption, secureid FROM photogallery WHERE image = ? AND year = ? AND timeofday = ? LIMIT 5"); $stmt->bind_param('sis', $file, $year, $timeofday); $stmt->execute(); $stmt->store_result(); $stmt->bind_result($id, $image, $title, $caption, $photoid); //$stmt->fetch(); while ($stmt->fetch()) { if (($id) && ($photoid)){ $idcheck = "<font color=\"green\">Found in Database</font>"; $admin = "<a href=\"../edit/photos.php?photoid=$photoid\">Edit</a>"; $details = "<b>$title</b> $caption"; } else { $idcheck = "<font color=\"red\">Not Found in Database</font>"; $admin = "<a href=\"../add/photos.php?image=$file&year=$year&timeofday=$timeofday\">Add</a>"; $details = ""; } echo "$image $details $idcheck $admin<br>"; } $stmt->close(); echo "$file $details $idcheck $admin<br>"; } } closedir($handle); } else {echo "This image directory was not found.";} What It is Doing: Right now it is only showing the ones found in the database. What I Want It To Do: I want it to show all the results found in the database and the ones that are not found in the database. So I can see everything. If you need any more information. Please ask.
×
×
  • 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.