Jump to content

avvllvva

Members
  • Posts

    140
  • Joined

  • Last visited

    Never

Everything posted by avvllvva

  1. Finally I got the solution from php.net, here is the one <?php function addLinks($string) { $string = preg_replace("/(^|[^=\"\/])\b((\w+:\/\/|www\.)[^\s<]+)". "((\W+|\b)([\s<]|$))/i", "$1<a href=\"$2\" target='_blank'>$2</a>$4", $string); return preg_replace("/href=\"www/i", "href=\"http://www", $string); } echo addLinks($str); ?> Regular expression did the job, anyway I have to study more on that.
  2. Thank you for your help. It outputs only a word "yahoo" but it is hyper linked. ie; ---------------------------------------------------------------------------------------------- yahoo ---------------------------------------------------------------------------------------------- but i'm looking for this ---------------------------------------------------------------------------------------------- Plain text plain text plain textplain textplain textplain text plain text plain text plain text plain text. Plain text plain text plain text plain text plain text plain text plain www.google.com/analytics text plain text plain text. Plain text plain text plain text plain text plain text plain text plain text plain text plain text plain text http://yahoo.com plain text plain text plain text plain text plain text plain text plain text plain text plain text plain text plain text. Plain text plain text plain text plain text https://www.example.com plain text plain text plain text plain text. ----------------------------------------------------------------------------------------------
  3. Hi, Here I have a plain-text string, it may contain one or more URLs inside it. I want to make all of them into hyperlinks. This Example explain more :- <?php $str = " Plain text plain text plain textplain textplain textplain text plain text plain text plain text plain text. Plain text plain text plain text plain text plain text plain text plain www.google.com/analytics text plain text plain text. Plain text plain text plain text plain text plain text plain text plain text plain text plain text plain text http://yahoo.com plain text plain text plain text plain text plain text plain text plain text plain text plain text plain text plain text. Plain text plain text plain text plain text https://www.example.com plain text plain text plain text plain text. "; ?> In the above string you can see 3 URLs, say 1. www.google.com/analytics 2. http://yahoo.com 3. https://www.example.com (I think, i've covered all possible formats of an URL in the above three.) So whenever echoing this string I want to make these URLs into hyperlinks. ie; appending anchor tag at the begining. Output like this: ---------------------------------------------------------------------------------------------- Plain text plain text plain textplain textplain textplain text plain text plain text plain text plain text. Plain text plain text plain text plain text plain text plain text plain www.google.com/analytics text plain text plain text. Plain text plain text plain text plain text plain text plain text plain text plain text plain text plain text http://yahoo.com plain text plain text plain text plain text plain text plain text plain text plain text plain text plain text plain text. Plain text plain text plain text plain text https://www.example.com plain text plain text plain text plain text. ---------------------------------------------------------------------------------------------- Can anybody help me to acheving this?
  4. suppose if your server is on PST, you haven't do anything, it will pick up server time by default. I think NOW() returns time on the server.
  5. try proper string quotes $result = mysql_query("UPDATE _0_sermon_data_file SET ".$column[$n]." = '".$value[$n]."' WHERE ".column2[$n2]." = '".$value2[$n2]."'")
  6. $sql="INSERT INTO test11 (name, ip, date) VALUES('$_POST[name]','$_SERVER[REMOTE_ADDR]',NOW())";
  7. This may give result as u wish, SELECT COUNT(*) as count,v.referral, (SELECT count(*) as count2 FROM visitors WHERE conversion = 1 AND referral = v.referral) as num_of_conversions FROM visitors v GROUP BY v.referral ORDER BY count DESC <?php while($row = mysql_fetch_array($select)) { $percentage = floor(($row['num_of_conversions']/$row['count'])*100); $table .= '<tr><td>'.substr($row['referral'],0,35).'</td><td>'.$row['count'].'</td><td>'.$percentage.'%</td></tr>'; } ?>
  8. Your query seems to be okay. then where u r facing problem ?? whats ur output ?
  9. what is your query result... is it grouping ?? I think u want to group by tid with highest time .. then wat abut this group by t2.tid order by t2.time desc
  10. For the current date-time u can try the Mysql function NOW(), and make the field type into "DATETIME". For checkbox validation use some javascript, and give some default value to it so that u can insert that value in db if (!document.form.checkboxname.checked)
  11. Yes I have the product id, and your query is working perfectly. Thank you very much kickstart. I've also posted a topic in php forum(http://www.phpfreaks.com/forums/index.php/topic,271418.0.html), the practical use of this.
  12. Finally it gets solved. Credit belongs to Kickstart (http://www.phpfreaks.com/forums/index.php/topic,271779.0.html). Final code is <?php // tbl_category -> category details // tbl_map_product_category -> mapping of product table with category table (2 fields category_id & product_id) // $pro_id -> variable that contains the id of product to be edit $qrystr = "SELECT c.*, mpc.category_id as category_id FROM tbl_category c LEFT OUTER JOIN tbl_map_product_category mpc ON c.id = mpc.category_id AND mpc.category_id = '$pro_id' "; $qry = mysql_query($qrystr); echo '<select multiple="multiple" >'; // dynamic dropdown for category with multiple selection while($row = mysql_fetch_array($qry)) { if($row['id']==$row['category_id']) // comparing current category id with existing category id in the mapping table $selection = 'selected="selected"'; else $selection = ''; echo '<option '.$selection.' >'.$row['title'].'</option>'; } echo '</select>'; ?>
  13. Hi all, Please look at following details, ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Table structure 1.tbl_product (stores product details) product_id, title 2.tbl_category (stores category details) category_id, title 3.tbl_map_product_category (stores product-category mapping. Here sometimes there would be multiple entry of same product['product_id']. ie; one product may have multiple categories ) product_id, category_id Hope following example will give u a clear picture, Example tbl_product id title 1 product_1 2 product_2 tbl_category id title 1 category_1 2 category_2 3 category_3 4 category_4 tbl_map_product_category product_id Category_id 1 2 2 1 2 2 2 4 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Now I can explain my requirement, I want to get all categories from tbl_category, but each category_id should be check with tbl_map_product_category table against a particular product.(it doesn't means getting only the categories for that particular product, but I needs to identify these categories of that particular product along with complete categories). eg:- For product_id - 2 I needs to display all categories (category 1,2,3,4), among these categories I need to identify the categories 1,2,4 (which are belongs to product_id 2 ) How can do it in a single mysql query ? This is the query i've tried - SELECT c.*, (SELECT category_id FROM tbl_map_product_category WHERE product_id='var_particular_product_id') as category_map_id FROM tbl_category c From this query result, I will get the complete categories and I can easily identify the categories against a particular product by simply comparing c.id = category_map_id case 1 : for product_id - 1 (replacing var_particular_product_id with 1 in the query ) This is working fine. It produces the complete category list and I can able to idetify the category belongs to product_id 1. case 2 : for product_id - 2 (replacing var_particular_product_id with 2 in the query ) This giving empty result. Because the sub query returns multiple rows (since product_id -> 2 have three categories) So for case 2, how can I modify my query to getting the exact result? Please help me..... if u need more explanation, plz let me know.... thanks
  14. Hi Cags, thanks for your reply. But.... what u explained is not my requirement, its entriely different, you might be misunderstood. thnx again for ur response. Anyway I will try to explain it more clearer. There is only one dropdown( but multiple selection is enabled). Here I have 2 actions Action 1 : Add a product Here along with product details , it saves the category choosen from dropdown (one or more categories). Action 2 : Edit a product Here , offcourse.. i have to display the dropdown for changing the category (i'm using the same dropdown which is used in adding page). And at this time I have to show them the previously selected categories. so i've put something like default selection for these selected categories inside the dropdown, so he can identify the previously selected categories. For this I have tried dropdown property -'selected="selected"'. This is my basic need. But here I'm used a single mysql query for doing it, datas from category table and datas from category-product mapping table (for previously selected categories for that product) I hope this will give u a clear idea. If there any confusion with my db tables & query, plz let me know , I can explain. But I'm so wondering about nobody before gone through this type of requirement ??? is this the first time ???? But How JOOMLA handled this situation ??? I hope somebody can help me........
  15. Okay then, I think nobody understood my problem.... maybe of my english. So for now........ can anybody tell, how to do a simple multiple dropdown selection dynamically ??
  16. I'm extremely sorry for my mistake.. It was a typo, instead of product table it is actually the category table. So please look at new code, discard the first script. Now its also more readable <?php // tbl_category -> category details // tbl_map_product_category -> mapping of product table with category table (2 fields category_id & product_id) // $pro_id -> variable that contains the id of product to be edit $qrystr = "SELECT c.*, (SELECT category_id FROM tbl_map_product_category WHERE product_id='$pro_id') as category_id FROM tbl_category c "; $qry = mysql_query($qrystr); echo '<select multiple="multiple" >'; // dynamic dropdown for category with multiple selection while($row = mysql_fetch_array($qry)) { if($row['id']==$row['category_id']) // comparing current category id with existing category id in the mapping table $selection = 'selected="selected"'; else $selection = ''; echo '<option '.$selection.' >'.$row['title'].'</option>'; } echo '</select>'; ?> Usually how, you guys are handling this situation?, please let me know....
  17. If u don't understood what I meant, simply the same in joomla administration. At there u can see different multiple-selection-dropdowns(eg:-list of menus), and at the time of editions previously selected items are automatically selected. This is exactly I'm looking for.... please help.
  18. In my product adding page, there is one dropdown for adding categories (one product may have multiple categories so I made it multiple selection). I'm using same page for editing, so at this time I have to make default selection for the categories which were chosen at the time of add. For achieving this i tried following code <?php // tbl_products -> product details // tbl_map_product_category -> mapping of product table with category table (2 fields category_id & product_id) // $pro_id -> variable that contains the id of product to be edit $qrystr = "SELECT p.*, (SELECT category_id FROM tbl_map_product_category WHERE product_id='$pro_id') as p_id FROM tbl_products p "; $qry = mysql_query($qrystr); ?> <select multiple="multiple" > <?php while($row = mysql_fetch_array($qry)) {?> <option <?php if($row['id']==$row['p_id']){?> selected="selected"<?php } ?> > <?php echo $row['title'] ?> </option> <?php } ?> </select> and this is working only when we chose sinlge category, for multiple categories it fails, because at that time the subquery[(SELECT category_id FROM tbl_map_product_category WHERE product_id='$pro_id') as p_id] returns multiple rows. Is there any other method to achieve this OR how to modify this code ?? Thanks in advance for any help.
  19. Is it better to keep changing the TITLE of website weekly ? Can anybody explain how the crawling programs treat the website's title? How long it will take to reflect ? Suppose I'm going to change my website's titles every week with different keywords, so the crawlers would cache the previous titles or it simply look for existing title? can anybody explain the basiscs of this ? please..
  20. Thank you for your info. As you mentioned, sub-folders also won't reflect on results right?? what I planned was make some folders & name with keywords and that will redirect to main site. So this also will not workout, am I correct?
  21. If I'm creating sub-domains with some keywords and that pointing to original site, this will give more rank to original website? eg :- www.example.com www.keyword1.example.com www.keyword2.example.com www.keyword3.example.com www.keyword4.example.com ... ... ... www.keyword-n.example.com Any ideas ?
  22. Thank you guys, anyhow I have to use some anti-spam technique for this ajax form too. I have another query. One of the common spam check is captcha image, so that image couldn't be readable by spamers. All other form elements they can trap. Suppose if I'm using a div tag and which will replace the captcah image and that contains the session string and that plays the role of captcha image.(why I'm planning like this , some server doesn't have GD support) Is this hackable ?
  23. Hi all, I am going to creating a Business related website, for this I need to show all free Feeds/Services/content (eg: stock exchange rate, currency rate, gold price, oil price, some other business related latest news, etc.. ). If anybody knows some FREE content providers, which are categorized as mentioned above, plz let me know. It will be more helpful, if those feeds are fully customizable. Thanks in advance.
×
×
  • 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.