PHP - Make Code Display Specific Number Of Titles
<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. Similar TutorialsI need to display a number(the number is retrieved from the db) in the form input field such that only the last 4 digits is visbile, the remaining can be masked as * or X or whatever is applicable. I know the last 4 can be obtained as follows: Code: [Select] $number=substr($number,-4,4); But when i hit the submit button the form validates the input field and checks if the number is a valid number of a specific format. Therefore when I click on the submit button then I should still be able to unmask the masked numbers or do something similar that would help me validate the whole number. Code: [Select] <input type="text" name="no" value="<?php if(!empty($number)){ echo $number;} ?>"> Hey... I'm trying to echo the title of the news in the right column but I just want to display maximum of 25 characters how can I do it? thanks Hello, i retrieve an array from the database that looks something like this: $var=a:1:{s:2:"cc";a:1:{i:22;s:11:"TESTING";}}; I need to retrieve the number corresponding to the character i: and print it(11 in the first case). For example , If, $var=a:1:{s:2:"cc";a:1:{i:15;s:11:"TESTING";}}; I would need to print 15. $var=a:1:{s:2:"cc";a:1:{i:3;s:11:"TESTING";}}; I would need to print 3. Thanks in advance. hey guys i have this invoice im working on but my clients want's the invoice id start at a specific number?
do it put that number in phpmyadmin direct on the line null?or can i do it another way?
I'm pretty sure this is really simple to do using the count function, but I am having a hard time finding examples on how to count the number of times a "SPECIFIC" word occurs in a file. For example, I just want to display how many times "this-word" occurs in "http://www.mysite.com/logfile.log". Any help would be appreciated. Hi there, I'm writing an application that pulls from two separate web based APIs, collates the data into a single array of data. Once done, it then enters a loop that cycles through the array and executes a cURL call for each cycle. This worked perfectly for a controlled set of 10 artificial records and so I've started testing with live data. On running the code, I eventually the following : Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. I'm not sure how to debug this and so I'm hoping I can find some help here. I'm running WAMP, and the php.ini contains the following: max_execution_time = 0 ; Maximum execution time of each script, in seconds max_input_time = 0 ; Maximum amount of time each script may spend parsing request data Through testing, I have discovered the following : The script can do exactly 35 iterations through the loop in under 2 minutes. Any number greater than this causes the error. If I skip the first 20 curl submits, I can then do 21 to 55 iterations before failure, so I do not believe it is the 36th value. If I put a sleep(5) command into the loop, I can still do 35 and no more iterations than that. If I put a sleep(10) command into the loop, it fails on 35 and needs less. Code: [Select] $action = "post"; $url = "http://url.url.url/api/v1.0/udo_Position/create"; // I've replaced the actual URL out of necessity // set user agent { print("Setting CURL options, using URL ".$url."<br>"); $cd = curl_init(); curl_setopt($cd, CURLOPT_HEADER, 1); curl_setopt($cd, CURLOPT_URL, $url); curl_setopt($cd, CURLOPT_USERPWD, 'username:password'); curl_setopt($cd, CURLOPT_RETURNTRANSFER, 1); // Don't send return value to screen curl_setopt($cd, CURLOPT_USERAGENT, "Firefox/2.0.0.1"); // spoofing FireFox 2.0 curl_setopt($cd, CURLOPT_VERBOSE, true); // } if ($action == 'get') { ; } elseif ($action == 'post') { print("POST set;<br>"); print("<pre style='font-family:verdana;font-size:13'>"); print_r($pointval); print("</pre>"); $pointval["save"] = "Save"; // The AddNew step form requires this. curl_setopt($cd, CURLOPT_POSTFIELDS, $pointval); } else { print("Invalid usage. Please see example<br>"); return; } $reply = curl_exec($cd); $http_status = curl_getinfo($cd, CURLINFO_HTTP_CODE); print("<pre style='font-family:verdana;font-size:13'>"); print_r($http_status); print("</pre>"); print("Here is the reply from the AddNew function: <br>"); print("<pre style='font-family:verdana;font-size:13'>"); print_r($reply); print("</pre>"); if (curl_error($cd)) { print("Error: ".(curl_error($cd))."<br>"); } curl_close($cd); print("Insert Successful.<br>"); I am uncertain whether it is a PHP, Apache or cURL issue at this point. I have another script that pushes a great deal more cURL calls to the same system but pulls from only one external resource, instead of two. Any help or suggestions would be appreciated. Hi all, Is there a way to get jquery ajax to run a specific PHP function. At the moment Im sending extra paramaters like check=1: Code: [Select] ajaxCall: function(process, obj, type){ $.post("registration-post.php", type + "=" + process + "&check=1", function(data){ alert(data); if(data==""){ $(obj).css(registration.errorNotificationType, registration.validatedColour); }else{ //registration.validationCollection.push($.trim(data)); $('.error').append($.trim(data) + "<br />"); $(obj).css(registration.errorNotificationType, registration.errorColour); registration.progress = false; } } ); } then doing an if statement, if($_POST["check"]==1){ $registration->checkDuplication(); } if($registration->validationBool){ $registration->validateFields(); } but its not really doing the job i need it to do. I'm a little stuck in my own battle to make cleaner coding So I'm trying to make an online quiz where the user can 'take the quiz' or go to 'module' where the user can edit the quiz. I've tried for days to search through the net for this particular one but I can't find any solutions. For the quiz I made a comma delimited text file and tried to use that file to make a multidimensional array. So far I only have the following: <h2>ONLINE QUIZ</h2> <ul> <li><a href='question.php'>Take quiz</a></li> <li><a href='module.php'>Admin Module</a></li> </ul> <?php $file = fopen ("data.txt","r"); $i=0; while (feof($file)==false) { $line = fgets($file); $array[$i]=$line; $i=$i + 1; } fclose($file); session_start(); $_SESSION["questions_array"]=$array; ?> My question is, how do I turn the text file from something that looks like this: HTML is...,Main markup language for web pages,Cross-site Security,Cleverly Structured Scripting,eXtremely Safe and Secure, PHP...,General-purpose server-side scripting language,Cross-site Security,Processing Hypertext Products,Process HTML Prettily To output something like this: Question #1 HTML is... [radio button] a.) Main markup language for web pages [radio button] b.) Cross-site Security etc, etc ll----I will type out the exact plan for this quiz----ll Main page: module and quiz link. For the quiz Question page: Questions only show up one by one. ex.) What is a dog? a.) a human b.) a pet c.) a job d.) a car (Submit button) Answer page: Once submit is hit, the page goes here, where the user can see whether they answered right or wrong. ex.) INCORRECT Your answer: a.) a human Correct answer: b.) a pet (continue link) Note that when 'continue' is hit, the page redirects back to the 'question page' but this time outputs the next question. When no more questions are available, the page automatically redirects to the 'results page'. Results page: Table of results For the module Main: A table of the available questions plus their choice answers ex.) Question l choice a l choice b l [] What? cat toy [] How? rat pop etc. Each row can be selected through a radio button. (so we know which question to edit) Select option: Drop down list whether to 'add', 'edit' or 'delete' a question. Each choice directs to a different page where you can perform the action. Also, if 'delete' is chosen, a confirmation page should show up. (i.e are you sure you want to delete this file?) I think that's detailed enough, I'm so sorry for the trouble;; but please if you don't have the time to help me throughout the whole thing, please help me figure out how to use the text file as a multi-dim array (aka the first thing I asked). I've been dying to know how to do it but I just can't get it to work so I'd really appreciate that! Thank you! I'm creating a social network for a friend and I need to make a flash webcam to talk to another flash webcam. I have all the flash code working, now all I need is a way to let users match themselves up to each other without other users being able to barge in. What areas of php do I need to learn about to do this? Dallas. In follow up to my previous post, I have found a way to display my data but now I am wanting to only display certain data (within an 'if' statement). For example, if I login as a particular student and there is three sets of data in there e.g. MATH1023, ENG1003 and ENG1013 but I only want to display the student's MATH1023 data in a section, how do I do this? I know that I need to do some sort of an IF statement where 'crsecode=MATH1023' but for some reason I cannot get this to work without it pulling this along with the two English courses. Here is my code: Code: [Select] <?php $db_host = "locahost"; $db_user = "dbuser"; $db_pass = "dbpassword"; $db_name = "dbconnection"; $dbac = mysql_connect($db_host,$db_user,$db_pass); mysql_select_db ($db_name) or die ("Cannot connect to database."); if (!$_POST['search']){ ?> <form name="Item Search" method="post" action=""> Item Search:<br> <label> <input name="swords" type="text" size="30" maxlength="30"> </label> <br> <label> <input name="search" type="submit" id="search" value="Search"> </label> </form> <?php }else{ $searchwords = addslashes(htmlspecialchars($_POST['swords'])); if (strlen($searchwords) < 2){ echo "Your search must contain at least 3 characters. Please try again.<br><input type=button value='Back' onClick='history.go(-1)'>"; }else{ $words = explode(' ',$searchwords); $totalwords = count($words); $i = 0; $searchstring = ""; while ($i != $totalwords){ if ($i != 0 and $i != $wordcount){ $searchstring .= " and ";; } $searchstring .= "cwid LIKE '%$words[$i]%'"; $i = $i + 1; } $query = mysql_query("SELECT DISTINCT * FROM transferdatafile where $searchstring"); if (mysql_num_rows($query) == 0){ echo "No results were found.<br><input type=button value='Back' onClick='history.go(-1)'>"; }else{ echo '<table border=1>'; while ($row = mysql_fetch_array($query)){ echo '<tr>'; echo '<td>'.$row['firstname'].'</td>'; echo '<td>'.$row['lastname'].'</td>'; echo '<td>'.$row['subj'].'</td>'; echo '<td>'.$row['course'].'</td>'; echo '<td>'.$row['crsecode'].'</td>'; echo '<td>'.$row['crsegrade'].'</td>'; // etc echo '</tr>'; } echo '</table>'; } } } ?> Here is the output that I currently get with this when all I want is MATH1023 to display for this particular student's ID (see attachment). Anyone help? [attachment deleted by admin] I'm using a wordpress theme that always tries to load a specific search tab first. ive tried figuring out if theres a way to make the second tab load first but cant seem to get it. hopefully someone can help a rookie like myself understand it for a live "demo" to get a sense of what im talking about you can see it here http://demo.woothemes.com/estate/ the Search Our Properties tab loads first. I want it to load the "Search the MLS" tab first or only display and load that one to be honest. Code: [Select] <span id="mls-search"> code is below. thanks! Code: [Select] <?php if (defined('DSIDXPRESS_OPTION_NAME')) { $options = get_option(DSIDXPRESS_OPTION_NAME); } else { $options = array('Activated' => false); } ?> <div class="search-tab <?php if(get_option('woo_idx_plugin_search') != 'true'){ echo 'no-idx'; }?>"> <?php if(get_option('woo_search_header')) { ?> <span id="local-search" class="current"><?php echo stripslashes(get_option('woo_search_header')); ?></span> <?php if ( $options['Activated'] && ( get_option('woo_idx_plugin_search') == 'true' ) ) { ?> <span id="mls-search"><a class="red-highlight"><?php echo stripslashes(get_option('woo_search_mls_header')); ?></a></span> <?php } ?> <?php } ?> </div> <div id="search"> <form name="property-webref-search" id="property-webref-search" method="get" action="<?php bloginfo('url'); ?>/"> <input type="text" class="text webref" id="s-webref" name="s" value="<?php _e('Property ID', 'woothemes'); ?>" onfocus="if (this.value == '<?php _e('Property ID', 'woothemes'); ?>') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php _e('Property ID', 'woothemes'); ?>';}" /> <input type="submit" class="submit button" name="property-search-webref-submit" value="<?php _e('Go To', 'woothemes'); ?>" /> </form> <form name="property-search" id="property-search" method="get" action="<?php bloginfo('url'); ?>/"> <div class="query"> <?php if (isset($_GET['s'])) { $keyword = strip_tags($_GET['s']); } else { $keyword = ''; } if ( $keyword == 'View More' ) { $keyword = ''; } ?> <input type="text" class="main-query text" id="s-main" name="s" value="<?php if ( $keyword != '' ) { echo $keyword; } else { _e(get_option('woo_search_keyword_text'), 'woothemes'); } ?>" onfocus="if (this.value == '<?php _e(get_option('woo_search_keyword_text'), 'woothemes') ?>') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php _e(get_option('woo_search_keyword_text'), 'woothemes') ?>';}" /> <input type="submit" class="submit button" name="property-search-submit" value="<?php _e('Search', 'woothemes'); ?>" /> <span class="or"><?php _e('Or', 'woothemes'); ?></span> <div class="fix"></div> </div><!-- /.query --> <div class="filters"> <?php if (isset($_GET['sale_type'])) { $sale_type = $_GET['sale_type']; } else { $sale_type = ''; } if ($sale_type == '') { $sale_type = 'all'; } ?> <div class="saletype"> <label for="saletype"><?php _e(get_option('woo_label_sale_type'), 'woothemes'); ?>:</label> <input type="radio" name="sale_type" value="all" <?php if ($sale_type == 'all') { ?>checked<?php } ?>> <?php _e('All', 'woothemes') ?> <input type="radio" name="sale_type" value="sale" <?php if ($sale_type == 'sale') { ?>checked<?php } ?>> <?php _e(get_option('woo_label_for_sale'), 'woothemes') ?> <input type="radio" name="sale_type" value="rent" <?php if ($sale_type == 'rent') { ?>checked<?php } ?>> <?php _e(get_option('woo_label_for_rent'), 'woothemes') ?> </div><!-- /.saletype --> <div class="location-type"> <label><?php _e(get_option('woo_label_property_location_and_type'), 'woothemes'); ?>:</label> <?php //property locations drop down if (isset($_GET['location_names'])) { $category_ID = $_GET['location_names']; } else { $category_ID = 0; } if ($category_ID > 0) { //Do nothing } else { $category_ID = 0; } $dropdown_options = array ( 'show_option_all' => __(get_option('woo_label_locations_dropdown_view_all')), 'hide_empty' => 0, 'hierarchical' => 1, 'show_count' => 0, 'orderby' => 'name', 'name' => 'location_names', 'id' => 'location_names', 'taxonomy' => 'location', 'hide_if_empty' => 1, 'selected' => $category_ID ); wp_dropdown_categories($dropdown_options); ?> <?php //property types drop down if (isset($_GET['property_types'])) { $category_ID = $_GET['property_types']; } else { $category_ID = 0; } if ($category_ID > 0) { //Do nothing } else { $category_ID = 0; } $dropdown_options = array ( 'show_option_all' => __(get_option('woo_label_property_type_dropdown_view_all')), 'hide_empty' => 0, 'hierarchical' => 1, 'show_count' => 0, 'orderby' => 'name', 'name' => 'property_types', 'id' => 'property_types', 'taxonomy' => 'propertytype', 'hide_if_empty' => 1, 'selected' => $category_ID, 'class' => 'last' ); wp_dropdown_categories($dropdown_options); if (isset($_GET['price_min'])) { $price_min = $_GET['price_min']; } else { $price_min = ''; } if (isset($_GET['price_max'])) { $price_max = $_GET['price_max']; } else { $price_max = ''; } ?> </div><!-- /.location-type --> <div class="fix"></div> <div class="price"> <label for="price_min"><?php _e(get_option('woo_label_min_price'), 'woothemes'); ?> <?php echo '('.get_option('woo_estate_currency').')'; ?>:</label><input type="text" class="text price validate_number" name="price_min" id="price_min" value="<?php if ( $price_min != '' ) { echo $price_min; } ?>" > <label for="price_max"><?php _e(get_option('woo_label_max_price'), 'woothemes'); ?> <?php echo '('.get_option('woo_estate_currency').')'; ?>:</label><input type="text" class="text price validate_number" name="price_max" id="price_max" value="<?php if ( $price_max != '' ) { echo $price_max; } ?>" > </div><!-- /.price --> <span class="advanced-search-button button"><?php _e(get_option('woo_label_advanced_search'), 'woothemes'); ?> ↓</span> <div class="fix"></div> <div id="advanced-search"> <?php if (isset($_GET['no_garages'])) { $no_garages = $_GET['no_garages']; } else { $no_garages = 'all'; } ?> <?php if (isset($_GET['no_beds'])) { $no_beds = $_GET['no_beds']; } else { $no_beds = 'all'; } ?> <?php if (isset($_GET['no_baths'])) { $no_baths = $_GET['no_baths']; } else { $no_baths = 'all'; } ?> <?php if (isset($_GET['size_min'])) { $size_min = $_GET['size_min']; } else { $size_min = ''; } ?> <?php if (isset($_GET['size_max'])) { $size_max = $_GET['size_max']; } else { $size_max = ''; } ?> <?php $options_features_amount = array("0","1","2","3","4","5","6","7","8","9","10+"); ?> <div class="features-filters"> <label for="no_garages"><?php _e(get_option('woo_label_garages'), 'woothemes'); ?>:</label> <select class="postform" id="no_garages" name="no_garages"> <option <?php if ($no_garages == 'all') { ?>selected="selected"<?php }?> value="all"><?php _e('Any', 'woothemes') ?></option> <?php foreach ($options_features_amount as $option) { ?><option <?php if ($no_garages == $option) { ?>selected="selected"<?php }?> value="<?php echo $option; ?>"><?php echo $option; ?></option><?php } ?> </select> <label for="no_beds"><?php _e(get_option('woo_label_beds'), 'woothemes'); ?>:</label> <select class="postform" id="no_beds" name="no_beds"> <option <?php if ($no_beds == 'all') { ?>selected="selected"<?php }?> value="all"><?php _e('Any', 'woothemes') ?></option> <?php foreach ($options_features_amount as $option) { ?><option <?php if ($no_beds == $option) { ?>selected="selected"<?php }?> value="<?php echo $option; ?>"><?php echo $option; ?></option><?php } ?> </select> <label for="no_baths"><?php _e(get_option('woo_label_baths_long'), 'woothemes'); ?>:</label> <select class="postform last" id="no_baths" name="no_baths"> <option <?php if ($no_baths == 'all') { ?>selected="selected"<?php }?> value="all"><?php _e('Any', 'woothemes') ?></option> <?php foreach ($options_features_amount as $option) { ?><option <?php if ($no_baths == $option) { ?>selected="selected"<?php }?> value="<?php echo $option; ?>"><?php echo $option; ?></option><?php } ?> </select> <label for="size_min"><?php _e(get_option('woo_label_min_size'), 'woothemes'); ?> <?php echo '('.get_option('woo_label_size_metric').')'; ?>:</label><input type="text" class="text size validate_number" name="size_min" id="size_min" value="<?php if ( $size_min != '' ) { echo $size_min; } ?>" > <label for="size_max"><?php _e(get_option('woo_label_max_size'), 'woothemes'); ?> <?php echo '('.get_option('woo_label_size_metric').')'; ?>:</label><input type="text" class="last text size validate_number" name="size_max" id="size_max" value="<?php if ( $size_max != '' ) { echo $size_max; } ?>" > </div><!-- /.size --> </div><!-- /#advanced-search --> <div class="fix"></div> </div><!-- /.filters --> <?php $term_names = ''; $price_list = ''; $size_list = ''; //Taxonomies $taxonomy_data_set = get_terms(array('location',/*'pricerange',*/'propertytype','propertyfeatures'), array('fields' => 'names')); $taxonomy_data_set = woo_multidimensional_array_unique($taxonomy_data_set); foreach ($taxonomy_data_set as $data_item) { //Convert string to UTF-8 $str_converted = woo_encoding_convert($data_item); //Add category name to data string $term_names .= htmlspecialchars($str_converted, ENT_QUOTES, 'UTF-8').','; } //Post Custom Fields $meta_data_fields = array('address'); $meta_data_set = woo_get_custom_post_meta_entries($meta_data_fields); $meta_data_set = woo_multidimensional_array_unique($meta_data_set); foreach ($meta_data_set as $data_item) { //Convert string to UTF-8 $str_converted = woo_encoding_convert($data_item->meta_value); //Add category name to data string $term_names .= htmlspecialchars($str_converted, ENT_QUOTES, 'UTF-8').','; } $price_list = ''; //Post Custom Fields $meta_data_fields = array('price'); $meta_data_set = woo_get_custom_post_meta_entries($meta_data_fields); $meta_data_set = woo_multidimensional_array_unique($meta_data_set); foreach ($meta_data_set as $data_item) { //Convert string to UTF-8 $str_converted = woo_encoding_convert($data_item->meta_value); //Add category name to data string $price_list .= htmlspecialchars($str_converted, ENT_QUOTES, 'UTF-8').','; } //Post Custom Fields $meta_data_fields = array('size'); $meta_data_set = woo_get_custom_post_meta_entries($meta_data_fields); $meta_data_set = woo_multidimensional_array_unique($meta_data_set); foreach ($meta_data_set as $data_item) { //Convert string to UTF-8 $str_converted = woo_encoding_convert($data_item->meta_value); //Add category name to data string $size_list .= htmlspecialchars($str_converted, ENT_QUOTES, 'UTF-8').','; } ?> <script> jQuery(document).ready(function($) { <?php if ( ( ($no_garages == 'all') || ($no_garages == '') ) && ( ($no_beds == 'all') || ($no_beds == '') ) && ( ($no_baths == 'all') || ($no_baths == '') ) && ( $size_min == '' ) && ( $size_max == '' ) ) { ?>jQuery("#advanced-search").toggle();<?php } ?> jQuery(".advanced-search-button").click(function(){ var hidetext = 'Hide <?php echo get_option('woo_label_advanced_search'); ?>'; var showtext = '<?php echo get_option('woo_label_advanced_search'); ?>'; var currenttext = jQuery(".advanced-search-button").text(); //toggle advanced search jQuery("#advanced-search").toggle(); //toggle text if (currenttext == hidetext) { jQuery(".advanced-search-button").text(showtext); //reset search values jQuery("#no_garages").val('all'); jQuery("#no_beds").val('all'); jQuery("#no_baths").val('all'); } else { jQuery(".advanced-search-button").text(hidetext); } }); //GET PHP data items var keyworddataset = "<?php echo $term_names; ?>".split(","); var pricedataset = "<?php echo $price_list; ?>".split(","); var sizedataset = "<?php echo $size_list; ?>".split(","); //Set autocomplete(s) $("#s-main").autocomplete(keyworddataset); $("#price_min").autocomplete(pricedataset); $("#price_max").autocomplete(pricedataset); $("#size_min").autocomplete(sizedataset); $("#size_max").autocomplete(sizedataset); //Handle autocomplete result $("#s").result(function(event, data, formatted) { //Do Nothing }); $("#price_min").result(function(event, data, formatted) { //Do Nothing }); $("#price_max").result(function(event, data, formatted) { //Do Nothing }); $("#size_min").result(function(event, data, formatted) { //Do Nothing }); $("#size_max").result(function(event, data, formatted) { //Do Nothing }); }); </script> <div class="fix"></div> </form> <?php if ( $options['Activated'] && ( get_option('woo_idx_plugin_search') == 'true' ) ) { $pluginUrl = DSIDXPRESS_PLUGIN_URL; $formAction = get_bloginfo("url"); if (substr($formAction, strlen($formAction), 1) != "/") $formAction .= "/"; $formAction .= dsSearchAgent_Rewrite::GetUrlSlug(); ?> <form name="property-mls-search" id="property-mls-search" method="get" action="<?php echo $formAction; ?>"> <?php $defaultSearchPanels = dsSearchAgent_ApiRequest::FetchData("AccountSearchPanelsDefault", array(), false, 60 * 60 * 24); $defaultSearchPanels = $defaultSearchPanels["response"]["code"] == "200" ? json_decode($defaultSearchPanels["body"]) : null; $propertyTypes = dsSearchAgent_ApiRequest::FetchData("AccountSearchSetupPropertyTypes", array(), false, 60 * 60 * 24); $propertyTypes = $propertyTypes["response"]["code"] == "200" ? json_decode($propertyTypes["body"]) : null; $requestUri = dsSearchAgent_ApiRequest::$ApiEndPoint . "LocationsByType"; //cities $location_cities = explode("\n", get_option('woo_idx_search_cities')); //communities $location_communities = explode("\n", get_option('woo_idx_search_communities')); //Tracts $location_tracts = explode("\n", get_option('woo_idx_search_tracts')); //Zips $location_zips = explode("\n", get_option('woo_idx_search_zips')); ?> <div class="mls-property-type"> <label for="idx-q-PropertyTypes"><?php _e('Property Type', 'woothemes'); ?>:</label> <select name="idx-q-PropertyTypes" class="dsidx-search-widget-propertyTypes"> <option value="All">- All property types -</option> <?php if (is_array($propertyTypes)) { foreach ($propertyTypes as $propertyType) { $name = htmlentities($propertyType->DisplayName); echo "<option value=\"{$propertyType->SearchSetupPropertyTypeID}\">{$name}</option>"; } } ?> </select> <label for="idx-q-MlsNumbers"><?php _e('MLS #', 'woothemes'); ?>:</label> <input id="idx-q-MlsNumbers" name="idx-q-MlsNumbers" type="text" class="text" /> </div> <div class="fix"></div> <div class="mls-area-details"> <label for="idx-q-Cities"><?php _e('City', 'woothemes'); ?>:</label> <select id="idx-q-Cities" name="idx-q-Cities" class="small"> <?php if (is_array($location_cities)) { foreach ($location_cities as $city) { $city_name = htmlentities(trim($city)); echo "<option value=\"{$city_name}\">$city_name</option>"; } } ?> </select> <label for="idx-q-Communities"><?php _e('Community', 'woothemes'); ?>:</label> <select id="idx-q-Communities" name="idx-q-Communities" class="small"> <option value="">- Any -</option> <?php if (is_array($location_communities)) { foreach ($location_communities as $community) { $community_name = htmlentities(trim($community)); echo "<option value=\"{$community_name}\">$community_name</option>"; } } ?> </select> <label for="idx-q-TractIdentifiers"><?php _e('Tract', 'woothemes'); ?>:</label> <select id="idx-q-TractIdentifiers" name="idx-q-TractIdentifiers" class="small"> <option value="">- Any -</option> <?php if (is_array($location_tracts)) { foreach ($location_tracts as $tract) { $tract_name = htmlentities(trim($tract)); echo "<option value=\"{$tract_name}\">$tract_name</option>"; } } ?> </select> <label for="idx-q-ZipCodes"><?php _e('Zip', 'woothemes'); ?>:</label> <select id="idx-q-ZipCodes" name="idx-q-ZipCodes" class="small"> <option value="">- Any -</option> <?php if (is_array($location_zips)) { foreach ($location_zips as $zip) { $zip_name = htmlentities(trim($zip)); echo "<option value=\"{$zip_name}\">$zip_name</option>"; } } ?> </select> </div> <div class="fix"></div> <div class="mls-features"> <label for="idx-q-PriceMin"><?php _e('Min Price', 'woothemes'); ?>:</label> <input id="idx-q-PriceMin" name="idx-q-PriceMin" type="text" class="text validate_number" /> <label for="idx-q-PriceMax"><?php _e('Max Price', 'woothemes'); ?>:</label> <input id="idx-q-PriceMax" name="idx-q-PriceMax" type="text" class="text validate_number" /> <label for="idx-q-ImprovedSqFtMin"><?php _e('Min Size', 'woothemes'); ?> <?php echo '(SQ FT)'; ?>:</label> <input id="idx-q-ImprovedSqFtMin" name="idx-q-ImprovedSqFtMin" type="text" class="text validate_number" /> <label for="idx-q-BedsMin"><?php _e('Beds', 'woothemes'); ?>:</label> <input id="idx-q-BedsMin" name="idx-q-BedsMin" type="text" class="text validate_number" /> <label for="idx-q-BathsMin"><?php _e('Baths', 'woothemes'); ?>:</label> <input id="idx-q-BathsMin" name="idx-q-BathsMin" type="text" class="text validate_number" /> </div> <input type="submit" value="Search" class="submit button" /> <?php if($options["HasSearchAgentPro"] == "yes"){ echo 'try our <a href="'.$formAction.'advanced/"><img src="'.$pluginUrl.'assets/adv_search-16.png" /> Advanced Search</a>'; } ?> <div class="fix"></div> </form> <?php } ?> </div><!-- /#search --> Hi I am trying to create a dynamic gallery in php with specific order of pictures on the page, but I can't find the function or piece of php code to do so.
Conditions: My code: $files = glob("layout/gallery/*.jpg"); rsort($files, SORT_NATURAL); for ($i=0; $i < count($files); $i++) { for( ; $i<5; $i++){ $one = $files[$i]; echo '<img src="'.$one.'">' . '<br><br>'; } echo "<br>"; for( ; $i<9; $i++){ $two = $files[$i]; echo '<img src="'.$two.'">' . '<br><br>'; } } The code works well, but it just displays 9 pictures obviously. I was unable to make it dynamic displaying 5 pictures first, 4 pictures after and stay this way in a loop till displays all pictures from that folder. is it possible to disable warnings on a specific page? php.ini set to show warnings Hi All, Sometimes after some calculation php may return this: 1.02563125481E+54 But how to make this into 1 number without the E+ etc ?! Cheers i have a register and login page where the users can perform register and login task and their detail gets saved in the database. my requirement is that when the user enters his/her account, they should be redirected to their profile page, where they can view all their profile details. Till now i have been able to make the user login and dislay a part of their profile page, for this purpose the code that i am using is
<code>
<?php This is my preg_match code:
preg_match("/(\d+)|(T)|(A)/", $link, $matches, PREG_OFFSET_CAPTURE, ($off-30)
It works and matches the number I want, except it only returns the first character in the $matches array. For instance, if the number it finds is 10, it only returns 1. Now I understand that is what preg_match does, but how would I make that regex ungreedy? I tried adding a *, but it just made an error, and preg match all would keep searching for strings after the first one. All I want is for the first number, regardless of the length of it, to be returned in full. Thanks for any help.
hello, if i have $big=3410 how can i take the last 2 digits of that to make it so that i only get the 10? hope this makes sence. Hi I have been trying to populate my data from 3 tables and display like this: DATE $acronym1 $acronym2 POSTS 1/9/2011 10 (this is no of posts) 3 POSTS 31/8/2011 20 10 and so on. the threads and user table will be similar as well. I am not able to populate the distinct dates since the dateline contains time as well. So when I try to print out the just dates(without time) , it prints with the dates repeated. it prints something like this: 1/9/2011 1 1/9/2011 1 and so on.. How can populate and print the the date and number of posts in the above format. Here is my complete code below: Code: [Select] <?php error_reporting(-1); //ini_set('display_errors',1); include("db.php"); //$thirty_days_ago = strtotime("-30 days"); $limit = strtotime("-1 month"); $sql=mysql_query(("SELECT * from new_site"),$con) or die(mysql_error()); while($row=mysql_fetch_assoc($sql)) { $include=$row['include']; $forumurl=$row['forumurl']; $url=$row['url']; $acronym=$row['acronym']; include("$include"); //echo $include."<br>"; $configdbname=$config['Database']['dbname']; $configdbconport=$config['MasterServer']['servername'].":".$config['MasterServer']['port']; $configusername=$config['MasterServer']['username']; $configpassword=$config['MasterServer']['password']; $configprefix=$config['Database']['tableprefix']; /* Connect to the required database */ $con2=mysql_connect($configdbconport, $configusername, $configpassword); if (!$con2) { die('Could not connect: ' . mysql_error()); } mysql_select_db($configdbname, $con2); $postdate=mysql_query("SELECT DISTINCT dateline,postid from post WHERE dateline >='$limit' ORDER by dateline DESC") or die(mysql_error()); while($postdate_results=mysql_fetch_assoc($postdate)) { $postdate_record=$postdate_results['dateline']; // echo $postdate."<br>"; $postdate_formatted=date('M dS Y ',$postdate_results['dateline']); $post_count=mysql_query("SELECT * from post WHERE dateline >='$postdate_record'"); while($post_count_results=mysql_fetch_assoc($post_count)) { //$postdate_formatted=date('M dS Y ',$post_dateline_results['dateline']); $posts=mysql_num_rows($post_count) or die(mysql_error()); //echo $acronym.":POSTS:".$posts."<br>"; echo '<table border="1">'; echo "<tr>"; echo "<th>Category</th>"; echo "<th>".$acronym."</th>"; echo "</tr>"; echo "<tr>"; echo "<td>POSTS:DATE:".$postdate_formatted."</td>"; echo "<td>".$posts."</td>"; echo "</tr>"; } $threaddate=mysql_query("SELECT * from thread WHERE dateline >='$limit' ORDER by dateline DESC") or die(mysql_error()); while($threaddate_results=mysql_fetch_assoc($threaddate)) { $threaddate_record=$threaddate_results['dateline']; $threaddate_formatted=date('M dS Y ',$threaddate_results['dateline']); $thread_count=mysql_query("SELECT * from thread WHERE dateline='$threaddate_record'"); while($thread_count_results=mysql_fetch_assoc($thread_count)) { $threads=mysql_num_rows($thread_count) or die(mysql_error()); //echo $acronym.":THREADS:".$threads."<br>"; echo "<tr>"; echo "<td>THREADS:DATE:".$threaddate_formatted."</td>"; echo "<td>".$threads."</td>"; echo "</tr>"; $userdate=mysql_query("SELECT * from user WHERE joindate >='$limit' ORDER by joindate DESC") or die(mysql_error()); while($userdate_results=mysql_fetch_assoc($userdate)) { $userdate_record=$userdate_results['joindate']; $userdate_formatted=date('M dS Y ',$userdate_results['joindate']); $user_count=mysql_query("SELECT * from user WHERE joindate='$userdate_record'"); while($user_count_results=mysql_fetch_assoc($user_count)) { $users=mysql_num_rows($user_count) or die(mysql_error()); //echo $acronym.":USERS REGISTERED:".$users."<br>"; echo "<tr>"; echo "<td>REGISTERED USERS::DATE:".$userdate_formatted."</td>"; echo "<td>".$users."</td>"; echo "</tr>"; } } } } } } echo "</table>"; ?> |