Jump to content

Using PHP GET with a database


Vivid Lust

Recommended Posts

Can someone please tell me how to use PHP GET with a datasbase for a use in a CMS system.

 

Is it that the link to a page gets the information from a datasbe and then it displays on that page?

 

Arghhhh... please help.

 

And if you can please send in some Code snippet examples.

 

Thanks!!

Link to comment
Share on other sites

It's kinda hard to figure out what you want...but I'm guessing something like this

 

<?php

$var = mysql_real_escape_string($_GET['var']);

$query = "SELECT * FROM table WHERE col='$var'";
$result = mysql_query($query)or die(mysql_error());

while ($row = mysql_fetch_assoc($result)){
   echo $row['col'].'<br>';
}

?>

Link to comment
Share on other sites

What exactly are you trying to accomplish?

 

To pass information through the URL you can simply make a link that looks like this

<a href="domain.com/script.php?var=something&anothervar=somethingelse">Link</a>

 

Or you could pass it through a form action and use the same url.

 

You can read more about GET here

http://www.tizag.com/phpT/postget.php

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

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.