Might sound confusing, but I want to display multiple pages depending on what option the visitor selects. Like, when the visitor clicks "buy something", then the page changes to display that page, while not redirecting to another page. Basically, the page checks to see what the user has chosen, and includes a file depending on what they chose. If they haven't chosen anything, then it displays the homepage. Anyone know how to do this? PS: I have a table. I am using the echo fuction to display it, and I wanted to put some php in the table. How do I do it?
Yes, it's done with javascript, and is commonly referred to as AJAX.. You will need to learn javascript, and take a look at the jquerry (it's a javascript library) documentation. It makes it pretty easy. -Jason
Seems like DopeDomains is right. Here you can see simple AJAX example. You can check if it looks like something you need
Omg Dkameleon !! I'm a big fan of your site. Thanks guys, but like in my old arcade script (Av Arcade v3), it did some thing with the $_GET thing, where it would be like: if $_GET['addlink'] include 'filename.php' else if $_get['deletelink'] include 'filename.php' I'm not understand how that works...
with $gets you will be doing page reloads.. Unless we both misunderstood the problem. Do you want it to display seperate content if you browse to: http://yoursite.com/ and http://yoursite.com/?show=arcade but still have it trigger off one index.php file? (for examle http://dopedomains.com/?show=5Dict vs http://dopedomains.com/?show=5Len both run off a single index.php file, but the content changes because of the parameters. (before the PHP and SEO gurus yell, that's not how links are actualy displayed on my site, but it was the easiest way to illustrate examples) or so you want someone to browse to your page.. and then have part of the page contents (but only part of it) change as they click on various page elements? (For example http://dopedomains.com/ and click on the sorting. notice the page doesn't reload, but the content changes). -Jason
and the proper syntax for that example is: if (isset($_GET['addlink'])) { include('filename.php'); } elseif (isset($_get['deletelink'])) { include('OTHERFilename.php'); } PHP:
YES! This is exactly it! Is there also a way to do this while keeping the SEO? Like, in my current arcade script, if SEO is on, it redirects to a page like site.com/category/page.html. It still keeps the same structure though. Only the middle screen changes, and no it doesn't use iframes. If you don't know how to do that, just show me how to do the ?show=page one please.
Yes, you can keep it SEO friendly with some clever .htaccess (assuming your host supports it, and it sounds like they do). .htaccess example: RewriteEngine on RewriteCond %{query_string} ^(.*)$ RewriteRule topic/(.+) /?topic=$1&%1 [nc,L] PHP: and the PHP code for it: if ($_GET['topic']=="addlink") { // Display Addlink code here } elseif ($_GET['topic']=="dellink") { // Display Dellink code here } PHP: to call them you would use http://domain.com/topic/addlink or http://domain.com/topic/dellink You can also add any paramaters you want to to the end with standard ?param=foo&p2=foo2 format. -Jason
Ok, so if I have a link that says "Add a Link", where do I point that link to so it'll open up in the main page.
Use iframe to display the additional pages, Use javascript and CSS to display a tab menu. Click each tab to display different iframe. Add a close button, if user click the close button, then delete the iframe.
Keep in mind that none of the dynamic methods to do this (ajax, iframes, frames) are SEO friendly. If that matters to you, you'll need to do a reload. DopeDomains presented what I think is the best solution for you in post #8.
SeaOtter, Thanks. If you code it right, with fall back for non-javascript you can have your ajax and SEO friendliness too! Dopedomains.com uses both SEO friendly URLs, and Ajax loading of content. -Jason
So how does that work though? I put <a href=topic/addlink>, and then whenever someone clicks on it they'll just get index.php?view=addlink ?
A simpler version of the mod_rewrite (using QSA instead of manually adding the query string) RewriteEngine On RewriteRule ^topic/(.+)$ /?topic=$1 [NC,L,QSA] Code (markup): The users sees example.com/topic/addlink in the address bar when they click the URL but the server processes it as example.com/index.php?view=addlink And yes, DopeDomains is right, SEO and fallbacks for non JS users can be maintained when using AJAX, if you don't believe this, here is a starting point I use that seems to make the most sense: <a href="non-js-method-of-doing-the-same-thing.htm" onclick="alert('woot'); return false;">Do something exciting!</a> Or just look for "proper" web sites using AJAX.