PHP - Parts Of Code Working Some Not.......
so I have this code..........(not in brackets sorry)
<table width="410" border="1" cellspacing="0" cellpadding="0"> <tr> <td width="339" bgcolor="#999999" scope="col">EVENTS</td> </tr> <tr> <td class="afasd"><?php echo date("F",strtotime("-0 month")); ?></td> </tr> <tr> <td><?php if ($startdate == date("F",strtotime("-0 month"))){ echo "<p><a href='viewevent.php?eventid=$eventid'>$startdate - $enddate --- $event</a></p>\r\n"; }else{ echo"there are no events scheduled for this month" ;} ?></td> </tr> <tr> <td class="adfaf"><?php echo date("F",strtotime("+1 month")); ?></td> </tr> <tr> <td><?php if ($startdate == date("F",strtotime("+1 month"))){ echo "<p><a href='viewevent.php?eventid=$eventid'>$startdate - $enddate --- $event</a></p>\r\n"; }else{ echo"there are no events scheduled for this month" ;} ?></td> </tr> <tr> <td class="jasdfjs"><?php echo date("F",strtotime("+2 month")); ?></td> </tr> <tr> <td><?php if ($startdate == date("F",strtotime("+2 month"))){ echo "<p><a href='viewevent.php?eventid=$eventid'>$startdate - $enddate --- $event</a></p>\r\n"; }else{ echo"there are no events scheduled for this month" ;} ?></td> </tr> </table> so Only the third piece is working displaying correct things...........the other two don't display at all....... Similar Tutorialshttp://paste.ee/p/OhiWv
The above is a link to a readable version of my code. The XMLHTTPREQUEST worked, and the array was pulled down. Was able to print out the undecoded/unparsed array. However, immediately afterwards, all code stops working.
<script> var xhr; if (window.XMLHttpRequest) { // Mozilla, Safari, ... xhr = new XMLHttpRequest(); } else if (window.ActiveXObject) { // IE 8 and older xhr = new ActiveXObject("Microsoft.XMLHTTP"); } xhr.open("POST", "PHPLibrary/selectMemberResults.php", true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.send(); xhr.onreadystatechange = display_data; var $phparray function display_data() { if (xhr.readyState == 4) { if (xhr.status == 200) { //alert(xhr.responseText); $phparray = xhr.responseText; document.getElementById("suggestion").innerHTML = $phparray; // // //......................................................? // The above line of code is the last thing to print or // to do anything that returns to the browser.... //.......................................................? // All lines below do nothing............................? // } else { //alert('There was a problem with the request.'); } } } document.write("Length of phparray Array :" + $phparray.length + "<"); var output = JSON.parse($phparray, function (key,val) { if ( typeof val === 'string' ) { // regular expression to remove extra white space if ( val.indexOf('\n') !== -1 ) { var re = /\s\s+/g; return val.replace(re, ' '); } else { return val; } } return val; } ); document.write("Length of Array :" + $output.length + "<"); for (var i=0; i < $output.length; i++) { document.getElementById("suggestion").innerHTML = $output[i].MEMBER_NAME; } </script> i dont understand what is wrong plz help me.
here is code
$name = "img/".rand(1,9999999).".png"; $myFile = $name; $fh = fopen($myFile, 'w') or die("can't open file"); $stringData = $html; fwrite($fh, $stringData); fclose($fh); $file=$name; $fst=file_get_contents($file); $im=imagecreatefromstring($fst); imagefilter($im, IMG_FILTER_GRAYSCALE); imagefilter($im, IMG_FILTER_NEGATE); //Convert to Grey Scale for($i=0;$i<123;$i++){ for($j=0;$j<50;$j++){ $px=imagecolorat($im,$i,$j); if($px<0x303030){ imagesetpixel($im,$i,$j,0); }else{ imagesetpixel($im,$i,$j,0xffffff); } } } $database = unserialize(@file_get_contents("db.txt")); if($database === false) $database = array(); // modify the database if needed if($_SERVER['REQUEST_METHOD'] == 'POST'){ if($_POST['submit'] == 'Add') $database[$_POST['ident']] = substr($_POST['letter'], 0, 1); if($_POST['submit'] == 'Del') unset($database[$_POST['ident']]); if($fh = @fopen('db111.txt', 'w+')){ fwrite($fh, serialize($database)); fclose($fh); } }else{ $newimage = true; } $width = 130; $height = 40; $captcha_gridstart =1; $captcha_gridspace =2; $letters = findletters($im, $width, $height, $captcha_gridstart, $captcha_gridspace); $count = count($letters); $cellw = ($count > 0) ? intval(100 / $count) : 0; //dispeckle the image and GET co-ordinates of the characters of captcha image and return them. function findletters($image, $width, $height, $gridstart, $gridspace){ $offsets = array(); $o = 0; $atstartx = true; for($x = 0; $x < $width; $x++){ $blankx = true; for($y = 0; $y < $height; $y++){ if(imagecolorat($image, $x, $y) == 0){ $blankx = false; break; } } if(!$blankx && $atstartx){ $offsets[$o]['startx'] = $x; $atstartx = !$atstartx; }else if($blankx && !$atstartx){ $offsets[$o]['endx'] = $x; $atstartx = !$atstartx; $o++; } } $count = $o; for($o = 0; $o < $count; $o++){ for($y = 0; $y < $height; $y++){ $blanky = true; for($x = $offsets[$o]['startx']; $x < $offsets[$o]['endx']; $x++){ if(imagecolorat($image, $x, $y) == 0){ $blanky = false; break; } } if(!$blanky){ $offsets[$o]['starty'] = $y; break; } } for($y = $height-1; $y > $offsets[$o]['starty']; $y--){ $blanky = true; for($x = $offsets[$o]['startx']; $x < $offsets[$o]['endx']; $x++){ if(imagecolorat($image, $x, $y) == 0){ $blanky = false; break; } } if(!$blanky){ $offsets[$o]['endy'] = $y; break; } } } for($o = 0; $o < $count; $o++){ $offsets[$o]['ident'] = ""; for($x = $offsets[$o]['startx'] + $gridstart; $x < $offsets[$o]['endx']; $x += $gridspace){ for($y = $offsets[$o]['starty'] + $gridstart; $y < $offsets[$o]['endy']; $y += $gridspace){ $offsets[$o]['ident'] .= ((imagecolorat($image, $x, $y) == 0) ? "0" : "1"); #echo $offsets[$o]['ident'].'<br>'; } } } return $offsets; } $a=""; foreach($letters as $letter){ $asciiletter = $database[$letter['ident']]; if(!empty($asciiletter)) { $a.=$asciiletter; } } Hi all,
I would like some input on database structure for a website that will sell car parts. Necessary fields a
Manufacturer
Part type (eg: exhaust, brakes, engine etc)
Part number
Description
Year & make of vehicle it fits (may need to be separate fields, I don't know, this is my main conundrum) **
Keep in mind, this is a basic example and purely hypothetical at this moment. I haven't done any coding yet.
My main roadblock at the moment is figuring out how to engineer part compatibility in conjunction with a search. Many parts fit many different vehicles. For example, part A123 could fit:
1999-2004 Jetta 2.0
1999-2004 Golf 2.0
1999-2004 Passat 1.9
In your opinion, what would be the most efficient way to store and retreive matching parts? Would I have each model as a separate row? i.e:
row 1: 2002-2004 Jetta ... part A123
row 2: 1999-2004 Golf... part A123
row 3: 1999-2004 Passat... part A123
Basically I would have many duplicate rows where only the year and vehicle model changes. This would definitely work, but would eventually lead to a very large and messy database.
There are already companies that offer a service such as this, but I am looking at looking to sell less products and secondly, in a different language. At the moment, I'm trying to figure out the best way that I could do it. Once I have an idea in mind, then I can decide whether I want to go ahead with that or use a pre-made commercial platform.
I have a database full of strings which are basically URL's with ports, so by default my strings look like: http://example.com:1234/ http://example2.com:3030/ http://example.com:9876/ http://example.com:5432/ What I am looking for is a way to separate the host from the post so the output would be something like: Host: example.com Port: 1234 Note: I once need to check one string at a time, so what I am after is something like: $string = "http://example.com:1234/"; And the result would be something like: $host (would be example.com without http://) $port (would be the port without ending /) Any help would be great Thanks for your time reasing this. Hi I want to hide the login box's of my webpage once you login. I have thought of two ways of doing it but which one would you say is better practice? 1. use a PHP if statement to echo 'Display: none on css' - when viewing source code it still shows the form but not displayed on page itself 2. use a PHP if statement around the whole <form></form> so it physically doesnt write the html if already logged in? Or if anyone has a better way it would be appreciated if you would share it? Thanks in advance hello guys
i wand to split the 24h of a day to parts and select the time that i wand to start the 24h circle to count!
lets say
i give 2 int variables
$day_starts_to_count_from=00;
$split_day_to_parts=4;
so!
$hours_per_part = 24/$split_day_to_parts;
this gives me $hours_per_part = 6 (i split the 24h every 6hr)
how to know the part of my current hour?
lets say the system time is 15:35
how to find that im at the 3d part 12:00-18:00 if the 24h circle starts to count from 00:00
thanks in advance
I have an image which is a complete image that has 4 titles(aquatic weeds,green algae,water quality,bottom muck) Can i write a code somehow that when i hover over those images or title i can link it to different hyperlinks? Hi, Everyone! I have an issue and I'm not even sure if it can be done with PHP, but even this info would help me (to stop looking for an answer). I need to populate a (MySQL) database with stuff which is now written in a (HTML formatted) file. Here are my options: 1. Copy/paste each single field via PHPMyAdmin . 2. Write a little script to extract the necessary parts of text from these files to create a CSV-like content which I would then easily INSERT into the db. Example The files look like this: Code: [Select] <!-- SEPARATOR (same throughout the file(s) --> <tr><td> <div style="something"><img src="img/what_i_need_to_extract_1.png"></div> </td><td> <div style="something else"><b>What I need to extract 2</b></div> <div style="something else">What I need to extract 3</div> </td></tr> <!-- SEPARATOR (same throughout the file(s) --> etc ... and it goes like... 100 times in each file in the same standard pattern with the "What I need to extract" parts being completely different each time. Since it's possible to tell when each part required for extraction begins and ends, I would expect the script to look for these key-points (according to the example, it would be: img/ to "></d then "><b> to </b>< and else"> to </div>) and return a result like this (acc. to the example): ('what_i_need_to_extract_1.png', 'What I need to extract 2', 'What I need to extract 3'), (and so on...). Is it possible? Is there a function/option/way to look for a start/end-point like this and fetch the part between these two set points? If so - how? Any help would be appreciated, I'm not expecting a full code, obviously, just a point to the right direction or where to look at would be nice. Thanks in advance. Hi, I have had some developers do me some work but the person who did it has gone away for three weeks and it has stopped working. On my webpage https://bellevedeals.co.uk there's three flags (UK, US and EU) which when clicked are meant to load the appropriate menu's. This was working fine but for some reason is now not! I have created a page to prove that the cookies are outputting correctly, this is the case. When I click the US flag for example and load the page https://bellevedeals.co.uk/cookie.php it echos 'us'. Is anyone able to help me out? My header.php file is below. The code I believe is about line 256. Thank you so much in advance. Any questions or anything you need from me please let me know :) Matt <!DOCTYPE html> <html <?php language_attributes(); ?>> <head> <meta charset="<?php bloginfo( 'charset' ); ?>" /> <?php elegant_description(); elegant_keywords(); elegant_canonical(); /** * Fires in the head, before {@see wp_head()} is called. This action can be used to * insert elements into the beginning of the head before any styles or scripts. * * @since 1.0 */ do_action( 'et_head_meta' ); $template_directory_uri = get_template_directory_uri(); ?> <link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" /> <script type="text/javascript"> document.documentElement.className = 'js'; </script> <?php wp_head(); ?> </head> <body <?php body_class(); ?>> <?php $product_tour_enabled = et_builder_is_product_tour_enabled(); $page_container_style = $product_tour_enabled ? ' style="padding-top: 0px;"' : ''; ?> <div id="page-container"<?php echo et_core_intentionally_unescaped( $page_container_style, 'fixed_string' ); ?>> <?php if ( $product_tour_enabled || is_page_template( 'page-template-blank.php' ) ) { return; } $et_secondary_nav_items = et_divi_get_top_nav_items(); $et_phone_number = $et_secondary_nav_items->phone_number; $et_email = $et_secondary_nav_items->email; $et_contact_info_defined = $et_secondary_nav_items->contact_info_defined; $show_header_social_icons = $et_secondary_nav_items->show_header_social_icons; $et_secondary_nav = $et_secondary_nav_items->secondary_nav; $et_top_info_defined = $et_secondary_nav_items->top_info_defined; $et_slide_header = 'slide' === et_get_option( 'header_style', 'left' ) || 'fullscreen' === et_get_option( 'header_style', 'left' ) ? true : false; ?> <?php if ( $et_top_info_defined && ! $et_slide_header || is_customize_preview() ) : ?> <?php ob_start(); ?> <div id="top-header"<?php echo $et_top_info_defined ? '' : 'style="display: none;"'; ?>> <div class="container clearfix"> <?php if ( $et_contact_info_defined ) : ?> <div id="et-info"> <?php if ( '' !== ( $et_phone_number = et_get_option( 'phone_number' ) ) ) : ?> <span id="et-info-phone"><?php echo et_core_esc_previously( et_sanitize_html_input_text( $et_phone_number ) ); ?></span> <?php endif; ?> <?php if ( '' !== ( $et_email = et_get_option( 'header_email' ) ) ) : ?> <a href="<?php echo esc_attr( 'mailto:' . $et_email ); ?>"><span id="et-info-email"><?php echo esc_html( $et_email ); ?></span></a> <?php endif; ?> <?php if ( true === $show_header_social_icons ) { get_template_part( 'includes/social_icons', 'header' ); } ?> </div> <!-- #et-info --> <?php endif; // true === $et_contact_info_defined ?> <div id="et-secondary-menu"> <?php if ( ! $et_contact_info_defined && true === $show_header_social_icons ) { get_template_part( 'includes/social_icons', 'header' ); } else if ( $et_contact_info_defined && true === $show_header_social_icons ) { ob_start(); get_template_part( 'includes/social_icons', 'header' ); $duplicate_social_icons = ob_get_contents(); ob_end_clean(); printf( '<div class="et_duplicate_social_icons"> %1$s </div>', et_core_esc_previously( $duplicate_social_icons ) ); } if ( '' !== $et_secondary_nav ) { echo et_core_esc_wp( $et_secondary_nav ); } et_show_cart_total(); ?> </div> <!-- #et-secondary-menu --> </div> <!-- .container --> </div> <!-- #top-header --> <?php $top_header = ob_get_clean(); /** * Filters the HTML output for the top header. * * @since 3.10 * * @param string $top_header */ echo et_core_intentionally_unescaped( apply_filters( 'et_html_top_header', $top_header ), 'html' ); ?> <?php endif; // true ==== $et_top_info_defined ?> <?php if ( $et_slide_header || is_customize_preview() ) : ?> <?php ob_start(); ?> <div class="et_slide_in_menu_container"> <?php if ( 'fullscreen' === et_get_option( 'header_style', 'left' ) || is_customize_preview() ) { ?> <span class="mobile_menu_bar et_toggle_fullscreen_menu"></span> <?php } ?> <?php if ( $et_contact_info_defined || true === $show_header_social_icons || false !== et_get_option( 'show_search_icon', true ) || class_exists( 'woocommerce' ) || is_customize_preview() ) { ?> <div class="et_slide_menu_top"> <?php if ( 'fullscreen' === et_get_option( 'header_style', 'left' ) ) { ?> <div class="et_pb_top_menu_inner"> <?php } ?> <?php } if ( true === $show_header_social_icons ) { get_template_part( 'includes/social_icons', 'header' ); } et_show_cart_total(); ?> <?php if ( false !== et_get_option( 'show_search_icon', true ) || is_customize_preview() ) : ?> <?php if ( 'fullscreen' !== et_get_option( 'header_style', 'left' ) ) { ?> <div class="clear"></div> <?php } ?> <form role="search" method="get" class="et-search-form" action="<?php echo esc_url( home_url( '/' ) ); ?>"> <?php printf( '<input type="search" class="et-search-field" placeholder="%1$s" value="%2$s" name="s" title="%3$s" />', esc_attr__( 'Search …', 'Divi' ), get_search_query(), esc_attr__( 'Search for:', 'Divi' ) ); ?> <button type="submit" id="searchsubmit_header"></button> </form> <?php endif; // true === et_get_option( 'show_search_icon', false ) ?> <?php if ( $et_contact_info_defined ) : ?> <div id="et-info"> <?php if ( '' !== ( $et_phone_number = et_get_option( 'phone_number' ) ) ) : ?> <span id="et-info-phone"><?php echo et_core_esc_previously( et_sanitize_html_input_text( $et_phone_number ) ); ?></span> <?php endif; ?> <?php if ( '' !== ( $et_email = et_get_option( 'header_email' ) ) ) : ?> <a href="<?php echo esc_attr( 'mailto:' . $et_email ); ?>"><span id="et-info-email"><?php echo esc_html( $et_email ); ?></span></a> <?php endif; ?> </div> <!-- #et-info --> <?php endif; // true === $et_contact_info_defined ?> <?php if ( $et_contact_info_defined || true === $show_header_social_icons || false !== et_get_option( 'show_search_icon', true ) || class_exists( 'woocommerce' ) || is_customize_preview() ) { ?> <?php if ( 'fullscreen' === et_get_option( 'header_style', 'left' ) ) { ?> </div> <!-- .et_pb_top_menu_inner --> <?php } ?> </div> <!-- .et_slide_menu_top --> <?php } ?> <div class="et_pb_fullscreen_nav_container"> <?php $slide_nav = ''; $slide_menu_class = 'et_mobile_menu'; $slide_nav = wp_nav_menu( array( 'theme_location' => 'primary-menu', 'container' => '', 'fallback_cb' => '', 'echo' => false, 'items_wrap' => '%3$s' ) ); $slide_nav .= wp_nav_menu( array( 'theme_location' => 'secondary-menu', 'container' => '', 'fallback_cb' => '', 'echo' => false, 'items_wrap' => '%3$s' ) ); ?> <ul id="mobile_menu_slide" class="<?php echo esc_attr( $slide_menu_class ); ?>"> <?php if ( '' === $slide_nav ) : ?> <?php if ( 'on' === et_get_option( 'divi_home_link' ) ) { ?> <li <?php if ( is_home() ) echo( 'class="current_page_item"' ); ?>><a href="<?php echo esc_url( home_url( '/' ) ); ?>"><?php esc_html_e( 'Home', 'Divi' ); ?></a></li> <?php }; ?> <?php show_page_menu( $slide_menu_class, false, false ); ?> <?php show_categories_menu( $slide_menu_class, false ); ?> <?php else : echo et_core_esc_wp( $slide_nav ) ; endif; ?> </ul> </div> </div> <?php $slide_header = ob_get_clean(); /** * Filters the HTML output for the slide header. * * @since 3.10 * * @param string $top_header */ echo et_core_intentionally_unescaped( apply_filters( 'et_html_slide_header', $slide_header ), 'html' ); ?> <?php endif; // true ==== $et_slide_header ?> <?php ob_start(); ?> <header id="main-header" data-height-onload="<?php echo esc_attr( et_get_option( 'menu_height', '66' ) ); ?>"> <div class="container clearfix et_menu_container"> <?php $logo = ( $user_logo = et_get_option( 'divi_logo' ) ) && ! empty( $user_logo ) ? $user_logo : $template_directory_uri . '/images/logo.png'; ob_start(); ?> <div class="logo_container"> <span class="logo_helper"></span> <a href="<?php echo esc_url( home_url( '/' ) ); ?>"> <img src="<?php echo esc_attr( $logo ); ?>" alt="<?php echo esc_attr( get_bloginfo( 'name' ) ); ?>" id="logo" data-height-percentage="<?php echo esc_attr( et_get_option( 'logo_height', '54' ) ); ?>" /> </a> </div> <?php $logo_container = ob_get_clean(); /** * Filters the HTML output for the logo container. * * @since 3.10 * * @param string $logo_container */ echo et_core_intentionally_unescaped( apply_filters( 'et_html_logo_container', $logo_container ), 'html' ); ?> <div id="et-top-navigation" data-height="<?php echo esc_attr( et_get_option( 'menu_height', '66' ) ); ?>" data-fixed-height="<?php echo esc_attr( et_get_option( 'minimized_menu_height', '40' ) ); ?>"> <?php if ( ! $et_slide_header || is_customize_preview() ) : ?> <nav id="top-menu-nav"> <?php $menuClass = 'nav'; if ( 'on' === et_get_option( 'divi_disable_toptier' ) ) $menuClass .= ' et_disable_top_tier'; $primaryNav = ''; if($_COOKIE['storeselector']=='uk') { $primaryNav = wp_nav_menu( array( 'theme_location' => 'primary-menu', 'container' => '', 'fallback_cb' => '', 'menu_class' => $menuClass, 'menu_id' => 'top-menu', 'echo' => false ) ); } else if($_COOKIE['storeselector']=='us'){ $primaryNav = wp_nav_menu( array( 'theme_location' => 'us-menu', 'container' => '', 'fallback_cb' => '', 'menu_class' => $menuClass, 'menu_id' => 'top-menu', 'echo' => false ) ); } else if($_COOKIE['storeselector']=='eu'){ $primaryNav = wp_nav_menu( array( 'theme_location' => 'eu-menu', 'container' => '', 'fallback_cb' => '', 'menu_class' => $menuClass, 'menu_id' => 'top-menu', 'echo' => false ) ); } else{ $primaryNav = wp_nav_menu( array( 'theme_location' => 'primary-menu', 'container' => '', 'fallback_cb' => '', 'menu_class' => $menuClass, 'menu_id' => 'top-menu', 'echo' => false ) ); } if ( empty( $primaryNav ) ) : ?> <ul id="top-menu" class="trans <?php echo esc_attr( $menuClass ); ?>"> <?php if ( 'on' === et_get_option( 'divi_home_link' ) ) { ?> <li <?php if ( is_home() ) echo( 'class="current_page_item"' ); ?>><a href="<?php echo esc_url( home_url( '/' ) ); ?>"><?php esc_html_e( 'Home', 'Divi' ); ?></a></li> <?php }; ?> <?php show_page_menu( $menuClass, false, false ); ?> <?php show_categories_menu( $menuClass, false ); ?> <li class="menu-item"><div class="langselectorr"> <img src="<?php echo get_option( 'my_layout_option9', true );?>" class="lanchooserico uslang" title="USA"> <img src="<?php echo get_option( 'my_layout_option8', true );?>" class="lanchooserico uklang" title="United Kingdom"> <img src="<?php echo get_option( 'my_layout_option10', true );?>" class="lanchooserico eulang" title="Europe"> </div></li> </ul> <?php else : echo et_core_esc_wp( $primaryNav ); endif; ?> </nav> <?php endif; ?> <?php if ( ! $et_top_info_defined && ( ! $et_slide_header || is_customize_preview() ) ) { //et_show_cart_total( array('no_text' => true,) ); } ?> <?php if ( $et_slide_header || is_customize_preview() ) : ?> <!--<span class="mobile_menu_bar et_pb_header_toggle et_toggle_<?php echo esc_attr( et_get_option( 'header_style', 'left' ) ); ?>_menu"></span>--> <?php endif; ?> <?php if ( ( false !== et_get_option( 'show_search_icon', true ) && ! $et_slide_header ) || is_customize_preview() ) : ?> <div id="et_top_search"> <div class="langselectorr"> <img src="<?php echo get_option( 'my_layout_option9', true );?>" class="lanchooserico uslang" title="USA"> <img src="<?php echo get_option( 'my_layout_option8', true );?>" class="lanchooserico uklang" title="United Kingdom"> <img src="<?php echo get_option( 'my_layout_option10', true );?>" class="lanchooserico eulang" title="Europe"> </div> <!--<span id="et_search_icon"></span>--> </div> <?php endif; // true === et_get_option( 'show_search_icon', false ) ?> <?php /** * Fires at the end of the 'et-top-navigation' element, just before its closing tag. * * @since 1.0 */ do_action( 'et_header_top' ); ?> <div class="langselectorr"> <img src="<?php echo get_option( 'my_layout_option9', true );?>" class="lanchooserico uslang" title="USA"> <img src="<?php echo get_option( 'my_layout_option8', true );?>" class="lanchooserico uklang" title="United Kingdom"> <img src="<?php echo get_option( 'my_layout_option10', true );?>" class="lanchooserico eulang" title="Europe"> </div> </div> <!-- #et-top-navigation --> </div> <!-- .container --> <div class="et_search_outer"> <div class="container et_search_form_container"> <form role="search" method="get" class="et-search-form" action="<?php echo esc_url( home_url( '/' ) ); ?>"> <?php printf( '<input type="search" class="et-search-field" placeholder="%1$s" value="%2$s" name="s" title="%3$s" />', esc_attr__( 'Search …', 'Divi' ), get_search_query(), esc_attr__( 'Search for:', 'Divi' ) ); ?> </form> <span class="et_close_search_field"></span> </div> </div> </header> <!-- #main-header --> <?php $main_header = ob_get_clean(); /** * Filters the HTML output for the main header. * * @since 3.10 * * @param string $main_header */ echo et_core_intentionally_unescaped( apply_filters( 'et_html_main_header', $main_header ), 'html' ); ?> <div id="et-main-area"> <?php /** * Fires after the header, before the main content is output. * * @since 3.10 */ do_action( 'et_before_main_content' ); ?> <style type="text/css"> @media only screen and (min-width:981px) { .et_header_style_left #et-top-navigation, .et_header_style_split #et-top-navigation { padding:39px 0 0 0; } .lanchooserico {cursor: pointer;float: left;margin-right: 4px;width: 20px;} .langselectorr{width:85px;} .lanchooserico.active {background-color: #f8bd18;opacity: 0.8;border: 1px solid #f8bd18;} .et_search_outer{display: none !important;opacity: 0;} </style> <script type="text/javascript"> jQuery('.uslang').on('click',function(){ setCookie('storeselector','us',365); jQuery('.uslang').addClass('active'); jQuery('.uklang').removeClass('active'); jQuery('.eulang').removeClass('active'); window.location.href = "https://bellevedeals.co.uk/"; }); jQuery('.uklang').on('click',function(){ setCookie('storeselector','uk',365); jQuery('.uklang').addClass('active'); jQuery('.uslang').removeClass('active'); jQuery('.eulang').removeClass('active'); window.location.href = "https://bellevedeals.co.uk/"; }); jQuery('.eulang').on('click',function(){ setCookie('storeselector','eu',365); jQuery('.eulang').addClass('active'); jQuery('.uslang').removeClass('active'); jQuery('.uklang').removeClass('active'); window.location.href = "https://bellevedeals.co.uk/"; }); jQuery(document).ready(function(){ if(getCookie('storeselector')=='us') { jQuery('.uslang').addClass('active'); jQuery('.uklang').removeClass('active'); jQuery('.eulang').removeClass('active'); } else if(getCookie('storeselector')=='uk') { jQuery('.uklang').addClass('active'); jQuery('.uslang').removeClass('active'); jQuery('.eulang').removeClass('active'); } else if(getCookie('storeselector')=='eu') { jQuery('.eulang').addClass('active'); jQuery('.uslang').removeClass('active'); jQuery('.uklang').removeClass('active'); } else { jQuery('.uklang').addClass('active'); jQuery('.uslang').removeClass('active'); jQuery('.eulang').removeClass('active'); } }); function setCookie(cname, cvalue, exdays) { var d = new Date(); d.setTime(d.getTime() + (exdays*24*60*60*1000)); var expires = "expires="+ d.toUTCString(); document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/"; } function getCookie(cname) { var name = cname + "="; var decodedCookie = decodeURIComponent(document.cookie); var ca = decodedCookie.split(';'); for(var i = 0; i <ca.length; i++) { var c = ca[i]; while (c.charAt(0) == ' ') { c = c.substring(1); } if (c.indexOf(name) == 0) { return c.substring(name.length, c.length); } } return ""; } </script> <?php setcookie("myCookie", '879', time() + 3600); ?>
Is this possible? Could the following code be replaced with one .txt consisting of two digits? Code: [Select] $myFile = "offerrotation.txt"; $myFile2 = "lprotation.txt"; $fh = @fopen($myFile, 'r'); $offerNumber = @fread($fh, 5); @fclose($fh); $fh = @fopen($myFile2, 'r'); $lpNumber = @fread($fh, 5); @fclose($fh); Many thanks hello everybody! This is just basic script, where i try to modify for the needs. I try to play with it. i want to parse some data. The whole script has three parts: 1. Fetching 2. parsing 3. storing i want to put all into one script: Two are allready put together - there all seems to be clear... So this thread is one that asks for the combining two parts of a script - how to invoke a variable between them What has happened untill now: 1st i need to have a connection to database lets say MySQL. I will suggest to use mysqli instead of mysql. Well - okay i safe this db.php $host="localhost"; //database hostname $username="******"; //database username $password="******"; //database password $database="******"; //database name ?> Now i am going to take a new script and save this config.php <?php require_once('db.php'); //call db.php $connect=mysqli_connect($host,$username,$password); //connect to mysql through mysqli if(!$connect){ die("Cannot connect to host, please try later."); //throw error if any problem } else { $select_db=mysqli_select_db($database); //select database if(!$select_db){ die("Site Database is down at the moment, Please check later. We will be back shortly."); // error if cannot connect to database or db does not exist } } ?> Now i have to take care for the script, that takes the files (note this is very basic - it is only a proof of concept. In the real situation i will take cURL since cURL is much much nicer and more elegant and faster etc. <?php require_once('config.php'); // call config.php for db connection $content = file_get_contents("<-here the path to the file goes in-> Position XY! an URL is here "); var_dump($content); $pattern = '/<td>(.*?)<\/td>/si'; preg_match_all($pattern,$content,$matches); foreach ($matches[1] as $match) { $match = strip_tags($match); $match = trim($match); var_dump($match); $sql = mysqli_query("insert into tablename(contents) values ('$match')"); } ?> Note: This is just basic script, where you can modify it for your taste and can play with it. Question: If i have stored the URLs that i want to parse in a local file - how do i "call" them in the script. How do i do the call to file where the URLs (there are more than 2500 URLs that have to be parsed) at the following position: $content = file_get_contents("<-here the path to the file goes in-> Position XY! an URL is here "); The folder with the URLs is stored in the same folder as the scripts reside! Many thanks for all hints and for a starting point! if i have to write more - or if you need more infos - or if i have to be more concrete, just let me know! i love to hear from you! db1 hello dear community, good day i have a problem - a parser that does not parse. IT does not work! It gives not back anything! Code: [Select] <?PHP // Original PHP code by Chirp Internet: http://www.chirp.com.au // Please acknowledge use of this code by including this header. $url = "http://www.edi.admin.ch/esv/00475/00698/index.html?lang=de"; //$input = @file_get_contents($url) or die("Could not access file: $url"); $input = file_get_contents($url) or die("Could not access file: $url"); $regexp = "<a\s[^>]*href=(\"??)([^\" >]*?)\\1[^>]*>(.*)<\/a>"; if(preg_match_all("/$regexp/siU", $input, $matches, PREG_SET_ORDER)) { foreach($matches as $match) { // $match[2] = all the data i want to collect... // $match[3] = text that i need to collect - see a detail-page } } ?> well - it goes a bit over my head: "what - i have did" - it does not give back any results!? i look forward to hear from you! regards Currently my code picks a random number between 1-6 then extracts that many (random) entries from a list in my database. My current code displays the whole array, how can I chop the array into 6 bits so I can output the data separately (up to 6 list items)? $con = mysql_connect("x","x","x"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("x", $con); $ran_x = rand(1,6); $appearance_query = "SELECT * FROM `x` ORDER BY RAND( ) LIMIT $ran_x"; $get_x = mysql_query($x_query); echo 'x(s): '; echo '<br />'; echo "<ul style='list-style:none;'>"; while($row = mysql_fetch_array($get_x)) { echo "<li>" . $row['x'] . "</li>"; } echo "</ul>"; echo "<br />"; mysql_close($con); Any help would be greatly appreciated, Thanks, otester Hi. I will try and explain simply.
I have a list of item codes eg.
size1 Acolor1
size1 Bcolor3
size1 Bcolor1
size1 Acolor3
size1 Acolor4
size2 Acolor1
size3 Bcolor1
size3 Bcolor2
size3 Bcolor2
size3 Acolor1
I want to take these and split them into parts:
size1 Acolor2
size1 Bcolor3
etc.
Then I want to create a form with 2 dropdowns. The first option would just have all unique sizes so:
size1
size2
size3
Then when one is selected, option 2 would show the colours available in that size.
Is there a standard way of doing this? Can I use PHP to create the array and then jquery to display and hide the options?
I'm totally stuck and i'm not just looking for somebody to code it all for me. any help would be greatly appreciated
thanks
Sam
Hi, I have a registration page (that one works fine) where users register with minimal personal info. They also get to rate 8 categories (see bellow) 1-5. Once they hit submit it all goes into database just fine. I have also created a page for myself where I can recall all data for any registration. All data gets pulled from database correctly. When I change variables and hit submit it does not update the record in the database. I get no errors from the script, but I have narrowed the problem to the recall of categories and the ratings. If I remove them from the update script other info gets stored correctly. Here is how I recall the 8 categories and their user submitted ratings (as well as other info): Code: [Select] $category = array('AS','BE','BI','CH','CS','EG','EV','PH'); foreach ($category as $cat) { if ($cat == 'AS') $cat_name = 'Animal Sciences'; if ($cat == 'BE') $cat_name = 'Behavioral & Social Sciences'; if ($cat == 'BI') $cat_name = 'Biology'; if ($cat == 'CH') $cat_name = 'Chemistry'; if ($cat == 'CS') $cat_name = 'Computer Science'; if ($cat == 'EG') $cat_name = 'Engineering'; if ($cat == 'EV') $cat_name = 'Environmental Sciences'; if ($cat == 'PH') $cat_name = 'Physical Sciences'; echo" <tr> <td>$cat_name</td>"; $numbers = array('0','1','2','3','4','5'); foreach ($numbers as $no) { echo "<td><input type='radio' name='$cat' value='$no'"; if ($row[$cat] == $no) echo " checked/>"; else echo "/>"; echo"$no</td>"; }} And here is how I update the record (as well as other info not listed): Code: [Select] mysql_query("UPDATE registrations SET AS = '$_POST[AS]', BE = '$_POST[BE]', BI = '$_POST[BI]', CH = '$_POST[CH]', CS = '$_POST[CS]', EG = '$_POST[EG]', EV = '$_POST[EV]', PH = '$_POST[PH]' WHERE ID = '$_POST[ID]' "); Something in my recall code is creating issued for me, but I have no idea what. Thanks <?php $con = mysql_connect("localhost","root","password"); if (!$con) { die('Could not connect:' . mysql_error()); } mysql_select_db("Products", $con); $status = $_POST["c1"]; $result=mysql_query("SELECT * FROM btp_reviews ORDER BY status =".$status.""); mysql_db_query("Products", $result) or die("Failed Query of " . $result); mysql_close($con); ?> Hello Guys n Gals too.. I have this big problem thats driving me nuts!! I have this login page that is not working. when i put the username n password all it does is reload itself. Alot of pages depend on the login and they dont work cozz login doesnt So please help me out. Thanx. Heres the code: Code: [Select] <?php include ("./common.php"); include ("./Header.php"); include ("./Footer.php"); // Login CustomIncludes end //------------------------------- session_start(); //=============================== // Save Page and File Name available into variables //------------------------------- $sFileName = "Login.php"; $sAction = get_param("FormAction"); $sForm = get_param("FormName"); //=============================== // Login Show begin //=============================== // Perform the form's action //------------------------------- // Initialize error variables //------------------------------- $sLoginErr = ""; //------------------------------- // Select the FormAction //------------------------------- switch ($sForm) { case "Login": Login_action($sAction); break; } //=============================== //=============================== // Display page //=============================== // HTML Page layout //------------------------------- ?><html> <head> <title>Pablo Online Rent-a-Car</title> <meta name="GENERATOR" content="Philmar"> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"></head> <body style="background-color: #FFFFFF; color: #000000; font-family: Arial, Tahoma, Verdana, Helveticabackground-color: #FFFFFF; color: #000000; font-family: Arial, Tahoma, Verdana, Helvetica"> <center> <table> <tr> <td valign="top"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Pablo Online Rent-a-Car</title> <script language="JavaScript" type="text/JavaScript"> <!-- function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}} } function MM_swapImgRestore() { //v3.0 var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc; } function MM_findObj(n, d) { //v4.01 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); if(!x && d.getElementById) x=d.getElementById(n); return x; } function MM_swapImage() { //v3.0 var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3) if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];} } //--> </script> </head> <body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="MM_preloadImages('images/mazda6_1.jpg','images/home_2.jpg','images/aboutus_2.jpg','images/contactus_2.jpg')"> <table width="778" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td><img src="images/header1.jpg" width="778" height="110"></td> </tr> </table> <table width="778" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td width="55"><img src="images/header2.jpg" width="55" height="43"></td> <td width ="17"><a href="default.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('home','','images/home_2.jpg',1)"><img src="images/home_1.jpg" alt="home" name="home" width="63" height="43" border="0"></a></td> <td width ="114" valign="middle"><a href="about.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('aboutphilmar','','images/aboutus_2.jpg',1)"><img src="images/aboutus_1.jpg" alt="aboutphilmar" name="aboutphilmar" width="114" height="43" border="0"></a></td> <td width ="111"><a href="contact.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('contactus','','images/contactus_2.jpg',1)"><img src="images/contactus_1.jpg" alt="contactus" name="contactus" width="108" height="43" border="0"></a></td> <td width ="455"><img src="images/header3.jpg" width="438" height="43"></td> </tr> </table> <table width="778" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td width="55"><img src="images/header4.jpg" width="55" height="48"></td> <td> </td> <td width="438"><img src="images/header5.jpg" width="438" height="48"></td> </tr> </table> <?php Menu_show() ?> </td> </tr> </table> </center> <table width="760" align="center"> <tr> <td align="center"> <hr color="#800000"><center> <table> <tr> <td valign="top"> <?php Login_show() ?> </td> </tr> </table> <hr color="#800000" width="60%"> </td> </tr> </table> <center> <table> <tr> <td valign="top"> <?php Footer_show() ?> </td> </tr> </table> </center> </body> </html> <?php // Login Show end //=============================== // Login Close Event begin // Login Close Event end //=============================== //******************************************************************************** //=============================== // Login Form Action //------------------------------- function Login_action($sAction) { global $db; global $sLoginErr; global $sFileName; global $styles; switch(strtolower($sAction)) { case "login": //------------------------------- // Login Login begin //------------------------------- $sLogin = get_param("Login"); $sPassword = get_param("Password"); $db->query("SELECT member_id,member_level FROM members WHERE member_login =".$sLogin. " AND member_password=".$sPassword.""); $is_passed = $db->next_record(); //------------------------------- // Login OnLogin Event begin // Login OnLogin Event end //------------------------------- if($is_passed) { //------------------------------- // Login and password passed //------------------------------- set_session("UserID", $db->f("member_id")); set_session("UserRights", $db->f("member_level")); $sPage = get_param("ret_page"); if (strlen($sPage)) header("Location: " . $sPage); else header("Location: Reservation.php"); } else { $sLoginErr = "Login or Password is incorrect."; } //------------------------------- // Login Login end //------------------------------- break; case "logout": //------------------------------- // Logout action //------------------------------- //------------------------------- // Login Logout begin //------------------------------- //------------------------------- // Login OnLogout Event begin // Login OnLogout Event end //------------------------------- session_unregister("UserID"); session_unregister("UserRights"); if(strlen(get_param("ret_page"))) header("Location:" . $sFileName . "?ret_page=" . urlencode(get_param("ret_page"))); else header("Location:" . $sFileName); //------------------------------- // Login Logout end //------------------------------- break; } } //=============================== //=============================== // Display Login Form //------------------------------- function Login_show() { global $sLoginErr; global $db; global $sFileName; global $styles; $querystring = get_param("querystring"); $ret_page = get_param("ret_page"); $sFormTitle = "Enter username and password"; //------------------------------- // Login Show begin //------------------------------- //------------------------------- // Login Open Event begin // Login Open Event end //------------------------------- ?> <table style="width:100%"> <form action="login.php" method="POST"> <input type="hidden" name="FormName" value="Login"> <tr><td style="background-color: #336699; text-align: Center; border-style: outset; border-width: 1" colspan="2"><font style="font-size: 10pt; color: #FFFFFF; font-weight: bold"><?=$sFormTitle?></font></td></tr> <? if ($sLoginErr) { ?> <tr><td colspan="2" style="background-color: #FFFFFF; border-width: 1"><font style="font-size: 10pt; color: #000000"><?= $sLoginErr ?></font></td></tr> <? } ?> <? if(get_session("UserID") == "") { //------------------------------- //- User is not logged in //------------------------------- ?> <tr><td style="background-color: #FFEAC5; border-style: inset; border-width: 0"><font style="font-size: 10pt; color: #000000">Login</font></td><td style="background-color: #FFFFFF; border-width: 1"><input type="text" name="Login" value="<?=tohtml(get_param("Login"))?>" maxlength="50"></td></tr> <tr><td style="background-color: #FFEAC5; border-style: inset; border-width: 0"><font style="font-size: 10pt; color: #000000">Password</font></td><td style="background-color: #FFFFFF; border-width: 1"><input type="password" name="Password" maxlength="50"></td></tr> <tr><td colspan="2"> <input type="hidden" name="FormAction" value="login"> <input type="submit" value="Login"> </td></tr> <? } else { //------------------------------- // User is logged in //------------------------------- $db->query("SELECT member_login FROM members WHERE member_id=". get_session("UserID")); $db->next_record(); ?> <tr><td style="background-color: #FFFFFF; border-width: 1"><font style="font-size: 10pt; color: #000000"> <?= $db->f("member_login") ?></font> <input type="hidden" name="FormAction" value="logout"> <input type="submit" value="Logout"> </td></tr> <? } ?> <input type="hidden" name="ret_page" value="<?= $ret_page ?>"><input type="hidden" name="querystring" value="<?= $querystring ?>"></td></tr> </form></table> <? } ?> <? include_once ("../includes/config.php"); include_once "../includes/dbconnect.php"; header("Content-type: image/jpeg"); $id = $_REQUEST['id']; $sql="SELECT product_image FROM tbl_product WHERE product_id='$id' "; $result=mysql_query($sql); while($row=mysql_fetch_array($result)) { $image= $row['product_image']; $image=imagecreatefromstring($image); $out=ImagejpeG($image); print ($out); }?> |