PHP - I Need Specific Help With Code
Hello all!
Well, here's my dilemma. I understand how PHP and server side code works, I understand the important basics about PHP in general, I just need more specific help. I'm currently working with a partner in building a website that allows users to basically enter in information in text fields, add a picture to their post, and choose from a drop down menu what other page on the website they want the post to go to. (For all of the things I'm discussing here, I've drawn out pictures of what I want in Illustrator if anyone needs specifications.) Once the user presses "Submit" or "Accept" or whatever, it will post their information on the page they selected, organized with the picture a certain size on the left, and the text aligned ragged right on the right side of the picture. Below that, each "post" will be assigned a number based on the last post made to that page. So if I was the first one to post it, it'd show "1" in the data. I can imagine this isn't a simple process, but because I understand how PHP works, and also how comment systems in server side coding works, I just need to know certain things in the code, like organizing the inputed data when posted and what not. Any help or advice would be greatly appreciated by both me and my partner. Thanks! Similar TutorialsI'm kind of a beginner in PHP and I'm not sure how complicated is this thing I need to do so I just need a little bit of help. Anyway, I have this clock counter on a few of my pages, counting down to 0 and what I need to do is execute certain code 15 minutes before a counter reaches 0. It's basically the same code but it needs to run every time one of the counters is 15 minutes away from 0. Any simple way for me to achieve this? Thanks! Commented in red is the code that doesn't produce anything. It is 3/4 of the way down the page.. Thanks for looking! Code: [Select] <?php error_reporting(E_ALL); ini_set("display_errors", 1); $host= ""; $db_name= ""; $db_user= ""; $db_password= ""; ob_start(); if(isset($_POST['newBidder'])) { $newBidder= isset($_POST['newBidder']) ? $_POST['newBidder'] : ''; $bidderId= $newBidder; mysql_connect("$host", "$db_user", "$db_password")or die("cannot connect to server"); mysql_select_db("$db_name")or die("cannot select DB"); $sql="SELECT * FROM bidders WHERE biddersId='$bidderId'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row if($count==0){ // Add $biddersId and redirect to anypage mysql_Query("INSERT INTO bidders (biddersId) VALUES ('$bidderId')"); header("Location: index.php"); exit(); } } //////////////////////////////////// if(isset($_POST['deleteBidder'])) { $deleteBidder= isset($_POST['deleteBidder']) ? $_POST['deleteBidder'] : ''; mysql_connect("$host", "$db_user", "$db_password")or die("cannot connect to server"); mysql_select_db("$db_name")or die("cannot select DB"); mysql_query("DELETE FROM bidders WHERE biddersId='$deleteBidder'"); header("Location: index.php"); exit(); } //////////////////////////////////// if (isset($_POST['itemDescription'], $_POST['itemPrice'], $_POST['winningBidder'], $_POST['itemQty'])) { $itemDescription= isset($_POST['itemDescription']) ? $_POST['itemDescription'] : ''; $itemPrice= isset($_POST['itemPrice']) ? $_POST['itemPrice'] : ''; $winningBidder= isset($_POST['winningBidder']) ? $_POST['winningBidder'] : ''; $itemQty= isset($_POST['itemQty']) ? $_POST['itemQty'] : ''; mysql_connect("$host", "$db_user", "$db_password")or die("cannot connect to server"); mysql_select_db("$db_name")or die("cannot select DB"); $sql="SELECT * FROM bidders WHERE biddersId='$winningBidder'"; $result=mysql_query($sql); $count=mysql_num_rows($result); // If result matched, table row must be 1 row if($count==0){ echo "That Bidder Number is NOT logged in, "; echo "would you like to set this bidder as active?"; echo " Enter 1 for NO or 2 for YES"; echo "<form action= \"process.php\" method= \"POST\">"; echo "<input type =\"text\" name= \"logUser\"/>"; echo "<input type= \"submit\" value = \"Submit\"/>"; exit(); } } $logUser= isset($_POST['logUser']) ? $_POST['logUser'] : ''; if ($logUser= '1') { header("Location: inprogress.php"); exit(); } if ($logUser= '2'){ // Add $biddersId and redirect to anypage mysql_connect("$host", "$db_user", "$db_password")or die("cannot connect to server"); mysql_select_db("$db_name")or die("cannot select DB"); mysql_Query("INSERT INTO bidders (biddersId) ////This won't add biddersid to database///////[ VALUES ('$winningBidder')"); mysql_query("INSERT INTO transactions /////This won't add details to the database either?///// VALUES('$itemDescription', '$itemPrice','$winningBidder', '$itemQty', '$totalPrice')") or die(mysql_error()); header("Location: inprogress.php"); exit(); } //////////////////////////////////////// echo "<font color= \"red\" face=\"calibri\" size=\"4\">That bidder is already logged, Please press your browsers back button and try again.</font>"; ob_end_flush(); ?> I have one database with 2 tables as follows bidders table ONLY has biddersId field; transactions has (in order) itemDescription, itemPrice, bidderId, itemQty, totalPrice everything else works, except updating the database with the above? Am I doing something wrong in MySql. I have all eroors on , but i get NONE when running the script? <ul> <!-- List the rest of the articles found in the category --> <?php else : ?> <li class="otherrecentmain"><span class="title"><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></span> <span class="meta"></span> </li> <?php endif; ?> <?php endwhile; ?> <!-- END --> </ul> For some reason, its stuck on displaying 9 articles but I want to be able to control how many I want. I may want to choose 17 or whatever etc, not sure how to add it into the php. I use the Wholesale Suite Premium Prices plugin with WooCommerce. I have 6 specific wholesale roles out of 15 that I wish to hide two specific shipping methods from being selected for the 6 exceptions. I'm just trying this on my staging server at this time using a code snippet example that I found and modified for my specific conditions. Would the following work for this purpose? /* Hide specific shipping methods for specific wholesale roles */ add_filter( 'woocommerce_package_rates', function( $shipping_rates ) { // User role and shipping method ID to hide for the user role $role_shipping_method_arr = array( 'ws_silvia_silver' => array( 'Silvia Premium Standard Shipping (Tracking Service)'), 'ws_silvia_silver_pst_exempt' => array( 'Silvia Premium Standard Shipping (Tracking Service)'), 'ws_silvia_silver_tax_exempt' => array( 'Silvia Premium Standard Shipping (Tracking Service)'), 'ws_silvia_silver' => array( 'Silvia Union Standard Shipping (Tracking Service)'), 'ws_silvia_silver_pst_exempt' => array( 'Silvia Union Standard Shipping (Tracking Service)'), 'ws_silvia_silver_tax_exempt' => array( 'Silvia Union Standard Shipping (Tracking Service)'), 'ws_silvia_gold' => array( 'Silvia Premium Standard Shipping (Tracking Service)'), 'ws_silvia_gold_pst_exempt' => array( 'Silvia Premium Standard Shipping (Tracking Service)'), 'ws_silvia_gold_tax_exempt' => array( 'Silvia Premium Standard Shipping (Tracking Service)'), 'ws_silvia_gold' => array( 'Silvia Union Standard Shipping (Tracking Service)'), 'ws_silvia_gold_pst_exempt' => array( 'Silvia Union Standard Shipping (Tracking Service)'), 'ws_silvia_gold_tax_exempt' => array( 'Silvia Union Standard Shipping (Tracking Service)'), ); // Getting the current user role $curr_user = wp_get_current_user(); $curr_user_data = get_userdata($current_user->ID); // Wholesale Suite Roles if (isset($current_user) && class_exists('WWP_Wholesale_Roles')) { $wwp_wholesale_roles = WWP_Wholesale_Roles::getInstance(); $wwp_wholesale_role = $wwp_wholesale_roles->getUserWholesaleRole(); // Loop through the user role and shipping method pair foreach( $role_shipping_method_arr as $role => $shipping_methods_to_hide ) { // Check if defined role exist in current user role or not if( in_array( $role, $current_user->roles) ) { // Loop through all the shipping rates foreach( $shipping_rates as $shipping_method_key => $shipping_method ) { $shipping_id = $shipping_method->get_id(); // Unset the shipping method if found if( in_array( $shipping_id, $shipping_methods_to_hide) ) { unset($shipping_rates[$shipping_method_key]); } } } } } return $shipping_rates; }); Any insights as to how to accomplish this would be greatly appreciated. Lyse How can i call a specific row when ever a like. example : Code: [Select] $record = mysql_query("select * from table_name"); ($getValue= mysql_fetch_row($record) //i'm not sure what should i use. should i use mysql_fetch_array, mysql_ fetch_ assoc, mysql_ fetch_ object, mysql_ field_ name and etc. print $getValue[$column_name][0]; 0 = value 1st row in the database/table_name 1 = value 2nd row in the database/table_name 2 = value 3rd row in the database/table_name ...... .... ...... ..... etc. is there a code i can do except from using sql_fetch_array then loop and put in into a multidimensional array? Hi Guys, I am fairly new to mySQL/PHP and I have an issue. I have a login/registration system for a website and it works. However in the registration the user enters info such as their phone and email. How can I access these two fields of info from the user who is currently logged in. For example someone makes an account with: Username: Person Password: hello Email: person@gmail.com Phone: 111-111-1111 Name: Hello Person When they log into the site using their username and password, how can I detect their email/phone/name? Thanks in advance! I'm wondering how I can find the x, y coordinates on an image in PHP where a specific colour lies. If there was a #000000 coloured pixel located on 127, 205, how could I use PHP to find the 127, 205 by just telling it #000000? I have json code and i want to prine only {"currency":"DOGE","available":"0","reserved":"420.000000000"} data. my json data [{"currency":"1ST","available":"0","reserved":"0"},{"currency":"DOGE","available":"0","reserved":"420.000000000"},{"currency":"ZSC","available":"0","reserved":"0"}] I use this code
<?php ?> I've been searching for a couple of days on google using keywords, trying to figure out why this form sends blank emails. I've found several different ways to write something like this, including what's below, but for the life of me I haven't figured it out. Can anyone help a brother out? <?php $email = $_REQUEST['email']; $message = $_REQUEST['date']; $message .= $_REQUEST['location']; $message .= $_REQUEST['quantitymodel']; mail( "name@email.com", "Email Contact Form", $message, "From: $email" ); header( "Location: thankyou.html" ); ?> Hello all, I have a rather large array and I need to list it's contents in an alphabetical list. The array is built like this: $array['query']['row']['0']['title'] = 'Bob'; $array['query']['row']['1']['title'] = 'Andy'; $array['query']['row']['2']['title'] = 'Tom'; I need to sort it so it is in alphabetical order based on the title. Is there an easy way to do this? Hey guys. How do you remove a specific element from an array? Lets say I have a string like this: $list = "guy,girl,boy,man,woman,lady"; Then I use explode to break it up into an array by commas: $listArray = explode(",",$list); Now $listArray contains everything. Now if I wanted to delete something specific from that array, how would I do that? So for example, I want to delete "man" out of the array. How do I do that without know its key? Hi there im trying to destroy a specific session i have been looking through many different ways on google but have yet to find one the reason i want to do this is because my website part of the website that is being made has to have a login to view everything and this login ontop to view restricted content, so far my logout has destroyed both sessions and i cant find an answer, all the nessecory scripts are listed below Login: <?php if(isset($_POST['code'])) { $host="***********"; // Host name $username="*************"; // Mysql username $password="************"; // Mysql password $db_name="******"; // Database name // Connect to server and select databse. mysql_connect($host, $username, $password); mysql_select_db($db_name); // username and password sent from form $myusername=$_POST['myusername']; $mypassword=$_POST['mypassword']; // To protect MySQL injection (more detail about MySQL injection) $myusername = stripslashes($myusername); $mypassword = stripslashes($mypassword); $myusername = mysql_real_escape_string($myusername); $mypassword = mysql_real_escape_string($mypassword); // encrypt password $encrypted_mypassword=md5($mypassword); $sql="SELECT * FROM members WHERE username='$myusername' and password='$encrypted_mypassword'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row if($count==1){ // Register $myusername, $mypassword and redirect to file "login_success.php" session_register("myusername"); session_register("mypassword"); header("location:jncomenu.php"); } else { echo "Wrong Username or Password"; } } ?> Check session: <? session_start(); if(!session_is_registered(myusername)){ header("location:JNCOlogin.php"); } ?> Logout: <? session_start(myusername); session_destroy(myusername); header("location:index.php"); ?> The first session is the same script bar [php][session_register("username"); session_register("password"); /php] Any help will be greatly appriciated. Thank, Blink359 Hey guys I have trouble picking the specific id of an entry i want to delete so please take a look at the codes first Here's the function for making the form: Code: [Select] function am_query_display_quick($page,$order ='DATE DESC'){ global $email; $conn = db_connect_2(); $color1 = "tableRowOdd"; $color2 = "tableRowEven"; $RowCount = 0; $result = $conn->query("SELECT pro,pro_update,ana,ana_update,cell,cell_update,cellother,cellother_update,gen,gen_update,genother,genother_update,author,author_update,other,other_update,id FROM mailing_list WHERE email = '$email' ORDER BY $order LIMIT $start_row, $max_per_page;"); echo "<form method = \"post\" action=\".{$_SERVER['PHP_SELF']}.\">"; echo "<table class=\"sortable\" id=\"query_quick2\" width=\"100%\" >\r\n"; echo "\t<tr><th></th><th>Promoter Locus</th><th>Update?</th><th>Anatomical Area</th><th>Update?</th><th>Cell Type</th><th>Update?</th><th>Other Cell Type</th><th>Update?</th><th>Genetic Background</th><th>Update?</th><th>Other Gen. Back.</th><th>Update?</th><th>Author</th><th>Update?</th><th>Other</th><th>Update?</th><th></th>\r\n"; if($result->num_rows){ while ($row = $result->fetch_array()){ $RowCount ++; $row_color = ($RowCount % 2) ? $color1 : $color2; echo "\t<tr class=\"$row_color\" ><td><input type=\"submit\" name=\"edit_mail\" value = \"Edit\"/></td> <td>{$row['pro']}</td><td>{$row['pro_update']}</td><td>{$row['ana']}</td> <td>{$row['ana_update']}</td><td>{$row['cell']}</td><td>{$row['cell_update']}</td><td>{$row['cellother']}</td> <td>{$row['cellother_update']}</td><td>{$row['gen']}</td><td>{$row['gen_update']}</td><td>{$row['genother']}</td> <td>{$row['genother_update']}</td><td>{$row['author']}</td><td>{$row['author_update']}</td><td>{$row['other']}</td><td>{$row['other_update']}</td> <td><input type=\"submit\" name=\"delete_mail\" value =\"Delete\"/></td> <td><input type =\"hidden\" name = \"id\" value=\"{$row['id']}\"/></td> </tr>"; } } echo "</table>"; echo "</form>"; And this is where the delete command comes into place (excerpt): Code: [Select] } elseif(isset($_SESSION['user_id']) AND isset($_POST['delete_mail'])){ //user is deleting existing queries $conn=db_connect_2(); $id = mysqli_real_escape_string($conn, $_POST['id']); echo $id; $sql2 = "DELETE FROM mailing_list WHERE id='$id'"; $result = mysqli_query($conn, $sql2) or mysqli_error($conn); $msgs[] = "Query deleted successfully."; $body = "account.php"; } yes it can delete entries all right but it doesn't delete a specific entry when i click the "delete" button near it somehow, it ALWAYS deletes the last row of entry at the table as you can see, i echoed out $id as it's referring to the LAST entry as well So my question is, how to delete a particular entry when i click the corresponding "delete" button?? Thanks Hi guys
I'll try keep this simple
I have been given access to a betting xml feed which requires my IP to be whitelisted.
I have whitelisted my home IP and it works fine.
I have whitelisted an IP on server 1 (linux, cpanel), this works fine
I have whitelisted an IP on server 2 (linux, cpanel), this doesn't work and I get:
"simplexml_load_file failed to open stream: http request failed!"
The IP is definitely whitelisted but I think it is something to do with the server. What could be blocking this?
allow_url_fopen and allow_url_include are both on by the way
Many thanks
Sam
New to PHP, I wrote a shortcode to use in WP that outputs a nav bar with some icons. One will link to a url, one to a pop up plugin (through a class), and one a phone number. The shortcode will then look like this [footer-btn url="link here "]Name of Icon Here[/footer-btn] Right now when I put the short codes into word press, I get duplicates of the URL ones. function footer_btn_function($atts, $content){ extract( shortcode_atts( array( 'class' => '', 'phone' => '', 'url' => '' ), $atts ) ); if($class){ '<a class="text-link" href='.$class.'><img class="popmake-73310 footer-btn mobile" src="'.get_template_directory_uri().'/images/faq-mobile-white.png">'.$content.'</a>'; } if($phone){ $output .= '<a class="text-link" href="tel:'.$phone.'" target="_blank"><img class="footer-btn mobile" src="'.get_template_directory_uri().'/images/phone-mobile-white.png">'.$content.'</a>'; }; if($url){ $output .= '<a class="text-link" href="tel:'.$url.'" target="_blank"><img class="footer-btn mobile" src="'.get_template_directory_uri().'/images/vacation-rentals-mobile-white.png">'.$content.'</a>'; }; if($url){ $output .= '<a class="text-link" href="tel:'.$url.'" target="_blank"><img class="footer-btn mobile" src="'.get_template_directory_uri().'/images/chat-mobile-white.png">'.$content.'</a>'; }; return $output; }
<?php class booking_diary { // Mysqli connection function __construct($link) { $this->link = $link; } // Settings you can change: // Time Related Variables public $booking_start_time = "09:00"; // The time of the first slot in 24 hour H:M format public $booking_end_time = "13:00"; // The time of the last slot in 24 hour H:M format public $booking_frequency = 02; // The slot frequency per hour, expressed in minutes. //$date = new DateTime(); //$Pdate-> setDate(2020, 10, 29); // Day Related Variables public $day_format = 1; // Day format of the table header. Possible values (1, 2, 3) // 1 = Show First digit, eg: "M" // 2 = Show First 3 letters, eg: "Mon" // 3 = Full Day, eg: "Monday" public $day_closed = array("Saturday", "Sunday"); // If you don't want any 'closed' days, remove the day so it becomes: = array(); //public $Special_day = array() public $day_closed_text = "CLOSED"; // If you don't want any any 'closed' remove the text so it becomes: = ""; // Cost Related Variables public $cost_per_slot = 20.00; // The cost per slot public $cost_currency_tag = "£"; // The currency tag in HTML such as € £ ¥ // DO NOT EDIT BELOW THIS LINE public $day_order = array("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"); public $day, $month, $year, $selected_date, $back, $back_month, $back_year, $forward, $forward_month, $forward_year, $bookings, $count, $days, $is_slot_booked_today; /*========================================================================================================================================================*/ function make_calendar($selected_date, $back, $forward, $day, $month, $year) { // $day, $month and $year are the $_GET variables in the URL $this->day = $day; $this->month = $month; $this->year = $year; // $back and $forward are Unix Timestamps of the previous / next month, used to give the back arrow the correct month and year $this->selected_date = $selected_date; $this->back = $back; $this->back_month = date("m", $back); $this->back_year = date("Y", $back); // Minus one month back arrow $this->forward = $forward; $this->forward_month = date("m", $forward); $this->forward_year = date("Y", $forward); // Add one month forward arrow // Make the booking array $this->make_booking_array($year, $month); } function make_booking_array($year, $month, $j = 0) { $stmt = $this->link->prepare("SELECT name, date, start FROM bookings WHERE date LIKE CONCAT(?, '-', ?, '%')"); $this->is_slot_booked_today = 0; // Defaults to 0 $stmt->bind_param('ss', $year, $month); $stmt->bind_result($name, $date, $start); $stmt->execute(); $stmt->store_result(); while($stmt->fetch()) { $this->bookings_per_day[$date][] = $start; $this->bookings[] = array( "name" => $name, "date" => $date, "start" => $start ); // Used by the 'booking_form' function later to check whether there are any booked slots on the selected day if($date == $this->year . '-' . $this->month . '-' . $this->day) { $this->is_slot_booked_today = 1; } } // Calculate how many slots there are per day $this->slots_per_day = 0; for($i = strtotime($this->booking_start_time); $i<= strtotime($this->booking_end_time); $i = $i + $this->booking_frequency * 60) { $this->slots_per_day ++; } $stmt->close(); $this->make_days_array($year, $month); } // Close function function make_days_array($year, $month) { // Calculate the number of days in the selected month $num_days_month = cal_days_in_month(CAL_GREGORIAN, $month, $year); // Make $this->days array containing the Day Number and Day Number in the selected month for ($i = 1; $i <= $num_days_month; $i++) { // Work out the Day Name ( Monday, Tuesday... ) from the $month and $year variables $d = mktime(0, 0, 0, $month, $i, $year); // Create the array $this->days[] = array("daynumber" => $i, "dayname" => date("l", $d)); } /* Sample output of the $this->days array: [0] => Array ( [daynumber] => 1 [dayname] => Monday ) [1] => Array ( [daynumber] => 2 [dayname] => Tuesday ) */ $this->make_blank_start($year, $month); $this->make_blank_end($year, $month); } // Close function function make_blank_start($year, $month) { /* Calendar months start on different days Therefore there are often blank 'unavailable' days at the beginning of the month which are showed as a grey block The code below creates the blank days at the beginning of the month */ // Get first record of the days array which will be the First Day in the month ( eg Wednesday ) $first_day = $this->days[0]['dayname']; $s = 0; // Loop through $day_order array ( Monday, Tuesday ... ) foreach($this->day_order as $i => $r) { // Compare the $first_day to the Day Order if($first_day == $r && $s == 0) { $s = 1; // Set flag to 1 stop further processing } elseif($s == 0) { $blank = array( "daynumber" => 'blank', "dayname" => 'blank' ); // Prepend elements to the beginning of the $day array array_unshift($this->days, $blank); } } // Close foreach } // Close function function make_blank_end($year, $month) { /* Calendar months start on different days Therefore there are often blank 'unavailable' days at the end of the month which are showed as a grey block The code below creates the blank days at the end of the month */ // Add blank elements to end of array if required. $pad_end = 7 - (count($this->days) % 7); if ($pad_end < 7) { $blank = array( "daynumber" => 'blank', "dayname" => 'blank' ); for ($i = 1; $i <= $pad_end; $i++) { array_push($this->days, $blank); } } // Close if $this->calendar_top(); } // Close function function calendar_top() { // This function creates the top of the table containg the date and the forward and back arrows echo " <div id='lhs'><div id='outer_calendar'> <table border='0' cellpadding='0' cellspacing='0' id='calendar'> <tr id='week'> <td align='left'><a href='?month=" . date("m", $this->back) . "&year=" . date("Y", $this->back) . "'>«</a></td> <td colspan='5' id='center_date'>" . date("F, Y", $this->selected_date) . "</td> <td align='right'><a href='?month=" . date("m", $this->forward) . "&year=" . date("Y", $this->forward) . "'>»</a></td> </tr> <tr>"; /* Make the table header with the appropriate day of the week using the $day_format variable as user defined above Definition: 1: Show First digit, eg: "M" 2: Show First 3 letters, eg: "Mon" 3: Full Day, eg: "Monday" */ foreach($this->day_order as $r) { switch($this->day_format) { case(1): echo "<th>" . substr($r, 0, 1) . "</th>"; break; case(2): echo "<th>" . substr($r, 0, 3) . "</th>"; break; case(3): echo "<th>" . $r . "</th>"; break; } // Close switch } // Close foreach echo "</tr>"; $this->make_cells(); } // Close function function make_cells($table = '') { echo "<tr>"; foreach($this->days as $i => $r) { // Loop through the date array $j = $i + 1; $tag = 0; // If the the current day is found in the day_closed array, bookings are not allowed on this day if(in_array($r['dayname'], $this->day_closed)) { echo "\r\n<td width='21' valign='top' class='closed'>" . $this->day_closed_text . "</td>"; $tag = 1; } // Past days are greyed out if (mktime(0, 0, 0, $this->month, sprintf("%02s", $r['daynumber']) + 1, $this->year) < strtotime("now") && $tag != 1) { echo "\r\n<td width='21' valign='top' class='past'>"; // Output day number if($r['daynumber'] != 'blank') echo $r['daynumber']; echo "</td>"; $tag = 1; } // If the element is set as 'blank', insert blank day if($r['dayname'] == 'blank' && $tag != 1) { echo "\r\n<td width='21' valign='top' class='unavailable'></td>"; $tag = 1; } // Now check the booking array $this->booking to see whether we have a booking on this day $current_day = $this->year . '-' . $this->month . '-' . sprintf("%02s", $r['daynumber']); if(isset($this->bookings_per_day[$current_day]) && $tag == 0) { $current_day_slots_booked = count($this->bookings_per_day[$current_day]); if($current_day_slots_booked < $this->slots_per_day) { echo "\r\n<td width='21' valign='top'> <a href='calendar.php?month=" . $this->month . "&year=" . $this->year . "&day=" . sprintf("%02s", $r['daynumber']) . "' class='part_booked' title='This day is part booked'>" . $r['daynumber'] . "</a></td>"; $tag = 1; } else { echo "\r\n<td width='21' valign='top'> <a href='calendar.php?month=" . $this->month . "&year=" . $this->year . "&day=" . sprintf("%02s", $r['daynumber']) . "' class='fully_booked' title='This day is fully booked'>" . $r['daynumber'] . "</a></td>"; $tag = 1; } // Close else } // Close if if($tag == 0) { echo "\r\n<td width='21' valign='top'> <a href='calendar.php?month=" . $this->month . "&year=" . $this->year . "&day=" . sprintf("%02s", $r['daynumber']) . "' class='green' title='Please click to view bookings'>" . $r['daynumber'] . "</a></td>"; } // The modulus function below ($j % 7 == 0) adds a <tr> tag to every seventh cell + 1; if($j % 7 == 0 && $i >1) { echo "\r\n</tr>\r\n<tr>"; // Use modulus to give us a <tr> after every seven <td> cells } } echo "</tr></table></div><!-- Close outer_calendar DIV -->"; if(isset($_GET['year'])) $this->basket(); echo "</div><!-- Close LHS DIV -->"; // Check booked slots for selected date and only show the booking form if there are available slots $current_day = $this->year . '-' . $this->month . '-' . $this->day; $slots_selected_day = 0; if(isset($this->bookings_per_day[$current_day])) $slots_selected_day = count($this->bookings_per_day[$current_day]); if($this->day != 0 && $slots_selected_day < $this->slots_per_day) { $this->booking_form(); } } // Close function function booking_form() { echo " <div id='outer_booking'><h2>Available Slots</h2> <p> The following slots are available on <span> " . $this->day . "-" . $this->month . "-" . $this->year . "</span> </p> <table width='400' border='0' cellpadding='2' cellspacing='0' id='booking'> <tr> <th width='150' align='left'>Start</th> <th width='150' align='left'>End</th> <th width='150' align='left'>Price</th> <th width='20' align='left'>Book</th> </tr> <tr> <td> </td><td> </td><td> </td><td> </td> </tr>"; // Create $slots array of the booking times for($i = strtotime($this->booking_start_time); $i<= strtotime($this->booking_end_time); $i = $i + $this->booking_frequency * 60) { $slots[] = date("H:i:s", $i); } // Loop through $this->bookings array and remove any previously booked slots if($this->is_slot_booked_today == 1) { // $this->is_slot_booked_today created in function 'make_booking_array' foreach($this->bookings as $i => $b) { if($b['date'] == $this->year . '-' . $this->month . '-' . $this->day) { // Remove any booked slots from the $slots array $slots = array_diff($slots, array($b['start'])); } // Close if } // Close foreach } // Close if // Loop through the $slots array and create the booking table foreach($slots as $i => $start) { // Calculate finish time $finish_time = strtotime($start) + $this->booking_frequency * 60; echo " <tr>\r\n <td>" . $start . "</td>\r\n <td>" . date("H:i:s", $finish_time) . "</td>\r\n <td>" . $this->cost_currency_tag . number_format($this->cost_per_slot, 2) . "</td>\r\n <td width='110'><input data-val='" . $start . " - " . date("H:i:s", $finish_time) . "' class='fields' type='checkbox'></td> </tr>"; } // Close foreach echo "</table></div><!-- Close outer_booking DIV -->"; } // Close function function basket($selected_day = '') { if(!isset($_GET['day'])) $day = '01'; else $day = $_GET['day']; // Validate GET date values if(checkdate($_GET['month'], $day, $_GET['year']) !== false) { $selected_day = $_GET['year'] . '-' . $_GET['month'] . '-' . $day; } else { echo 'Invalid date!'; exit(); } echo "<div id='outer_basket'> <h2>Selected Slots</h2> <div id='selected_slots'></div> <div id='basket_details'> <form method='post' action='book_slots.php'> <label>Name</label> <input name='name' id='name' type='text' class='text_box'> <label>Email</label> <input name='email' id='email' type='text' class='text_box'> <label>Phone</label> <input name='phone' id='phone' type='text' class='text_box'> <div id='outer_price'> <div id='currency'>" . $this->cost_currency_tag . "</div> <div id='total'></div> </div> <input type='hidden' name='slots_booked' id='slots_booked'> <input type='hidden' name='cost_per_slot' id='cost_per_slot' value='" . $this->cost_per_slot . "'> <input type='hidden' name='booking_date' value='" . $_GET['year'] . '-' . $_GET['month'] . '-' . $day . "'> <input type='submit' class='classname' value='Make Booking'> </form> </div><!-- Close basket_details DIV --> </div><!-- Close outer_basket DIV -->"; } // Close function } // Close Class ?> Edited October 29, 2020 by requinix please use the Code <> button when posting code Hy i have a GIT repo on a specific location and i need to exec it. so i tooth it was like exec git reset --hard but it executes the command as it was on the base root location. I need before i execute the command to go to my GIT repo location. Can someone help me out? I read about it here http://www.linuxjournal.com/content/bash-redirections-using-exec and if i get it i need a named pipe... but i don't get how i can do it ~.~ i am a exec newbie. Hi guys, i was having an issue with dates and although it leans a bit more into MYSQL I was hoping i could get some help ive searched all over the net for this so I dont know if im not thinking on how to ask this correctly or can't find it, but ill be as detailed as possible and hope that helps.
Ok I have a table that shows when payment was received on past invoices dating back to say 1995; The company processes 'ALL' invoices every month on the 9th, so if anything comes in from the first to the ninth it will be processed that month on the ninth. If it comes in from the tenth to the thirtieth or thirty-first it will be processed the following month.
The table already has a "Received" date filed and now I want to create a column on the table called "Processed Date" (adding the column is no problem don't need help with that part) that shows me the date we processed the invoice.
I know i have to use the "Received" field (because it shows what day the invoice was put into the system) but im not sure how to format the "Processed Date" field, so say the "Received" field shows an invoice came in on '1995-05-11', I want the "Processed Date" field to display it was payed on '1995-06-09' (notice that is the following month).
I thought i would put in a visual of what I was trying to do below:
So if I pull the two columns in MYSQL from that table I would see something like this:
Received Processed Date
1996-02-03 1996-02-09
1996-03-03 1996-03-09
1996-04-11 1996-05-09
1996-05-20 1996-06-09
1996-07-13 1996-08-09
If i could get some guidance/help on this i would really appreciate it.
thanks in advance!!
JL
|