php - Results that include space don't get fetched -


this code used results of different category names. here, if category names have space result won't displayed while names without having spaces displayed.

this code:

<ul>     <li><a href="<?php echo base_url();?>clients">view </a></li>     <?php foreach($clientdropdown $row){?>     <li class="<?php if($active_mn== $row->id) echo 'active'; ?>">         <a href="<?php echo base_url();?>client/<?php echo $row->category_name;?>">             <?php echo $row->category_name;?>             <span></span>         </a>     </li>          <?php }?>         </ul> 

i'm little bit confused use replace() avoid spaces.

i had changed code please see

having looked @ trying in edited code, problem had isn't $row->category_name won't fetch.
space in url not being encoded page won't redirect correctly.

url encoding replaces unsafe ascii characters "%" followed 2 hexadecimal digits.
space unsafe ascii character.
urls cannot contain spaces. url encoding replaces space plus (+) sign or %20.

urlencode() translates space +
rawurlencode() translates parameters hex code, %20 space

<ul>     <li><a href="<?php echo base_url();?>clients">view </a></li>     <?php foreach($clientdropdown $row){?>     <li class="<?php if($active_mn== $row->id) echo 'active'; ?>">         <a href="<?php echo base_url();?>client/<?php echo rawurlencode($row->category_name);?>">             <?php echo $row->category_name;?>             <span></span>         </a>     </li>          <?php }?>         </ul> 

update
codeigniter translates space underscore when creates directory name contains space, correct path access directory created using category name "hello world" should "hello_world", particular case str_replace(" ", "_", $row->category_name) there needed.


Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -