Jump to content

Darkwoods

Members
  • Posts

    88
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

Darkwoods's Achievements

Member

Member (2/5)

0

Reputation

1

Community Answers

  1. Yes this is how I managed to do it but not so sure if it looks good.. but it works $text = 'cat1=hello,world|cat2=one,two|cat3=value1,value2'; $arr= explode('|', $text); foreach($arr as $value) { $key = rtrim(stristr($value, '=', true), '='); $values = ltrim(stristr($value, '='), '='); $values = explode(',', $values); $array[$key] = $values; } print_r($array);
  2. Im trying to parse/convert this string using delimiters = , | $text = 'cat1=hello,world|cat2=one,two|cat3=value1,value2'; Into an array like this: Array( [cat1] => Array ( [0] => hello [1] => world ) [cat2] => Array ( [0] => one [1] => two ) [cat3] => Array ( [0] => value1 [1] => value2 ) ) any suggestion on how to achieve this ?
  3. hey thanks I know it looks awful that because I am total noob I'm still having problem with displaying the name of the category please if anybody can help me out with it would be great I have been stuck with this for a while now.. <?PHP $result = mysql_query("SELECT a.*, b.c_id, b.c_title FROM properties AS a JOIN cat AS b ON SUBSTRING_INDEX(a.pr_category, ',', 1) = b.c_id",$connect); while($row = mysql_fetch_assoc($result)) { $cat_name = $row["c_title"]; $cat_id = $row["c_id"]; $categories = explode(',', $row['pr_category']); /*test*/ foreach ($categories as $category) { list($cat_id, $cat_name) = explode('=', $category); echo '' . $cat_id . ':' . $cat_name . ''; } } ?>
  4. I cant figure this out I have been searching and searching with no luck
  5. Hey in my category field I got multiple values in the same mysql row I'm having problem with how to separate them so I can display the name of the category and make a link for each category.. the multiple values are something like that 1,2 how can I make it so it would separate after each comma? <?PHP $result = mysql_query("SELECT a.*, b.c_id, b.c_title FROM properties AS a JOIN cat AS b ON a.pr_category = b.c_id",$connect); while($row = mysql_fetch_assoc($result)) { ?> <h2><a href="blog-post.php?id="><?php echo $row['pr_title']; ?></a></h2> <p class="date">12 July 2011 in <a href="index.php?id<?php echo $row['c_id']; ?>"><?php echo $row['c_title']; ?></a></p> <img class="img-large-bg" src="../uploads/images/<?php echo $row['f_img']; ?>" alt="" title="" /> <?PHP } ?>
  6. Hey your code worked but my remaining problem is how do I display the name of multi categories for example in the mysql field I got 1,2 which are cat1 and cat2 so far I'm only seeing the name of one category
  7. Hey I'm trying to display the names of the categories but the values are numbers connected to another table with the title of the category and the other problem is that sometimes it is multi categories selected and this will make a value like 1,2 so how can I solve this please? here is my messed up code and there seems to be something wrong with it.. <?PHP $result = mysql_query("SELECT * FROM properties, categories ",$connect); while($row = mysql_fetch_assoc($result)) { $pr_category = $row["pr_category"]; ?> <h2><a href="blog-post.html"><?php echo $row['pr_title']; ?></a></h2> <?PHP $result = mysql_query("SELECT * FROM categories WHERE id='$pr_category' ",$connect); while($row = mysql_fetch_assoc($result)) { $cat_title = $row["title"]; ?> <p class="date">12 July 2011 in <a href="#"><?php echo $cat_title; } ?></a></p> <img class="img-large-bg" src="../uploads/images/<?php echo $row['f_img']; } ?>
  8. Hey thanks for your reply but this wont solve the problem the jQuery tabs im using is for news posts so the fragment tabs have to be the same 1,2,3,4 it wont work with id. is there a way to tell the mysql to echo the latest second or third or forth post? this way I can echo it in every fragment..
  9. Hello I got an jQuery tabs and every tab got ID "fragment-1", "fragment-2" and so on now if want to tell PHP to use fragment-2 if fragment-1 is taken how do I do that? Thanks <div id="fragment-1" class="ui-tabs-panel"> <img src="assets/img/image1.jpg" title="" alt="" /> <div class="info" > <h1><?php echo $row['pr_title']; ?></h1> <p>blabla..</p> </div> </div>
  10. ah thanks that's how i did it <?php echo substr($news_title,0,25); ?> thanl for helping me out...
  11. Hey... I'm trying to echo the title of the news in the right column but I just want to display maximum of 25 characters how can I do it? thanks
  12. thank youu this worked very well.. thanks again
  13. Hey im having troube making this code as i have no idea how to do it... basically what im trying to do is for example if the index.php?id=XXX i want to echo "this" and if it is just index.php i want to echo "that" your help would be nice thanks <?php $id_lang = $_GET['id']; if($id_lang == $id_lang){ $result = mysql_query("SELECT * FROM pages WHERE id='$id_lang' ",$connect); while($row44 = mysql_fetch_assoc($result)) { $js_langdir = $row44['lang_dir']; }} else{ $js_langdir = "LTR"; } ?>
  14. hey thanks for your help guys im using TinyMCE now so it is working fine thanks for your help anyway
  15. i tried addslashes() but it is still the same magic_quotes_gpc() is on know and it didn't change anything yeah there is a DB connection the data is getting to the mysql but for example if i try to add text such as ( The whatever ‘Countdown’ will begin now!) the text will cut and will only get (The whatever) to the database
×
×
  • 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.