Welcome Guest, Not a member yet? Register   Sign In
Creating URLs
#1

[eluser]eric cumbee[/eluser]
I am new to codeigniter, i am trying to form a url that passes a value to another controller function.

this is the code for generating the link
Code:
<a >Precinct_ID);?&gt;">
i want it to generate a link that follows this nomenclature

http://<serveraddress>/index.php/<mycontroller>/<myfunction>/<value to be passed>
instead it is generating a url like this

Code:
http://localhost/list_voters/7
#2

[eluser]TheFuzzy0ne[/eluser]
Welcome to the CodeIgniter Community!

I think your code for generating the link is broken... :/

site_url() should be what you're looking for. You can find it in the [url="http://ellislab.com/codeigniter/user-guide/helpers/url_helper.html"]URL helper[/url].
#3

[eluser]eric cumbee[/eluser]
what i do not get is that i did the same thing on another page and it worked fine

and somehow seemingly at random it is getting the current function included in the url.
#4

[eluser]TheFuzzy0ne[/eluser]
Can you give a better example?
#5

[eluser]eric cumbee[/eluser]
how do i post code with out the forum messing it up?
#6

[eluser]TheFuzzy0ne[/eluser]
It shouldn't mess it up. If it does, then there's probably something wrong with the code your posting. The forum replaces < with &amp;lt; and > with &amp;gt;. You might need to do this manually.
#7

[eluser]eric cumbee[/eluser]
its truncating my code big time

basicly i am doing a href= set_precienct/echo ($row->County_Code)

and that works fine in the first page it creates the link properly

but when i do the same thing on the next page

except instead of set_precienct/County_Code i use list_voters/Precienct_ID

and i get set_precienct thrown into my url
#8

[eluser]TheFuzzy0ne[/eluser]
Either make your URL absolute, or append a forwards slash to the URL.

Code:
<a href="&lt;?php echo site_url('list_voters/' . $precinct_id); ?&gt;">URL</a>

// OR

<a href="/list_voters/&lt;?php echo $precinct_id; ?&gt;">URL</a>
// Note the leading forward slash.
#9

[eluser]eric cumbee[/eluser]
first way gives me http://192.168.1.20/index.php/Houdini/se..._voters/10

and the second gives me

http://192.168.1.20/list_voters/10
#10

[eluser]TheFuzzy0ne[/eluser]
What's your base_url set to in your config file?

Please post your controller and view. If you put them between [code][/code] tags, it should display properly.




Theme © iAndrew 2016 - Forum software by © MyBB