Jump to content

taking the url and putting it into query


Codeman0013

Recommended Posts

I tend to put that sort of information at the top of my page after the headers.

Defines the variables for the rest of the page that way.

So you'd have it look like this:

[code]
<?php
// get parameters from the URL into the page and sanitise
if (!empty($_GET['industry'])){
  $ind_id = strip_tags(add_slashes($_GET['industry']));
}

// call the file that has my DB connect code in it
include('connect.php');

// setup the SQL statement with the variable from the url
$sql = "SELECT * FROM tablename WHERE industry = $ind_id";

// execute the statement
$result = mysql_query($sql);

// Check it executed ok
if (!$result){
  die ('There was an error executing the SQL: ' . mysql_error());
}

// Do something with the results
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)){
  echo "$row['columnname']<br>\n";
}
?>
[/code]

Regards
Huggie

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.