Jump to content

markjohnson

Members
  • Posts

    14
  • Joined

  • Last visited

    Never

Everything posted by markjohnson

  1. Hi, I have a SQL statement: $sql='SELECT PROPID, ADDRESS_1, ADDRESS_2, TOWN, POSTCODE1, POSTCODE2, BEDROOMS, BATHROOMS, RECEPTIONS, PRICE, TRANS_TYPE_ID FROM properties WHERE TRANS_TYPE_ID=2 AND BEDROOMS =3 AND PROP_SUB_ID IN (1,2,3,4,5,6,21,22,23,24,27,30,95,128,131) ORDER BY DATE_ADDED, PROPID DESC'; I want to be able to get the fields and their corresponding values as such: $result['TRANS_TYPE_ID']=2; $result['BEDROOMS']=3; And then capture the values in PROB_SUB_IN IN(*) How can I do this? Any help will be greatly appreciated. Thanks
  2. If I have a string as such: $title = "Product Title £143.99" How can I search the string for £ and then all the subsequent numbers, and then enclose them with a tag? I was thinking of using preg match, and enclosing the result within whatever tag. Any ideas? Thanks
  3. For further info on the problem: This is what index.php does right in the beginning: $uri = preg_replace("/\/+/", "/", substr($_SERVER["REQUEST_URI"], strlen($cms_path))); if(substr($uri, 0, 1) == "/") $uri = substr($uri, 1); if(strpos($uri, "?")) $uri = substr($uri, 0, strpos($uri, "?")); if ($uri=="") $uri="/"; $path=explode("/",$uri); It just takes a url like site.com/categoryA/categoryB/product-name-id-1234 and breaks it down like: $path[0]=categoryA $path[1]=categoryB $path[2]=product-name-id-1234 OR, sometimes: site.com/categoryA/product-name-id-5678 which is broken down as: $path[0]=categoryA $path[1]=product-name-id-5678 The php script then checks $path[1] for a pattern like this: 'id-1234' If it finds it, it runs the query for displaying product details. If the pattern doesn't match, it simply lists all the products in categoryA. The problem that I am encountering now is that when it is given this URL: site.com/categoryA/product-name-id-5678 It is showing the product details page, which is fine, but it is also running Product list query several times, raising CPU usage to 100%. I think it is quite obvious, looking at the ReWriteLog that it is due to internal redirects to index.php And if I am right, I need to know how to stop internal redirection. Thanks
  4. *bump* For further clarification, here are the two queries, only one of which should run: // This function looks at the uri "/whatever-product-name-id-2039" and extracts the id at the end: 2039 product_id($uri[1]); // Run only if end of uri is a number if (product_id($uri[1])) { //this runs fine, which it should. $qryDisplayProduct = "SELECT * FROM content WHERE id = ".content_id($path[1]); } else { //for some reason, mysql shows several processes for this query which should NOT run. Not only it runs but several instances clogging up the CPU. $qryListProducts = "SELECT * FROM content ORDER BY `date` DESC"; } In light of the above from ReWriteLog, am I right in at least assuming that this is due to internal redirects? What am I doing wrong?
  5. Hi, I have the following in my .htaccess file: Code: php_flag magic_quotes_gpc off Options +FollowSymlinks RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-s RewriteRule ^admin(.*)$ admin/index.php [L] RewriteCond %{REQUEST_FILENAME} !-s RewriteCond %{REQUEST_FILENAME} !-d RewriteRule .* index.php [L,QSA] The idea is to fetch the entire URL into index.php, e.g. http://site.com/page1/page2/3928 index.php would then explode the uri 'page1/page2/3928' into three parts page1/page2 list all the products (i.e. if $uri[2] is not set, then list all products). This works fine. page1/page2/3928 is supposed to present product detail, which it does, but for some reason it also runs the query for product listing (page1/page2) not only once but several times. When I click on page1/page2/3928, mysqyl shows me several instances of product listing query which shouldn't be running at all. My guess is that /page1/page2/3928 is also internally redirecting about 10 times to /page1 as well. The rewrite log file show many instances of the following: Code: 127.0.0.1 - - [25/Jan/2010:02:44:58 +0000] [site/sid#1656600][rid#28e14c8/initial] (2) [perdir C:/xampp/htdocs/site/public_html/] trying to replace prefix C:/xampp/htdocs/site/public_html/ with / 127.0.0.1 - - [25/Jan/2010:02:44:58 +0000] [site/sid#1656600][rid#28e14c8/initial] (1) [perdir C:/xampp/htdocs/site/public_html/] internal redirect with /index.php [iNTERNAL REDIRECT] 127.0.0.1 - - [25/Jan/2010:02:44:58 +0000] [site/sid#1656600][rid#2c53088/initial/redir#1] (3) [perdir C:/xampp/htdocs/site/public_html/] strip per-dir prefix: C:/xampp/htdocs/site/public_html/index.php -> index.php 127.0.0.1 - - [25/Jan/2010:02:44:58 +0000] [site/sid#1656600][rid#2c53088/initial/redir#1] (3) [perdir C:/xampp/htdocs/site/public_html/] applying pattern '(.*)' to uri 'index.php' 127.0.0.1 - - [25/Jan/2010:02:44:58 +0000] [site/sid#1656600][rid#2c53088/initial/redir#1] (3) [perdir C:/xampp/htdocs/site/public_html/] strip per-dir prefix: C:/xampp/htdocs/site/public_html/index.php -> index.php 127.0.0.1 - - [25/Jan/2010:02:44:58 +0000] [site/sid#1656600][rid#2c53088/initial/redir#1] (3) [perdir C:/xampp/htdocs/site/public_html/] applying pattern '^(.+)$' to uri 'index.php' 127.0.0.1 - - [25/Jan/2010:02:44:58 +0000] [site/sid#1656600][rid#2c53088/initial/redir#1] (1) [perdir C:/xampp/htdocs/site/public_html/] pass through C:/xampp/htdocs/site/public_html/index.php Any help will be appreciated. Many thanks!
  6. Hi, I have: $string="this-is-my-uri--8271"; How can extract just the last group of numbers at the end, i.e. 8271? Thanks
  7. Thanks, mate. But this line: preg_match('#^(\d+){([^}]+)}$#', $string, $matches)); gives parsing error.
  8. Ok, so here it goes: I have a variable: $var = ":12:3{this is a test}:5:8{this is another test}:" Everything between : : is a separate value, which I can easily extract in an array: $value=explode(":",$var); I then get: $value[0]=12 $value[1]=3{this is a test} $value[2]=5 $value[3]=8{this is another test} RE values like $value[1] and $value[3] with brackets, I would like to extract the number before the bracket '{' in one variable, and then all the text between the brackets {} in another variable, which should result in something like this: $key=3 $keytext=this is a test How can I achieve this? I am sure this one will be dead simple for PHP experts, so many thanks in advance!
  9. Yes, it has a unique id. the fields are as follows: id (primary) group_id display_value option_number option_price
  10. Is there a way I can detect change in a variable value? This is what I want to achieve: I have a normal select query that lists records with their group_ids... like so... group_id --- number 333 333 333 333 345 345 345 345 The number field at the moment is null, and I would like to update that field in each of these records, starting with 1, then 2 and so on... And as soon as group_id changes, from 333 to 345, I would like the numbering to restart. At the moment I have this: <?php $x=1; do { ?> <tr> <td><?php echo $row_rsOptionGroups['id']; ?></td> <td><?php echo $row_rsOptionGroups['group_id']; ?></td> <td><?php echo $row_rsOptionGroups['display_value']; ?></td> <td><? $g_id=$row_rsOptionGroups['group_id']; $y=$g_id; if ($y != $row_rsOptionGroups['group_id']) { $x=1; $g_id=$row_rsOptionGroups['group_id']; } echo $x; $x=$x+1; ?></td> <td><?php echo $row_rsOptionGroups['option_price']; ?></td> </tr> <?php } while ($row_rsOptionGroups = mysql_fetch_assoc($rsOptionGroups)); ?> And it obviously doesn't work. Is there a way I can do: If ($row_rsOptionGroups['group_id'] changes from what it previously was) { $x=1; } Many Thanks
×
×
  • 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.