Jump to content


  • Content Count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About tarquino

  • Rank
  1. thanks for the advice. i am getting a grip on jquery and ajax at the moment.
  2. the reason is i am interested in learning a bit of ajax, i followed a few tutorials and while it queries using a database, i wanted to know what the process is (and know whether) arrays can be queried too.
  3. I want to be able to check whether values exist in the php array without having to click the submit button to do those checks using jquery/ajax. when users enter an abbreviation in the text field want to be able to show that the brand exists (either vw or tyta) or not (as they type in the input box) and show the results in the carnamestatus div. I was following a tutorial from youtube, however it queried against a mysql database. I was wondering if this is possible using php arrays instead of mysql? I would be grateful if you could pick any faults in the code. The jquery is in the head section. the rest of the code is as follows: <?php $car = array() $car["vw"] = array( "name" => "volkswagen"); $car["tyta"] = array( "name => "toyota"); ?> the html code is as follows: <label for="carname">Car Code:</label> <input type="text" onblur="checkcar()" value="" id="carname" /> <div id="carnamestatus"></div> the checkcar() function checkcar(){ var u = _("carname").value; if(u != ""){ _("carname").innerHTML = 'checking ...'; var B = new XMLHttpRequest(); B.open("POST","check.php",true); / B.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); B.onreadystatechange = function() { if(B.readyState==4 && B.status== 200) { _("carnamestatus").innerHTML = B.responseText; } } var v = "carnamecheck="+u; B.send(v); } } </script>
  4. no i did not change anything. everything is as it is. for some reason the links i transform to lowercase, do not match the array. This is what this script does. it checks whether the cake is valid. if the cake is valid it displays the cake name, however if the cake is invalid, it says it is. to make it easier to troubleshoot, i decided to use the raw link instead of the htaccess pretty links. //cake.php <?php $cakesmade = array(); $cakesmade = array( "kate" => array( "cake" => array( "cakeingredients" => "egg, flour"), "Lovely Chocolate Cake" => array( "cakeingredients" => "chocolate, eggs, flour"), "amazing cake" => array( "cakeingredients" => "lemons, flour") ), ); if(isset($_GET["id"])) { $id = $_GET["id"]; // check if user valid if(isset($cakesmade[$id])) { $username = $cakesmade[$id]; } else { echo "<h1>user does not exist</h1>"; } } if(isset($_GET["product"])) { $products = $_GET["product"]; if(isset($cakesmade[$id][$products])) { $product = $cakesmade[$id]; } else { echo "<h1>cake is invalid</h1>"; exit; } } ?> <?php if(isset($username)) { ?> <h1>User: <?php echo $id; ?></h1> <h2>Product: <?php $cakesmade = array_change_key_case($cakesmade, CASE_LOWER); foreach($cakesmade as $id => $cake) foreach($cake as $bakedcake => $description) { $bakedcake = strtolower($bakedcake); $str = "cake.php?id={$id}&product={$bakedcake}"; $lower = strtolower($str); $url = str_replace(' ', '-', $lower); echo "<a href='{$url}'>" . $url . "</a><br>"; } ?></h2> <?php } ?> if i delete the strtolower and str_replace part of the code and use simply $str it works fine. the problem only occurs when i try to lowercase url is used, it says the cake is invalid (maybe due to being case sensitive). hope this makes it easier to understand what i am trying to do.
  5. hi, i want to make all urls lowercased(and transform spaces with a hyphen) so they are uniformed throughout, all lowercased urls. the data has always remained the same, not that i have unknowingly changed. i am using htaccess to make clean urls, currently it does make clean urls, although it does not match the array (which happens to have spaces and capital letters). for example: Below this it does not work: it does not go to the intended page. ie. the values of the url are not matched to those of the array example.com/user/kate/baked/lovely-chocolate-cake i want my urls to look like the above with hyphens and lowercase. example.com/user/kate/baked/Lovely-Chocolate-Cake --- This line below it works: this works and goes to te intended page. ie. the values of the url match those of the array, but its not how i want the url to look like (%20 and capitalized letters) example.com/user/kate/baked/Lovely%20Chocolate%20Cake any ideas on how to try to solve the problem. the colouring on the code isnt working, so ammended that.
  6. hi i managed to do that, although i still have the same problem i was trying to solve in the first place. the thing is that whenever i gather those values to direct to the specific product page, if the values are in upper case and the url gets lowercased, then it does not gather the detail page for that specific product. i am thinking is there a way to completely make the url completely case insensitive so that when one clicks the url: example.com/lovely-chocolate-cakes it automatically displays the values from the array: Lovely%20Chocolate%20Cakes while not replacing the url. i know this can be done manually for each url, is there a more simpler way to do this for all urls? your input is welcome.
  7. thanks cyberbot. will this work when one uses the array as the name of the product (ie.Lovely Chocolate Cake in the details page) and url rewrites to convert spaces to a -.and lowercase.(ie. example.com/user/$id/baked/$bakedcake) using htaccess? or will i come accross problems?
  8. thanks strider64, i did try that before, however that did not work out successfully. the keys in the array remained the same and the only thing it changed was the url. (i was using url rewrite in htaccess), when would click it, it would not go to the intended page.
  9. i am trying to convert all keys to lowercase and i was wondering if it is really possible to do using array_map to convert all keys to lowercase or using array_reduce. what i am trying to do is to gather details from keys and display it on the page as links that redirect to the details page, i managed to convert it into lowercase, however it did not gather the records mainly due to keys being capitalised and me trying to gather those records using lowercase. to put things into perspective here is the code: <?php $cakesmade = array(); $cakesmade = array( "kate" => array( "cake" => array( "cakeingredients" => "egg, flour"), "Lovely Chocolate Cake" => array( "cakeingredients" => "chocolate, eggs, flour"), "amazing cake" => array( "cakeingredients" => "lemons, flour") ), ); ?> //links <?php foreach($cakesmade as $id => $donecake) foreach($donecake as $bakedcake => $description) { echo "<a href='/user/$id/baked/$bakedcake'>$bakedcake</a>" } ?>
  10. tarquino

    url question

    how do they manage to do so? do they use htaccess redirects and the like? or is this down to something else?
  11. tarquino

    url question

    i am trying to understand, how a site like ebay can display content and be case insensitive? for example: The original url: http://www.ebay.co.uk/itm/Toshiba-Satellite-C50-AMD-E-Series-1-4GHz-Dual-Core-15-6-Inch-500GB-2GB-Laptop/151458954958 the above works fine and go to the intended page. user editing the browser url into lowercase : http://www.ebay.co.uk/itm/toshiba-satellite-c50-amd-e-series-1-4ghz-dual-core-15-6-inch-500gb-2GB-laptop/151458954958 random uppercase and lowercase. http://www.ebay.co.uk/itm/toshiba-sateLLite-c50-aMd-e-sERIes-1-4ghz-dual-core-15-6-inch-500gb-2GB-laptop/151458954958 both the urls above also work fine and go to the intended page. How can such a thing can work? it is supposed to throw an error such as page not found and the like? any thoughts welcome.
  12. i have the php (linkchange.php) which translates the array into lowercase and with a hypen, however i am unable to get it working properly. the code is the following: the code in the htaccess RewriteRule ^/user/.*[A-Z\ ] linkchange.php?l=%{REQUEST_URI} [L] RewriteRule ^/user/([a-z]+)/baked/([a-z.*0-9_-]+)$ cakes.php?id=$1&baked=$2 for the cakes.php <?php $cakesmade = array(); $cakesmade = array( "kate" => array( "cake" => array( "cakeingredients" => "egg, flour"), "Lovely Chocolate Cake" => array( "cakeingredients" => "chocolate, eggs, flour"), "amazing cake" => array( "cakeingredients" => "lemons, flour") ), ); ?> <?php foreach($cakesmade as $id => $donecake) foreach($donecake as $bakedcake => $description) { echo "<a href='user/$id/baked/{$bakedcake}'>{$bakedcake}</a><br>"; } ?> // this part should appear once the user and variable are set in the url The selected cake is: <?php if(isset($bakedcake)) { echo $bakedcake; } else { echo "not set"; } ?> by <?php if(isset($id)) { echo $id; } else { echo "not set"; } ?>. for the linkchange.php <? $link = $_GET['l']; $newlink = strtr($link," ABCDEFGHIJKLMNOPQRSTUVWXYZ","-abcdefghijklmnopqrstuvwxyz"); header("Location: http://www.example.com". $newlink,TRUE,301); exit; ?> the linkchange.php is the code which makes the substitution into lowercase and hyphen. are the above codes formatted correctly? and where exactly will i need to make the changes? please help i am eager to learn this.
  13. so to this code if i add \%20 would it replace the whitespace with a - or do i need to do something else? RewriteRule ^/user/([a-z]+)/cake/([a-z\%20A-Z0-9-_]+)$ /cakes.php?userid=$1&cakebaked=$2
  14. thanks requinix for explaining. i am new to the rewriterules hence i did not know what it really meant. i put the code together after reading for the various functions and trying to implement it for my instance. do you know some place which would help me learn the htaccess code better? i am really interested in learning exactly what is in between the parenthesis. if you could point me in the right direction or provide me what it means that would be helpful.
  15. hello everyone. could you advise me on the structure of my code to check if it is correct: RewriteRule ^/user/([a-z]+)/cake/([a-z\ .*A-Zx0-9-_]+)$ /cakes.php?userid=$1&cakebaked=$2 what i am trying to do is to add a - instead of a whitespace which appears in the url as %20.
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.