Everything posted by karloff
-
dynamic titles, descriptions, etc
thanks man, i tried that but can't get it working. buffering is enabled on my server, however there is no output.
-
dynamic titles, descriptions, etc
i have a template where i'm calling my pages which looks like this <?php // Start the session session_start(); //meta data for seo - don't not leave any of these variables blank $page = $_GET['page']; // Include functions require_once('includes/functions.inc.php'); // Include database connection require_once('includes/global.inc.php'); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title><?=$title?></title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="keywords" content="<?=$keywords?>" /> <meta name="description" content="<?=$description?>" /> </head> <body > <h1 class="logo"><strong>logo</strong></h1> if (($page=='home2') || ($page=='')) { @ require_once ("pages/home.php"); } else { @ require_once ("pages/" .$page .".php"); } ?> <?php include('includes/footer.php');?> now in my page i set the $title, however because i call it after the header section it doesn't show. how can i develop this so that it includes title?
-
ICANN announce expansion of TLD's
seems insane if you ask me, not many people will hunger after a .ass, etc. the boom for .com, etc will continue imo
-
xpath/ simplexml search query
managed to solve it by setting $price =[price>15000][price < 200000], etc ta
- xpath/ simplexml search query
-
xpath/ simplexml search query
SOLVED I can't get this to work, i have a property site which searches dependant on 3 variable and it seems to be ignoring the variable (therefore not searching:() here is my code // set price range if ($price < 1) { $price = '["price=0 to 500000000000"]'; } elseif ($price == 1) { $price = '["price=0 to 50000"]'; } elseif ($price == 2) { $price = '["price=50000 to 100000"]'; } elseif ($price == 3) { $price = '["price=100000 to 150000"]'; } elseif ($price == 4) { $price = '["price=150000 to 200000"]'; } elseif ($price == 5) { $price = '["price=200000 to 250000"]'; } elseif ($price == 6) { $price = '["price=250000 to 350000"]'; } elseif ($price == 7) { $price = '["price=350000 to 400000"]'; } elseif ($price == { $price = '["price=400000 to 500000"]'; } elseif ($price == 9) { $price = ''; } // set property type range if ($property_type < 0) { $prop_type = ''; } elseif ($property_type == 1) { $prop_type = '[type/en="Apartment"]'; } elseif ($property_type == 2) { $prop_type = '[type/en="Duplex"]'; } elseif ($property_type == 3) { $prop_type = '[type/en="Town house"]'; } elseif ($property_type == 4) { $prop_type = '[type/en="Villa"]'; } elseif ($property_type == 5) { $prop_type = '[type/en="Cortijo"]'; } elseif ($property_type == 6) { $prop_type = '[type/en="Log home"]'; } elseif ($property_type == 7) { $prop_type = '[type/en="Finca"]'; } elseif ($property_type == { $prop_type = '[type/en="Bungalow"]'; } elseif ($property_type == 9) { $prop_type = '[type/en="Pentouse"]'; } elseif ($property_type == 10) { $prop_type = '[type/en="Cave house"]'; } // set berrom no range //if ($bedroom_no > 4){ // $bedroom_no = "[beds>4]"; if ($bedroom_no < 1){ $bedroom_no = "[beds>0]"; } else { $bedroom_no = "[beds=$bedroom_no]"; } // Include the pagination class include 'pagination.class.php'; // Create the pagination object $pagination = new pagination; // some example data // set xpath search $result = $xml->xpath("//property".$price.$prop_type.$bedroom_no.""); // initiate the search and display list foreach ( $result as $list) { $propertyid = $list->id ; $date = $list->date; $ref = $list->ref; $price = $list->price; i thought that the quotes around $price may be my problem but i can't get it working $price = '["price=0 to 50000"]'; instead of $price = '[price=0 to 50000]'; if i remove the quotes and add a single variable to $result, it works fine, but if i include other variable i get this error. Warning: SimpleXMLElement::xpath() [function.SimpleXMLElement-xpath]: Invalid predicate in C:\xampp\htdocs\test\search.php on line 84 Warning: SimpleXMLElement::xpath() [function.SimpleXMLElement-xpath]: xmlXPathEval: evaluation failed in C:\xampp\htdocs\test\search.php on line 84 Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\test\search.php on line 87 does anyone know where i may be going wrong?
-
Web folder structure?
not really sure what your asking, stop me if i'm wrong. the www is a subdomain of your main domain name. there domain name is setup through your DNS settings, you should add a A RECORD to create the www (is it a A RECORD or CNAME? someone can correct me) Do you host you only server/ control DNS settings for you domains? anyway, back to topic, i usually set it up as css images includes js docs (sometimes)pages - if i'm creating a templating system very handy bit of script which let you setup your directories <?php // Set directories if(DIRECTORY_SEPARATOR == '\\') { $fullpath = str_replace("\\", "/", __FILE__); } else { $fullpath = __FILE__; } $breadcrumb = explode("/", $fullpath); $filename = end($breadcrumb); $temp = strlen(prev($breadcrumb))+1; $directory['base'] = substr($fullpath, strlen($_SERVER['DOCUMENT_ROOT']), (-1 * strlen($filename) - $temp)); $directory['include'] = substr($fullpath, 0, (-1 * strlen($filename))); $directory['image'] = $directory['base']."images/"; $directory['css'] = $directory['base']."css/"; $directory['script'] = $directory['base']."js/"; $temp = explode("/", substr($_SERVER['PHP_SELF'], strlen($directory['base']))); ?> i'm currently looking into code igniter framework which setup the directories in a far bigger way, looks good:)
-
Silly doubts on Server management?
what the server hosting? php, ror, asp.net?
-
simple sessions question
i'm trying to pass a variable to a page which is stored in a session var then echo'd out... simple? i thought so but it won't work at all $_SESSION['property'] = $_GET['id']; echo "session id:" .$_SESSION['property']; nothing comes out if i Print_r ($_SESSION); i get Array ( [property] => 607504 ) so something is there, i just can't get to it. any ideas?
-
get variables confusion
sorry this is my calculation script <?php $page = 'leasecalculator'; echo "<h2>Lease Calculator</h2>"; //either print out the calculation (if amount supplied) or print out form $amt = 0; //check if given a number if ( isset($_GET['amt']) && (!empty($_GET['amt'])) && (is_numeric($_GET['amt']) ) ){ //given a number, print lease calculation $amt = round( $_GET['amt'], 2);//only store with max 2 decimal places, but don't insert commas before calculation //standard rates $oldcustomer_3yr_rate = 35.62; //payment profile 1 + 35 $oldcustomer_5yr_rate = 25.02; //payment profile 1 + 59 $newcustomer_3yr_rate = 37.98; //payment profile 1 + 35 $newcustomer_5yr_rate = 27.66; //payment profile 1 + 59 //calculate our results $old_customer_3yr_monthly = round( ($amt * $oldcustomer_3yr_rate / 1000), 2); $old_customer_3yr_weekly = round( ($old_customer_3yr_monthly * 12 / 52), 2); $old_customer_5yr_monthly = round( ($amt * $oldcustomer_5yr_rate / 1000), 2); $old_customer_5yr_weekly = round( ($old_customer_5yr_monthly * 12 / 52), 2); $new_customer_3yr_monthly = round( ($amt * $newcustomer_3yr_rate / 1000), 2); $new_customer_3yr_weekly = round( ($new_customer_3yr_monthly * 12 / 52), 2); $new_customer_5yr_monthly = round( ($amt * $newcustomer_5yr_rate / 1000), 2); $new_customer_5yr_weekly = round( ($new_customer_5yr_monthly * 12 / 52), 2); //now format everything nicely $amt = number_format($amt, 2); $old_customer_3yr_monthly = number_format($old_customer_3yr_monthly, 2); $old_customer_3yr_weekly = number_format($old_customer_3yr_weekly, 2); $old_customer_5yr_monthly = number_format($old_customer_5yr_monthly, 2); $old_customer_5yr_weekly = number_format($old_customer_5yr_weekly, 2); $new_customer_3yr_monthly = number_format($new_customer_3yr_monthly, 2); $new_customer_3yr_weekly = number_format($new_customer_3yr_weekly, 2); $new_customer_5yr_monthly = number_format($new_customer_5yr_monthly, 2); $new_customer_5yr_weekly = number_format($new_customer_5yr_weekly, 2); ?> <p>The total lease amount you requested was <strong>£<?=$amt?></strong></p> <p>Companies trading in excess of 3 years</p> <table> <tr><th>Term</th><th>Payment<br />Profile</th><th>Monthly<br />Payments</th><th>Weekly<br />Equivalent</th></tr> <tr><td>3 Years</td><td>1 + 35</td><td>£<?=$old_customer_3yr_monthly?></td><td>£<?=$old_customer_3yr_weekly?></td></tr> <tr><td>5 Years</td><td>1 + 59</td><td>£<?=$old_customer_5yr_monthly?></td><td>£<?=$old_customer_5yr_weekly?></td></tr> </table> <p>New Start Businesses trading less than 3 years</p> <table> <tr><th>Term</th><th>Payment<br />Profile</th><th>Monthly<br />Payments</th><th>Weekly<br />Equivalent</th></tr> <tr><td>3 Years</td><td>1 + 35</td><td>£<?=$new_customer_3yr_monthly?></td><td>£<?=$new_customer_3yr_weekly?></td></tr> <tr><td>5 Years</td><td>1 + 59</td><td>£<?=$new_customer_5yr_monthly?></td><td>£<?=$new_customer_5yr_weekly?></td></tr> </table> <p>Payments are calculated based on Direct Debit. All prices are subject to VAT</p> <p><a href="index.php?page=leasecalculator">Calculate another Lease Cost</a></p> <?php } else { ?> <p>Please enter the cost in pounds of the item you wish to purchase</p> <form name="leasecalcform" method="get" action="index.php?page=leasecalculator"> <fieldset id="leasing"> <ul> <li class="text"> <label for="cost">cost</label> </li> <li class="input-box"> <input type="text" name="amt" /> </li> <li class="submit-box"> <input type="submit" class="submit" alt="calculate" /> <input name="calculate" type="hidden" /> </li> </ul> </fieldset> </form> <? } ?> and this is the index <?php $page = $_GET['page']; include "includes/header.php"; ?> <? if ($page=='home') { include "includes/scrolling.php"; } ?> <div id="sidebar"> <h2>wishlist</h2> <div id="shopping_cart"> <table id="shopping_cart_items"> <tr> <th>Items</th> <th>Description</th> <th>Price</th> <th></th> </tr> </table> <div id="shopping_cart_totalprice"></div> </div> </div> <!-- end sidebar --> <? if ($page=='home'){ echo "<div class=\"clearfix\" id=\"content-home\">\n"; } else { echo "<div class=\"clearfix\" id=\"content\">\n"; } require_once ("pages/" .$page .".php"); ?> </div><!-- end content --> </div><!-- end content-wrapper --> </div> <!-- end container --> <?php include('includes/footer.php');?> all of my page files are in a folder /pages, does that help?
-
get variables confusion
i am using a template to call my pages (using php require) eg: index.php?pages=home now i have a calculation form which $_GET a variable and prints out the results. i have the script working in a static site, however when i try enter the calculation form i get this url index.php?pages=home?calc=600 now that doesn't work, i need to get this index.php?pages=home&calc=600 how do i go about getting that to work?
-
xpath search query
cheers man, i'm sure i tried the 2nd example you gave, obviously it wasn't the same. thanks mate:)
-
xpath search query
hi guys, i'm tring to search through a XML doc with SIMPLEXML, but i mus have my syntax wrong $prop = $xml->xpath('/root/property[id=$id]'); foreach { $prop as &list) { //do something } i know that this works is i enter say 61245 instead of $id. what is the correct syntax to stick a variable into this query? i have tried multiple variation but i'm stumped?
-
pagination problems
anyone have any ideas?
-
pagination problems
hi guys, i have a xml doc which i'm parsing with php and trying to split into different pages. i can't seem to pass the results of the array further than page 1, all it show is m result for page 1 over an over but for the correct amont of results the example i followed didn't use sessions and i haven't changed the pagintion.class.php does anone know where i'm going wrong, mus be in the array somewhere <?php // Include the pagination class include 'pagination.class.php'; // Create the pagination object $pagination = new pagination; // some example data // set xpath search $prop = $xml->xpath('/root/property[province="Alicante"]'); // initiate the search and display list foreach ( $prop as $list) { $propertyid = $list->id ; $date = $list->date; $ref = $list->ref; $price = $list->price; $pricefreq = $list->price_freq; $type = $list->type->en; $town = $list->town; $provinceName = $list->province; $location = $list->location_detail; $beds = $list->beds; $baths = $list->baths; $pool = $list->pool; $description = $list->desc->en->asXML(); $images = $list->images->image; // search and set the primary image counter for use $count = 0; while ($list->images->image[$count]->primary != 1) { $count++; } // setup image thumb $image = substr($list->images->image[$count]->url, 0, -9); $properties[$cur_prop] = array ( 'propertyid' => $propertyid, 'date' => $date, 'ref' => $ref, 'price' => $price, 'pricefreq' => $price_freq, 'type' => $type, 'town' => $town, 'provinceName' => $province, 'location' => $location_detail, 'beds' => $beds, 'baths' => $baths, 'pool' => $pool, 'description' => $description, 'image' => $image, ); $cur_prop++; } //foreach ($properties as $key=> $value) //{ // echo $key."-".$value.""; //} // If we have an array with items if (count($properties)) { // Parse through the pagination class $propertiesPages = $pagination->generate($properties, 6); // If we have items if (count($propertiesPages) != 0) { // Create the page numbers echo $pageNumbers = '<div class="numbers">'.$pagination->links().'</div>'; // Loop through all the items in the array $current = 1; foreach ($propertiesPages as $propertiesArray) { // Show the information about the item echo "<div class=\"property-box\"> \n"; echo "<h3>price: " . $properties[$current]['beds'] . " bedroom " .$properties[$current]['type'] ." based in " . $properties[$currrent]['town'] ."</h3>\n"; $image_thumb = $properties[$current]['image']; echo "<img src=\" " . $image_thumb . "med.jpg\" class=\"property-image\" alt=\"\" />\n" ; echo "<h4>€" . $properties[$current]['price'] . "</h4>\n"; // remove chars from description $description = substr($properties[$current]['description'], 0, 310); echo "<p> " . nl2br($description) . " ......</p>\n" ; echo "</div> \n"; $current++; //echo '<p><b>'.$properties['propertyid'].'</b> £'.$properties['price'].'</p>'; } // print out the page numbers beneath the results echo $pageNumbers; } } ?>