Jump to content

[SOLVED] URL help


Bopo

Recommended Posts

Hi

 

Just need a bit of advice really, basically I need to pass two pieces of data from a url, now I know how to do one, like so

 

<?php

include("admin/blogconnect.php");

$sql = "SELECT * FROM months ORDER BY id DESC";
$query = mysql_query($sql, $connect);
while ($row = mysql_fetch_assoc($query)) {


echo '<li><a href="achieve.php?month=' . $row['month'] . '">' . $row['month'] . ' ' . substr($row['year'], 2) . '</a></li>'; 

}


?>
?>

 

Basically I want the URL to look like website.com/achieve.php?=March&=2009 something along those lines that allows both the month and year in the URL to be stored using GET. I'm guessing its something similar to what I have done to create the alt tag, it's just the '&=' or 'someword=' bit I'm not too sure on.

 

 

Link to comment
https://forums.phpfreaks.com/topic/154749-solved-url-help/
Share on other sites

example : mysite.com?month=March&year=2009

 

k, assume that's in the URL .. to retrieve the values using $_GET would be as follows :

$month = $_GET['month'];

then, if i echo'd out $month, i'd get the value from the URL, which is March.

 

pretty easy, eh?

 

when using $_GET, and passing values via the URL, be sure to properly clean the values as they are easily altered by a user.

Link to comment
https://forums.phpfreaks.com/topic/154749-solved-url-help/#findComment-813784
Share on other sites

Hi

 

Thanks for the reply, however my post must be misleading, I'm fine with GET, I just need to include the '&year' as a second parameter in my URL, currently as you can see I only have month (achieve.php?month=) well I want achieve.php?month=text&year=text

 

EDIT: Nvm, I was just a case of adding the text, I didn't think that would work

 

<?php <a href="achieve.php?month=' . $row['month'] . '&year=' . $row['year'] . '">' . $row['month'] . ' ' . substr($row['year'], 2) . '</a> ?>

Link to comment
https://forums.phpfreaks.com/topic/154749-solved-url-help/#findComment-813796
Share on other sites

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.