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
https://forums.phpfreaks.com/topic/79275-using-php-get-with-a-database/
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>';
}

?>

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

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.