Jump to content

Jaswinder

Members
  • Posts

    124
  • Joined

  • Last visited

Posts posted by Jaswinder

  1. Hello friends,

     

    I am trying to achieve a simple thing, but I do not know jquery/javascript  much. When I click on a forst list item in one div , I want to show corresponding 1st li in the second div. I have 6 list items in total and related 6 li in second div.

     

    Also when I click on any list item in first div, it will be borderd, this I achieved. But I am not able to bring the related li in the second div.

     

    Hope I make myself clear.

     

    Here is my code

    <style>
    .selected img
    {
        border:2px solid #090;
    }
    .visible
    {
    display:block;
    }
    
    .invisible
    {
    display:none;
    }
    </style>
    
    <div id="all">
    <ul>
    <li class="selected"><img src="image1.JPG" /></li>
    <li><img src="image2.JPG" /><br /></li>
    <li><img src="image3.JPG" /><br /></li>
    </ul>
    </div>   
    
    <div class="container">
    <ul>
    <li class="visible"><img src="related_image1.JPG" /></li> (In these list items there may be img or content)
    <li class="invisible"><img src="related_image2.JPG" /></li>
    <li class="invisible"><img src="related_image3.JPG" /></li>
    </ul>
    </div>
    
    <script type="text/javascript">
    
        $('#all ul li').on('click', function(){
        
    	$(this).addClass('selected').siblings().removeClass('selected');
    	
    	$('.container ul li:nth-child(1)').fadeout(); // Don't know this line is correct or not
    	
    	
    });
    </script>
    
    

    Any help guys ?

  2. Hi all

    Its my first project in CodeIgniter and I tried to make it live from local

     

    Issue is, In local server, site URI is running without index.php, but live it is giving error.

     

    e.g http://localhost/ci_basic/site/about

     

    folder name -  ci_basic

    Controller name - site

    Function name - about

     

    In .htaccess file

     

    RewriteEngine On
    RewriteBase /ci_basic/

     

    Now i uploaded the file in a folder named - chikabana ( folder in my root directory assigned to the chikabana.com )

     

    In .htaccess file

     

    RewriteEngine On
    RewriteBase /chikabana/

     

    I also changed the base url to - chikabana.com in config file

    and also removed index.php from config file.

     

    But this URL not working - http://chikabana.com/site/about

     

    this is working - http://chikabana.com/index.php/site/about

     

     

     

    Also my second question is  - how i remove the controller name from url?

     

  3. Hi guys

    I am a php programmer and  in a big confusion. I want to learn a framework, but can't figure out which one start ?

     

    CakePHP

    Codelgniter

    Symfony

    laravel

     

    I am new to them, so you can suggest me which one to start 1st and move on to other. Or If i miss any other framework , you can tell me that also.

     

    Any help is appriciable.

    Thanks

  4. thanks for reply, array_intersect_assoc()  works

     

    But i am not clear,

     

    As you said - array_intersect() only checks values - not keys

     

    and here  i am  trying to compare the values only, and all values are different,  so why i cant be able to use array_intersect() here ?

  5. Hi guys ,

    Again i facing array comparison problem

     

    i got this after var_dump()  $a and $b

    array(4) { ["q1"]=> string(3) "yes" ["q4"]=> string(2) "no" ["q3"]=> string(2) "no" ["q2"]=> string(2) "no" }
    array(4) { ["q1"]=> string(2) "no" ["q4"]=> string(3) "yes" ["q3"]=> string(3) "yes" ["q2"]=> string(3) "yes" }

     

    But when i use array_intersect($a,$b).. it results this

    array(4) { ["q1"]=> string(3) "yes" ["q4"]=> string(2) "no" ["q3"]=> string(2) "no" ["q2"]=> string(2) "no" }

     

    Don't know why, but there is no same value in both

  6. i tried var_dump() , and i found  some problem

     

    array(3) { ["q1"]=> string(2) "no" ["q2"]=> string(10) " yes" ["q3"]=> string(10) " yes" }

    array(3) { ["q1"]=> string(2) "no" ["q2"]=> string(3) "yes" ["q3"]=> string(3) "yes" }

     

    After array_intersect()

    array(1) { ["q1"]=> string(2) "no" }

     

    Why it showing string(10), there is only 3

     

    I think there is something messy in the value of input field

  7. Hi thanks for reply guys, nothing helping,

    I explain you what i am doing

     

    I entered some questions in database with answer  yes    or   no

     

    After that  i asked the same question from visitors and get their answer also .., then i compared them ,

     

    Now in the same example , if i take some numeric values, instead of yes/no, the functions results correct i.e returning all the same values.

     

    i think character comparison is giving problem ? isn't it ?

  8. Hi

    i am trying to compare to arrays

     

    $a = Array ( [q1] => no [q3] => yes [q2] => yes );

    $b = Array ( [q1] => no [q3] => yes [q2] => yes );

     

    But when i intersect them it results in one element only, dont know why???

     

    $c = array_intersect($a,$b);

    print_r($c);

     

    output -

     

    Array ( [q1] => no )

    • I got your first point , there is no quoted string, so i will not use this  function
    • Regarding error handling, this is new to me, i will surf the web more for this, Thanks for bringing this thing in notice.
    • Lastly, i was not trying to make empty table as error, just trying to print an error,  if any occurred . This will also get clear after learning error handling

    Thanks a lot :)

  9. Thanks Jacques1 

    for reply and help me  to improve my code. :)

     

    I started learning oops few days back, so there may be many mistakes.

     

    • Firstly,  mysqli_real_escape_string, i admit its of no use here , as no user input is there.
    • Secondly, regarding errors, i want to display my own error messages , so  i found this method comfortable
    • This function is basically in a class in a separate file, so i am just returning result after fetching  from database
  10. hi

    i am trying to fetch all my data from table

    here is the code

    function premiumview($cn,$table)
    	{
    		$table=mysqli_real_escape_string($cn,$table);
    		$result=$cn->query("select * from $table");
    		if($result->num_rows >0)
    		{
    			while($f=$result->fetch_all(MYSQL_ASSOC))
    			{
    				$result[]=$f;
    			}
    			return $result;
    		}
    		else
    		{
    			return $result=$cn->error;
    		}
    	}
    

    and the error is

     

    Fatal error: Cannot use object of type mysqli_result as array ( in while loop line )

     

    What i am doing wrong?

  11. Insert  query not working

    insert into user(code) values('saafvjfjeklwvlk') where email='abc@yahoo.com'
    

    tablename - user

    column name - code

    error - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'where email='abc@yahoo.com''

     

    Any idea ?

  12. i want to convert multidimensional array to single array

     

    I am having this array

    array ( 
    0 => array ( 'sno' => 'q3', 'result' => '15', ),
    1 => array ( 'sno' => 'q1', 'result' => '5', ), 
    2 => array ( 'sno' => 'q2', 'result' => '10', ),
    )
    

    i want this resulting array

    array ( 'q3' => '15', 'q1' => '5','q2' =>'10' )
    

    i tried foreach, but it gives the values (not an array ) like q3 15 q1 5 q2 10

×
×
  • 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.