Welcome Guest, Not a member yet? Register   Sign In
links to divs using ids
#1

[eluser]joeizang[/eluser]
hi y'all,

gotta question! can i make an anchor tag to link to a div with an id of say '#articles'?
I tried that but ci says my link has a forbidden character. I basically would like to make links on my homepage to link to a div with id='#foo'. normally (according to ci usermanual) ci urls are such that you will have 'controller/function/.../...' so is this possible?

Thnks
#2

[eluser]Jamie Rumbelow[/eluser]
Just add the hash symbol ('#') to your uri_allowed_chars setting in config.php! It should work fine then.

Jamie
#3

[eluser]Yorick Peterse[/eluser]
You can't link to div elements, however you can link to anchor tags. Simply add the following somewhere :

Code:
<a name="myanchor"></a>

Then simply browse to the following URL :

Code:
http://www.mywebsite.com/#myanchor
#4

[eluser]joeizang[/eluser]
thanks jamie, looks good.
#5

[eluser]joeizang[/eluser]
sorry guys,

on a different note. can you explain how i can use the now() function of mysql in active record when I am inserting a row into my database? I have not been too successful with this at all. this is so I can display the date on a homepage for example like with new articles for instance.

Thanks
#6

[eluser]jedd[/eluser]
New subject, new thread!

Code:
// I use manually crafted query strings - but you should be able to work this out.
     $query = $this->db->query ("INSERT INTO
                                    message (thread_id , author , msgdate )
                                 VALUES
                                    ( ". $thread_id  .",".  $this->session->userdata('id')  .", NOW() )
                                 ");


EDIT: D'oh! Just noticed you specified active record. What's the problem? I don't think () need escaping, but if they do, just set the third parameter to TRUE (if you're using ->set())

EDIT2: Your phrase- ... now() function of mysql ... belies the problem of using it within an AR context. One of the reasons to use AR is to keep your code DB-agnostic - keep this in mind if you're about to do this. If your DB and web server are on different boxes, and/or you have users in disparate timezones, it may be time (haha) to re-ponder your approach to time.
#7

[eluser]Colin Williams[/eluser]
Quote:You can’t link to div elements, however you can link to anchor tags. Simply add the following somewhere

You can link to any element with an ID, Yorick
#8

[eluser]Jamie Rumbelow[/eluser]
[quote author="Yorick Peterse" date="1256702469"]You can't link to div elements, however you can link to anchor tags. Simply add the following somewhere :

Code:
<a name="myanchor"></a>

Then simply browse to the following URL :

Code:
http://www.mywebsite.com/#myanchor
[/quote]

Yes you can. You can link to (almost) any element with an ID, using the hash symbol in the URL.
#9

[eluser]John_Betong[/eluser]
[quote author="joeizang" date="1256703832"]sorry guys,

on a different note. can you explain how i can use the now() function of mysql in active record when I am inserting a row into my database? I have not been too successful with this at all. this is so I can display the date on a homepage for example like with new articles for instance.

Thanks[/quote]
&nbsp;
When I first started using MySQL I struggled with the multitude of functions and relationships available for time, dates and different timeZones. I discovered MySQL's CURRENT_TIMESTAMP and it solved all my problems Smile Check it out.

No doubt I will stand corrected but I get the distinct impression that MySQL and PHP are far more helpful towards fields set as TIMESTAMP rather than DATETIME.
&nbsp;
&nbsp;
&nbsp;




Theme © iAndrew 2016 - Forum software by © MyBB