Jump to content

Search the Community

Showing results for tags 'conversion'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start





Website URL








Donation Link

Found 9 results

  1. PLEASEEE no matter what i do... datepicker always post the dates as string i do whatever ways know convert string to date but no way!! how convert string to date so i can sarch in a mysql table... tnx in advanced <!--HTML--> <div class="control-group"> <label class="control-label">from</label> <div class="controls input-append date form_date" data-date="" data-date-format='yyyy/mm/dd' data-link-format="yyyy/mm/dd"> <input size="16" type="text" value="" id="from" name="from"> <span class="add-on"><i class="icon-th"></i></span> </div> <input type="hidden" id="d" value="" /><br/> </div> <div class="control-group"> <label class="control-label">tto</label> <div class="controls input-append date form_date" data-date="" data-date-format='yyyy/mm/dd' data-link-format="yyyy/mm/dd"> <input size="16" type="text" value="" id="tto" name="tto"> <span class="add-on"><i class="icon-th"></i></span> </div> <input type="hidden" id="h" value="" /><br/> </div> <div class="card-body"> <button type="submit" class="btn btn-secondary">search...</button> </div> <!--PHP--> $yfromx=$_POST['from'] ; $yuntilly=$_POST['untill'] ; $yfroma=str_replace(" ","/","$yfromx"); $yuntillb=str_replace(" ","/","$yuntilly"); $t1=gettype ( $yfromx ) ; $t2=gettype ( $yuntilly ) ; $yfrom=date('Y/m/d', '$yfroma'); $yuntill=date('Y/m/d', '$yuntillb'); $t3=gettype ( $yfrom ) ; $t4=gettype ( $yuntill ) ; echo $yfroma.' | '.$yuntillb.' | '.$t1.' | '. $t2.' | '.$t3.' | '. $t4; //SELECT username FROM oc_calendar WHERE start_date between '$from' AND '$to' $queryfebus = "SELECT distintc FROM glamm_pedidos WHERE fecha_folio between '$yfrom' AND '$yuntill';"; //$queryfolb = "SELECT *M glamm_pedidos WHERE procesado='$yfoliox' or folio='$yfoliox' or nombre like '%$yfoliox%' or mail like '%$yfoliox%';"; $resultfebus = mysqli_query($con,$queryfebus) or mysqli_error($con); blah blah
  2. $results = mysql_query("$select", $link_id); while ($query_data = mysql_fetch_row($results)) { $link_id = mysqli_connect("$db_host","$db_user","$db_password","$db_database"); if ($mysqli->connect_errno) { echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error; } $link_id = mysql_connect("$db_host","$db_user","$db_password"); if (mysql_select_db("$db_database", $link_id)); else { echo "connection failed."; } I am having to update MySQL to mysqli as my host is upgrading to PHP5.6 I have managed to convert and connect to the database converted to I cannot get the fetch results to work, can anyone help me convert the following code Many Thanks
  3. Hello to everyone! I've got a script written in php4 and would like to convert it to php5, I can't find either a paid or open source version of any script similar. I don't know enough to do this myself, but can work it all out if someone could give me a hand with this first part, how would this be written in php5? <?php session_start(); // Require standard files include("./require/config.php"); require("./require/authmember.php"); require("./require/functions.php"); include("./include/get_config.inc.php"); $content="./include/index.inc.php"; if(session_is_registered("valid_user")) { $menu="./include/menu_v.inc.php"; } else { $menu="./include/menu_u.inc.php"; } //Page Description $page_title="Welcome to $site_name"; //Meta description tag $description=""; //Meta keywords tag $keywords=""; include("./include/header.inc.php"); include("./include/body.inc.php"); include("./include/footer.inc.php"); ?> Your help would be most appreciated, thanks in advance.
  4. Hello fellas I have been working on this piece of php for over a week now and I have got a few questions. 1. Where is the $selected_date is being read from ? given that this is a unixtime stamp format , should it not get converted with date function ? The code however is working fine with Gregorian calendar but with persian calendar time conversion , the $selected_date returns as year 1970 instead of 2014. 2. by clicking <a href='calendar.php?month=" . $this->month . "&year=" . $this->year . "&day=" . sprintf("%02s", $daynumber) . "'> what function is being called ? ** the make_time and mds_date are actually from a separated php class which is responsible for the date year and day conversion <?php include 'PersianCalendar.php'; //require_once("PersianCalendar.php"); date_default_timezone_set("Asia/Tehran"); class booking_diary { // Mysqli connection function __construct($link) { $this->link = $link; } /* Settings you can change: $booking_start_time: The time of the first slot $booking_end_time: The time of the last slot $booking_frequency: The amount of slots per hour, expressed in minutes $booking_slots_per_day: The total number of slots avaliable in one day */ public $current_day; public $booking_start_time = "09:00"; public $booking_end_time = "19:00"; public $booking_frequency = 120; public $booking_slots_per_day = 10; public $day, $month, $year, $selected_date, $first_day, $back, $back_month, $back_year, $forward, $forward_month, $forward_year, $bookings, $count, $days; /*========================================================================================================================================================*/ function make_calendar($selected_date, $first_day, $back, $forward, $day, $month, $year) { //persian starts here $year = mds_date("Y"); $chand = mds_date("m"); $fdchand = mds_date("D", make_time(0,0,0,$chand,01,$year)); //going back persian starts $curmonth = mds_date("m", time()); $month = mds_date("m"); $curyear = mds_date("Y", time()); if($curmonth=='01') { $monthnominat = 12; $yearnominat = $curyear-1; } else { $monthnominat = $curmonth-1; $yearnominat = $curyear; } echo date("d m Y" ,$selected_date); $this->current_day = $day; $faselected = mds_date("d, m, Y", $selected_date); var_dump($faselected); $back = make_time(1, 1, 1, $monthnominat, 1, $yearnominat); ////////////////////////////////////////////////////////////////////////////////////////////////////////////// if (empty($selected_date)) { $parts = explode(",", $faselected); $this->month = $parts[1]; $this->day = $parts[0]; $this->year = $parts[2]; $first_day = $this->chandom(mds_date("D", make_time(0, 0, 0, $this->month, 1, $this->year))); $check = 2; } else { $this->day = 0; $this->month = mds_date("m"); $this->year = mds_date("Y"); $first_day = $this->chandom($fdchand); $check = 1; } // Add a value to these public variables echo "<br />"; echo $check; $this->back = $back; $this->back_month = mds_date("m", $back); $this->back_year = mds_date("Y", $back); // Minus one month back arrow $this->selected_date = make_time(24, 0, 0, $this->month, $this->day, $this->year); $this->first_day = $first_day; $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); echo mds_date("F Y", $this->selected_date); } function make_booking_array($year, $month) { $query = "SELECT * FROM bookings WHERE date LIKE '$year-$month%'"; $result = mysqli_query($this->link, $query) or die(mysqli_error($this->link)); $this->count = mysqli_num_rows($result); $this->bookings = ''; while ($row = mysqli_fetch_array($result)) { $this->bookings[] = array( "name" => $row['name'], "date" => $row['date'], "start" => $row['start'], "comments" => $row['comments'] ); } $this->make_days_array( $this->year, $this->month); } // Close function function make_days_array($year, $month) { // Create an array of days in the month //$num_days_month = cal_days_in_month(CAL_GREGORIAN, $month, $year); $num_days_month = dim($month, $year); // Make array called $day with the correct number of days for ($i = 1; $i <= $num_days_month; $i++) { $d = make_time(0, 0, 0, $month, $i, $year); $this->days[] = array("daynumber" => $i, "dayname" => mds_date("l", $d)); } // Add blank elements to start of array if the first day of the month is not a Monday. for ($j = 1; $j <= $this->first_day; $j++) { array_unshift($this->days, '0'); } // Add blank elements to end of array if required. $pad_end = 7 - (count($this->days) % 7); if ($pad_end < 7) { for ($j = 1; $j <= $pad_end; $j++) { array_push($this-> days, '|'); } } // Close if $this->make_table_top(); } // Close function function make_table_top() { echo " <div class='left'> <table border='0' cellpadding='0' cellspacing='0' id='calendar'> <tr id='week'> <td align='left'><a href='?month=" . mds_date("m", $this->back) . "&year=" . mds_date("Y", $this->back) . "'>«</a></td> <td colspan='5' id='center_date'>" . mds_date("F Y", $this->selected_date) . "</td> <td align='right'><a href='?month=" . mds_date("m", $this->forward) . "&year=" . mds_date("Y", $this->forward) . "'>»</a></td> </tr> <tr> <th>شنبه</th><th>یکشنبه</th><th>دوشنبه</th><th>سه شنبه</th><th>چهارشنبه</th><th>پنجشنبه</th><th>جمعه</th>"; $this->make_day_boxes($this->days, $this->bookings, $this->month, $this->year); } // Close function function make_day_boxes() { $i=0; foreach ($this->days as $row) { $tag = ''; if($i % 7 == 0) echo "</tr><tr>"; // Use modulus to give us a <tr> after every seven <td> cells if(isset($row['daynumber']) && $row['daynumber'] != 0) { // Padded days at the start of the month will have a 0 at the beginning echo "<td width='21' valign='top' class='days'>"; if ($this->count > 0) { $day_count = 0; foreach ($this->bookings as $booking_date) { if ($booking_date['date'] == $this->year . '-' . $this->month . '-' . sprintf("%02s", $row['daynumber'])) { $day_count++; } // Close if } // Close foreach } // Close if $count // Work out which colour day box to show if ($row['dayname'] == 'جمعه') $tag = 2; // It's a friday if (make_time(0, 0, 0, $this->month, sprintf("%02s", $row['daynumber']) + 1, $this->year) < strtotime("now")) $tag = 4; // Past Day if ($day_count >= $this->booking_slots_per_day && $tag == '') $tag = 3; if ($day_count >0 && $tag == '') $tag = 1; echo $this->day_switch($tag, $row['daynumber']) . "<span>" . str_replace('|', ' ', $row['daynumber']) . "</span></td>"; } else { echo "<td width='21' valign='top' class='days'><img src='images/block_null.gif' title='مجاز به انتخاب نیستید' alt=''></td>"; } $i++; } // Close foreach $this->make_key(); } // Close function function day_switch($tag, $daynumber) { switch ($tag) { case (1): // Part booked day $txt = "<a href='calendar.php?month=" . $this->month . "&year=" . $this->year . "&day=" . sprintf("%02s", $daynumber) . "'> <img src='images/block_part.gif' title='ساعاتی رزرو شده' border='0' alt=''></a>\r\n"; break; case (2): // friday $txt = "<img src='images/block_sunday.gif' title='روز تعطیل است' border='0' alt=''>\r\n"; break; case (3): // Fully booked day $txt= "<img src='images/block_fully_booked.gif' title='کامل رزرو شده' border='0' alt=''>\r\n"; break; case (4): // Past day $txt = "<img src='images/block_past.gif' title='از تاریخ امروز گذشته' border='0' alt=''></a>\r\n"; break; case (5): // Block booked out day $txt= "<img src='images/block_fully_booked.gif' title='این روز موجود نیست' border='0' alt=''>\r\n"; break; default: // FREE $txt = "<a href='calendar.php?month=" . $this->month . "&year=" . $this->year . "&day=" . sprintf("%02s", $daynumber) . "'> <img src='images/block_free.gif' title='آزاد برای رزرو' border='0' alt=''></a>\r\n"; break; } return $txt; } // Close function function make_key() { // This key is displayed below the calendar to show what the colours represent echo "</tr></table> <table border='0' id='key' cellpadding='2' cellspacing='6'> <tr> <td id='key_1'> </td> <td id='key_2'> </td> <td id='key_3'> </td> <td id='key_4'> </td> <td id='key_5'> </td> </tr> <tr> <td>نبود وقت</td> <td>روز تعطیل</td> <td>حداقل یک وقت رزرو موجود است</td> <td>آزاد</td> <td>گذشته</td> </tr> </table></div>"; $this->make_booking_slots(); } // Close function function make_booking_slots() { /* Variable $day has a default value of 0. If a day has been clicked on, display it. If there is no date selected, show a msg. Otherwise show the booking form. */ if($this->day == 0) { $this->select_day(); } else { $this->make_form(); } } // Close function function select_day() { echo "<form method='post' action=''><div id='selected_date'>لطفا روز رزرواسیون را انتخاب کنید</div>"; } function make_form() { // Create 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); } echo "\r\n\r\n<form method='post' action=''><div id='selected_date'>تاریخ انتخاب شده: " . $this->month.",". $this->current_day.",". $this->year . "</div>"; $opt = "<select id='select' name='booking_time'><option value='selectvalue'>لطفا زمان رزرواسیون را انتخاب کنید</option>"; if($this->count >= 1) { foreach($this->bookings as $row) { // Check for bookings and remove any previously booked slots foreach($slots as $i => $r) { if($row['start'] == $r && $row['date'] == $this->year . '-' . $this->month . '-' . $this->day) { unset($slots[$i]); } } // Close foreach } // Close foreach } // If count bookings // Make select box from $slots array foreach($slots as $booking_time) { $finish_time = strtotime($booking_time)+ $this->booking_frequency * 60; // Calculate finish time $opt .= "<option value='" . $booking_time . "'>" . $booking_time . " - " . date("H:i:s", $finish_time) . "</option>"; } echo $opt. "</select>"; echo " <table width='300' border='0' id='booking'> <tr> <td class='details'>اسم و فامیلی</td> <td><input class='input' type='text' name='name' size='32'"; if(isset($_POST['name'])) echo " value='" . $_POST['name'] . "'"; echo "></td> </tr> <tr> <td class='details'>ایمیل</td> <td><input class='input' type='text' name='email' size='32'"; if(isset($_POST['email'])) echo " value='" . $_POST['email'] . "'"; echo "></td> </tr> <tr> <td class='details'>تلفن</td> <td><input class='input' type='text' name='phone' size='32'"; if(isset($_POST['phone'])) echo " value='" . $_POST['phone'] . "'"; echo "></td> </tr> <tr> <td class='details'>پیام</td> <td><textarea rows='3' cols='30' name='comments' onclick='make_blank();'>"; if(isset($_POST['comments'])) echo $_POST['comments']; echo "</textarea></td> </tr> <tr> <td> </td> <td> <input type='submit' value='' id='book'></td> </tr> </table></form>"; } function after_post($month, $day, $year) { $alert=''; $msg=0; if(isset($_POST['name']) && empty($_POST['name'])) { $msg = 1; $alert .= "Please fill in the name box<br>"; } if(isset($_POST['email']) && empty($_POST['email'])) { $msg = 1; $alert .= "Please fill in the email box<br>"; } if(isset($_POST['phone']) && empty($_POST['phone'])) { $msg = 1; $alert .= "Please add a contact number<br>"; } if(isset($_POST['booking_time']) && $_POST['booking_time'] == 'selectvalue') { $msg = 1; $alert .= "Please select a booking time"; } if($msg == 1) { echo "<div class='error'>" . $alert . "</div>"; } elseif($msg == 0) { $booking_date = mds_date("Y-m-d", make_time(0, 0, 0, $month, $day, $year)); $booking_time = $_POST['booking_time']; $query = "INSERT INTO bookings (date, start, name, email, phone, comments) VALUES ('$booking_date', '$booking_time', '$_POST[name]', '$_POST', '$_POST[phone]', '$_POST[comments]')"; $result = mysqli_query($this->link, $query) or die(mysqli_error($this->link)); $this->confirm(); } // Close else } // Close function function chandom($fdchand) { if($fdchand=='ج') { $first_day = 6; } if($fdchand=='پ') { $first_day = 5; } if($fdchand=='چ') { $first_day = 4; } if($fdchand=='س') { $first_day = 3; } if($fdchand=='د') { $first_day = 2; } if($fdchand=='ى') { $first_day = 1; } if($fdchand=='ش') { $first_day = 0; } return $first_day; } function confirm() { echo "<div class='success'>وقت شما رزرو شد، لطفا برای اطلاعات بیشتر با دفتر تماس بگیرید</div>"; } // Close function } // Close Class ?>
  5. I downloaded a free template from a website and I want to customize it in PHP but I don't know how. Here is a link to the files: http://deadshotcolada.net/megacorporate.zip I need someone to do this for me please. - I want to add a member's login on the left hand side of the page in the sidebar in the place of the sidebar menu (I want the menu moved down). I want it to show member links when logged in already (in the same format as the sidebar menu). - I want to swap the "Wise Words" section of the sidebar for an advertisement. (I will provide the advertisement so I just need a place for the html) - I want Facebook, Twitter, YouTube, and Google+ icons to the right of the menu items at the top that highlight the same way. (They will link to my pages) - I want to be able to make the form on the 'contact' page work and be able to customize it. - I want the buttons on the home page (the 1, 2, 3, page switching buttons) to be working and make it load more content on that same page. - I want the 'blog' section working so that members can leave replies if they have permission. - I want the 'image gallery' at the bottom of each page to show a random image from a list accompanied by a link that I provide for each image. (I also want to provide the images of course.) - I want an advertisement control page in an admin panel (mydomain.com/admin - allow me to change the path) that allows me to enter code for different ad dimensions and then insert each ad easier on each page. -I want member control from the admin panel. -I want template color control from the admin panel. -I want to be able to edit each and every page's content from the admin panel. -I want to be able to create new pages, upload images and files, and manage every aspect of a page from the admin panel. -I want members to have an area where they can upload files which I can download from the admin panel. -I want members to be able to pay a fee (via PayPal) to download a file. (I set the fee amount when uploading the file). -I want to be able to add a file download button to any page of the site that allows me to specify which file they download. (The file location cannot be revealed by looking at code). -I want to be able to make pages accessible by members only from the admin panel. -I want to be able to IP ban people. I also want to be able to block email addresses. -I want to be able to make it so that in order to download a file that does not have a fee, people must post about it on Facebook or Twitter and watch an advertisement first. (I set the time that they have to watch it for - from the admin panel) -I want to be able to have a mailing list that saves an email address when connecting to Facebook or Twitter and has member's email addresses saved in it. (No duplicates) (I must be able to view the list and send a mass email out from the admin panel). -All pages must load fast. I want images to be compressed when uploaded from the admin panel to reduce filesize but maintain image quality. (Image formats must stay the same as uploaded, just losslessly compressed.) -I want to be able to embed a YouTube video onto a page from the admin panel. (I supply the link. Dimensions are auto-fit unless specified.) -I want to be able to have individual favicons for each page, or the default if I don't upload one. -I want members to be able to upload a profile photo and add information about themselves. I want each member to have their own profile page. -I want misspelled words to be highlighted as in Microsoft Word. -I want a profanity filter (I set the words to filter) on all member content unless I turn it off from the admin panel. -I want to be able to manually add or edit member info and create new members as well as delete them. -I want to be able to track member usage. (Last login, last IP used, all IP's used, times logged in, members currently online, new members (today, this week, this month, this year), etc.) I also want to be able to track total website visits by the hour, day, week, month, year. -I want visitors to be able to share any page on Facebook, Twitter, Google+, etc by clicking a button. I believe that is all that I want done to this template. There is no rush on the time it needs to be done by, I just want it as soon as possible. I can pay for this to be done but I am limited on the amount. If everything I listed is added, I can pay around $100 USD for this given I see a demo first to make sure that it is the way I like it. Please contact me via email at support@devonmiller.net to discuss anything regarding this project. I can't have any bugs as I will be uploading this to a domain that gets hundreds of hits per day. This will be replacing my current template which can be seen at http://www.deadshotcolada.net/. Thanks!
  6. I wrote the following code to create a set of 12 php calendars to display specific entries from a database. I have found many posts about converting a date into an integer but can find nothing to convert an integer into a date or more specifically in this case a month. The interesting thing about all of this is that it accepts and integer as a string in a concatinated set of values initially but won't accept the $month after the change at the end of the code when it returns to continue the loop. Can anyone tell me where I'm going wrong here? <?php $month = date("m"); // Initate $month to current month $twelveCount = '1'; // Set count to 1 for loop while($twelveCount != '13') { // Create loop condition to break at 13 producing 12 calendars $monthName = date("F", strtotime($month)); // Grab name of month from $month variable $year = date("Y"); // Initiate $year from current year $firstDate = $month . '/01/' . $year; // Calculate first day of the month, NOTE: It accepts the string integer here; $firstDay = date("D", strtotime($firstDate)); // Grab day of the first date $firstDay = strtoupper($firstDay); // Capitalise first day string $lastDay = cal_days_in_month(CAL_GREGORIAN, $month, $year); // Grab last day of the month $i = '1'; // Set integer to 1 for begining of auto incremental date display $lastDayPlusOne = $lastDay + 1; // Set limit for loop break when days are complete if ($firstDay == 'SUN') {$skipDays = '0';} // Skip spaces on calendar to equal actual first day if ($firstDay == 'MON') {$skipDays = '1';} if ($firstDay == 'TUE') {$skipDays = '2';} if ($firstDay == 'WED') {$skipDays = '3';} if ($firstDay == 'THU') {$skipDays = '4';} if ($firstDay == 'FRI') {$skipDays = '5';} if ($firstDay == 'SAT') {$skipDays = '6';} $count = '0'; // Iniate $count for loop break when first day is in the correct position $calendarDisplay .= '<div style="float:left; width:182px; margin:0px 0px 7px 7px;"> <div style="float:left; width:161px; text-align:left; margin-bottom:5px;">' . $monthName . ' ' . $year . '</div> <div style="float:left; width:23px; margin:0px 3px 3px 0px; background-color:#CCC; font-size:10px; text-align:center;">SUN</div> <div style="float:left; width:23px; margin:0px 3px 3px 0px; background-color:#CCC; font-size:10px; text-align:center;">MON</div> <div style="float:left; width:23px; margin:0px 3px 3px 0px; background-color:#CCC; font-size:10px; text-align:center;">TUE</div> <div style="float:left; width:23px; margin:0px 3px 3px 0px; background-color:#CCC; font-size:10px; text-align:center;">WED</div> <div style="float:left; width:23px; margin:0px 3px 3px 0px; background-color:#CCC; font-size:10px; text-align:center;">THU</div> <div style="float:left; width:23px; margin:0px 3px 3px 0px; background-color:#CCC; font-size:10px; text-align:center;">FRI</div> <div style="float:left; width:23px; margin:0px 3px 3px 0px; background-color:#CCC; font-size:10px; text-align:center;">SAT</div> <div style="float:left; width:182px;">'; // Create day names for header while($count != $skipDays) { // Output spaces to match day of the week before dates begin $calendarDisplay .= '<div style="float:left; width:23px; padding:4px 0; margin:0px 3px 3px 0px;"></div>'; $count++; } while($i != $lastDayPlusOne) { // Output dates inline with days in header $calendarDisplay .= '<div style="float:left; padding:4px 0; width:23px; margin:0px 3px 3px 0px; background-color:#0C0; font-size:10px; text-align:center;">' . $i . '</div>'; $i++; } $calendarDisplay .= '</div></div>'; // End calendar display // This is where it all goes wrong... if ($month == date("m", strtotime("1/10/10"))) {$month = date("m", strtotime("2/10/10")); echo $month;} if ($month == '02') {$month = date("m", strtotime("3/10/10")); echo $month;} if ($month == '03') {$month = '04'; echo $month;} /* if ($month == '04') {$month = date("m", strtotime("5/10/10")); echo $month;} if ($month == '05') {$month = date("m", strtotime("6/10/10")); echo $month;} if ($month == '06') {$month = date("m", strtotime("7/10/10")); echo $month;} if ($month == '07') {$month = date("m", strtotime("8/10/10")); echo $month;} if ($month == '08') {$month = date("m", strtotime("9/10/10")); echo $month;} if ($month == '09') {$month = date("m", strtotime("10/10/10")); echo $month;} if ($month == '10') {$month = date("m", strtotime("11/10/10")); echo $month;} if ($month == '11') {$month = date("m", strtotime("12/10/10")); echo $month;} if ($month == '12') {$month = date("m", strtotime("01/10/10")); echo $month;} */ $twelveCount++; // Increment $twelveCount by 1 } // End while($twelveCount != '13') { echo $calendarDisplay; // Echo result out to page ?>
  7. I'm having issues converting to MySQLI, can someone take a look for me. Thanks, salestatusupdateplusone.php
  8. Hi all, In my organization we have a small group that keeps track of medical terms in an Access database (they're secretaries and not very technically savvy, it works for them) and they'd like to take the contents of this database and move it to a web-app who's backend is a MySQL database. What would be the best way to make this conversion happen? The version of Access is: 2007
  9. Well, I am a total Python Newbie but know PHP very well, I wanted to create a website that would help people to generate Word crosswords, hence after a little web search I found this Python Code which I need help in converting to PHP> I tried myself but failed as I know nothing about Python, I also tried an online conversion tool, but without any luck, so if anyone here can help me convert the following code to PHP, it will be highly respected. Heres the code: import random, re, time, string from copy import copy as duplicate class Crossword(object): def __init__(self, cols, rows, empty = '-', maxloops = 2000, available_words=[]): self.cols = cols self.rows = rows self.empty = empty self.maxloops = maxloops self.available_words = available_words self.randomize_word_list() self.current_word_list = [] self.debug = 0 self.clear_grid() def clear_grid(self): # initialize grid and fill with empty character self.grid = [] for i in range(self.rows): ea_row = [] for j in range(self.cols): ea_row.append(self.empty) self.grid.append(ea_row) def randomize_word_list(self): # also resets words and sorts by length temp_list = [] for word in self.available_words: if isinstance(word, Word): temp_list.append(Word(word.word, word.clue)) else: temp_list.append(Word(word[0], word[1])) random.shuffle(temp_list) # randomize word list temp_list.sort(key=lambda i: len(i.word), reverse=True) # sort by length self.available_words = temp_list def compute_crossword(self, time_permitted = 1.00, spins=2): time_permitted = float(time_permitted) count = 0 copy = Crossword(self.cols, self.rows, self.empty, self.maxloops, self.available_words) start_full = float(time.time()) while (float(time.time()) - start_full) < time_permitted or count == 0: # only run for x seconds self.debug += 1 copy.current_word_list = [] copy.clear_grid() copy.randomize_word_list() x = 0 while x < spins: # spins; 2 seems to be plenty for word in copy.available_words: if word not in copy.current_word_list: copy.fit_and_add(word) x += 1 #print copy.solution() #print len(copy.current_word_list), len(self.current_word_list), self.debug # buffer the best crossword by comparing placed words if len(copy.current_word_list) > len(self.current_word_list): self.current_word_list = copy.current_word_list self.grid = copy.grid count += 1 return def suggest_coord(self, word): count = 0 coordlist = [] glc = -1 for given_letter in word.word: # cycle through letters in word glc += 1 rowc = 0 for row in self.grid: # cycle through rows rowc += 1 colc = 0 for cell in row: # cycle through letters in rows colc += 1 if given_letter == cell: # check match letter in word to letters in row try: # suggest vertical placement if rowc - glc > 0: # make sure we're not suggesting a starting point off the grid if ((rowc - glc) + word.length) <= self.rows: # make sure word doesn't go off of grid coordlist.append([colc, rowc - glc, 1, colc + (rowc - glc), 0]) except: pass try: # suggest horizontal placement if colc - glc > 0: # make sure we're not suggesting a starting point off the grid if ((colc - glc) + word.length) <= self.cols: # make sure word doesn't go off of grid coordlist.append([colc - glc, rowc, 0, rowc + (colc - glc), 0]) except: pass # example: coordlist[0] = [col, row, vertical, col + row, score] #print word.word #print coordlist new_coordlist = self.sort_coordlist(coordlist, word) #print new_coordlist return new_coordlist def sort_coordlist(self, coordlist, word): # give each coordinate a score, then sort new_coordlist = [] for coord in coordlist: col, row, vertical = coord[0], coord[1], coord[2] coord[4] = self.check_fit_score(col, row, vertical, word) # checking scores if coord[4]: # 0 scores are filtered new_coordlist.append(coord) random.shuffle(new_coordlist) # randomize coord list; why not? new_coordlist.sort(key=lambda i: i[4], reverse=True) # put the best scores first return new_coordlist def fit_and_add(self, word): # doesn't really check fit except for the first word; otherwise just adds if score is good fit = False count = 0 coordlist = self.suggest_coord(word) while not fit and count < self.maxloops: if len(self.current_word_list) == 0: # this is the first word: the seed # top left seed of longest word yields best results (maybe override) vertical, col, row = random.randrange(0, 2), 1, 1 ''' # optional center seed method, slower and less keyword placement if vertical: col = int(round((self.cols + 1)/2, 0)) row = int(round((self.rows + 1)/2, 0)) - int(round((word.length + 1)/2, 0)) else: col = int(round((self.cols + 1)/2, 0)) - int(round((word.length + 1)/2, 0)) row = int(round((self.rows + 1)/2, 0)) # completely random seed method col = random.randrange(1, self.cols + 1) row = random.randrange(1, self.rows + 1) ''' if self.check_fit_score(col, row, vertical, word): fit = True self.set_word(col, row, vertical, word, force=True) else: # a subsquent words have scores calculated try: col, row, vertical = coordlist[count][0], coordlist[count][1], coordlist[count][2] except IndexError: return # no more cordinates, stop trying to fit if coordlist[count][4]: # already filtered these out, but double check fit = True self.set_word(col, row, vertical, word, force=True) count += 1 return def check_fit_score(self, col, row, vertical, word): ''' And return score (0 signifies no fit). 1 means a fit, 2+ means a cross. The more crosses the better. ''' if col < 1 or row < 1: return 0 count, score = 1, 1 # give score a standard value of 1, will override with 0 if collisions detected for letter in word.word: try: active_cell = self.get_cell(col, row) except IndexError: return 0 if active_cell == self.empty or active_cell == letter: pass else: return 0 if active_cell == letter: score += 1 if vertical: # check surroundings if active_cell != letter: # don't check surroundings if cross point if not self.check_if_cell_clear(col+1, row): # check right cell return 0 if not self.check_if_cell_clear(col-1, row): # check left cell return 0 if count == 1: # check top cell only on first letter if not self.check_if_cell_clear(col, row-1): return 0 if count == len(word.word): # check bottom cell only on last letter if not self.check_if_cell_clear(col, row+1): return 0 else: # else horizontal # check surroundings if active_cell != letter: # don't check surroundings if cross point if not self.check_if_cell_clear(col, row-1): # check top cell return 0 if not self.check_if_cell_clear(col, row+1): # check bottom cell return 0 if count == 1: # check left cell only on first letter if not self.check_if_cell_clear(col-1, row): return 0 if count == len(word.word): # check right cell only on last letter if not self.check_if_cell_clear(col+1, row): return 0 if vertical: # progress to next letter and position row += 1 else: # else horizontal col += 1 count += 1 return score def set_word(self, col, row, vertical, word, force=False): # also adds word to word list if force: word.col = col word.row = row word.vertical = vertical self.current_word_list.append(word) for letter in word.word: self.set_cell(col, row, letter) if vertical: row += 1 else: col += 1 return def set_cell(self, col, row, value): self.grid[row-1][col-1] = value def get_cell(self, col, row): return self.grid[row-1][col-1] def check_if_cell_clear(self, col, row): try: cell = self.get_cell(col, row) if cell == self.empty: return True except IndexError: pass return False def solution(self): # return solution grid outStr = "" for r in range(self.rows): for c in self.grid[r]: outStr += '%s ' % c outStr += '\n' return outStr def word_find(self): # return solution grid outStr = "" for r in range(self.rows): for c in self.grid[r]: if c == self.empty: outStr += '%s ' % string.lowercase[random.randint(0,len(string.lowercase)-1)] else: outStr += '%s ' % c outStr += '\n' return outStr def order_number_words(self): # orders words and applies numbering system to them self.current_word_list.sort(key=lambda i: (i.col + i.row)) count, icount = 1, 1 for word in self.current_word_list: word.number = count if icount < len(self.current_word_list): if word.col == self.current_word_list[icount].col and word.row == self.current_word_list[icount].row: pass else: count += 1 icount += 1 def display(self, order=True): # return (and order/number wordlist) the grid minus the words adding the numbers outStr = "" if order: self.order_number_words() copy = self for word in self.current_word_list: copy.set_cell(word.col, word.row, word.number) for r in range(copy.rows): for c in copy.grid[r]: outStr += '%s ' % c outStr += '\n' outStr = re.sub(r'[a-z]', ' ', outStr) return outStr def word_bank(self): outStr = '' temp_list = duplicate(self.current_word_list) random.shuffle(temp_list) # randomize word list for word in temp_list: outStr += '%s\n' % word.word return outStr def legend(self): # must order first outStr = '' for word in self.current_word_list: outStr += '%d. (%d,%d) %s: %s\n' % (word.number, word.col, word.row, word.down_across(), word.clue ) return outStr class Word(object): def __init__(self, word=None, clue=None): self.word = re.sub(r'\s', '', word.lower()) self.clue = clue self.length = len(self.word) # the below are set when placed on board self.row = None self.col = None self.vertical = None self.number = None def down_across(self): # return down or across if self.vertical: return 'down' else: return 'across' def __repr__(self): return self.word ### end class, start execution #start_full = float(time.time()) word_list = ['saffron', 'The dried, orange yellow plant used to as dye and as a cooking spice.'], \ ['pumpernickel', 'Dark, sour bread made from coarse ground rye.'], \ ['leaven', 'An agent, such as yeast, that cause batter or dough to rise..'], \ ['coda', 'Musical conclusion of a movement or composition.'], \ ['paladin', 'A heroic champion or paragon of chivalry.'], \ ['syncopation', 'Shifting the emphasis of a beat to the normally weak beat.'], \ ['albatross', 'A large bird of the ocean having a hooked beek and long, narrow wings.'], \ ['harp', 'Musical instrument with 46 or more open strings played by plucking.'], \ ['piston', 'A solid cylinder or disk that fits snugly in a larger cylinder and moves under pressure as in an engine.'], \ ['caramel', 'A smooth chery candy made from suger, butter, cream or milk with flavoring.'], \ ['coral', 'A rock-like deposit of organism skeletons that make up reefs.'], \ ['dawn', 'The time of each morning at which daylight begins.'], \ ['pitch', 'A resin derived from the sap of various pine trees.'], \ ['fjord', 'A long, narrow, deep inlet of the sea between steep slopes.'], \ ['lip', 'Either of two fleshy folds surrounding the mouth.'], \ ['lime', 'The egg-shaped citrus fruit having a green coloring and acidic juice.'], \ ['mist', 'A mass of fine water droplets in the air near or in contact with the ground.'], \ ['plague', 'A widespread affliction or calamity.'], \ ['yarn', 'A strand of twisted threads or a long elaborate narrative.'], \ ['snicker', 'A snide, slightly stifled laugh.'] a = Crossword(13, 13, '-', 5000, word_list) a.compute_crossword(2) print a.word_bank() print a.solution() print a.word_find() print a.display() print a.legend() print len(a.current_word_list), 'out of', len(word_list) print a.debug #end_full = float(time.time()) #print end_full - start_full
  • 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.