Jump to content
xisto Community
Sign in to follow this  
loc

Php Help Please ^.^

Recommended Posts

I have noticed that when some people use links, they type in something like this *index.php?view=Ranks* or something like that. Can you tell me how to use the little addons that go after the .php?Or point me toward a good tutorial on the subject?

Share this post


Link to post
Share on other sites

Unless you are using POST requests in forms, you can access it with the $_GET array. With the ranks example:

<?php[br]if ($_GET['view'] == 'Ranks')[/br]{[br]// display the ranks page[/br]}[br]else[/br]{[br]// other code goes here[/br]}?>

You may have to use $_POST instead of $_GET if you're using the POST method to submit data.

Share this post


Link to post
Share on other sites

You don't need a $_GET to pass parameters, or a form, you can use a simple link like this:

 

 

<a href="results.php?criteria=searchField=A">Title with A</a><a href="results.php?criteria=searchField=B">Title with B</a><a href="results.php?criteria=searchField=C">Title with C</a>

And then, the results.php page:

 

<?php		  ...		  $_connection		   ...?><head><title>Books!</title></head><body><?php$sql = "SELECT * FROM books WHERE $_REQUEST[criteria] like '$_REQUEST[searchField]%' ORDER BY title";$result=mysql_query($sql); if (mysql_num_rows($result)){while ($row=mysql_fetch_array($result)){  echo '<strong>'.$row["title"].'</strong>;}}else	  echo 'No records were found!';?></body></html>

It works for me!
Edited by acantocephala (see edit history)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | 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.