index.php?id=
Moderator: General Moderators
index.php?id=
ok.. i a bit of php code in my site right now, and i want one page where i can have one variable changed by what they have in the address bar IE index.php?id=, do that id= would be what i put in the address bar, and i know of many websites that do this, and i want to know how hard it would be to do this.
-NonStopableForce
-NonStopableForce
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
quite easy.
http://php.net/reserved.variables#reser ... iables.get
Code: Select all
<?php
echo $_GETї'id'];
?>Code: Select all
hi I am a get variableok, thanks but now.. i have it like his
but i can't have it like that because of the ' how whould i change it so it works?
because it errors right now, and i tryed
but that doesn't work eather..
-NonStopableForce
Code: Select all
<?php
$limit = '$_GETї'id']';
?>because it errors right now, and i tryed
Code: Select all
<?php
$limit = '{$_GETї'id']}';
?>-NonStopableForce
ok, thanks it worked, but not how i wanted : (
Well i am going to explain, what all i have... here goes...
","</em>",$echo_text);
$echo_text = preg_replace('/\[list\](.*)\[\/list\]/si',"<div style="padding: 7px">$1</div>",$echo_text);
$echo_text = preg_replace('/\
Well i am going to explain, what all i have... here goes...
Code: Select all
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Head-Humped :: Forums</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body>
<table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="81" colspan="3" align="center"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="17%"><img src="images/newlayou-murged_03.gif" width="209" height="149"></td>
<td width="50%" background="images/topback.gif"> </td>
<td width="40%" align="right"><a href="http://www.head-humped.co.uk"><img src="images/newlayou-murged_04.gif" width="496" height="149" border="0"></a></td>
</tr>
</table></td>
</tr>
<tr>
<td width="15%" rowspan="3" align="left" valign="top"><table width="100%" height="505" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="209" height="50" align="left" valign="middle" background="images/newlayou-murged_06-top.gif"><div class="linktitle">:: Navigation </div></td>
</tr>
<tr>
<td height="428" align="left" valign="top" background="images/newlayou-murged_06-mid.gif">
<?php include("menu.php"); ?>
</td>
</tr>
<tr>
<td height="19" valign="bottom" background="images/newlayou-murged_06-mid.gif"><img src="images/newlayou-murged_06-bottom.gif" width="209" height="19"></td>
</tr>
</table></td>
<td width="814" height="44" align="center" valign="middle" background="images/newlayou-murged_07.gif"><div class="title"></div></td>
<td width="15%" height="44" rowspan="3" align="right" valign="top"><table width="100%" height="505" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="206" height="50" align="left" valign="middle" background="images/newlayou-murged_07-top.gif"><div class="linktitleright">Quick Media :: </div></td>
</tr>
<tr>
<td height="428" align="left" valign="top" background="images/newlayou-murged_07-mid.gif"><?php include("quickmeida.php"); ?>
</td>
</tr>
<tr>
<td height="19" valign="bottom" background="images/newlayou-murged_06-mid.gif"><img src="images/newlayou-murged_07-bottom.gif" width="209" height="19"></td>
</tr>
</table></td>
</tr>
<tr>
<td height="428" align="center" valign="top">
<!-- HERE!!!-->
<?php
## Mod Title: Topic Extraction
## Version: 1.5.0
#############
## Edit Below
#############
// Where to take the topics from
// Always a number
$forum = '$_GET[id]';
// How many topics to show
$limit = '1';
// How to show the topics
// full or blank ('')
$show = 'full';
// How to display the date and time if used
// short or long
$date_time = 'short';
// How top display the topic link if usede
// topic or phpbb
$topic_link = 'topic';
// Comments link - how to send them to comments
// topic or reply
$comment = 'topic';
// Path to your forums directory
// Usually ./forum/ or ./phpBB/ or ./forums/
$phpbb_root_path = 'forums/';
#############################################
## No Editing unless you know what your doing
#############################################
if ( !defined('IN_PHPBB') )
{
define('IN_PHPBB', true);
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
include($phpbb_root_path . 'config.'.$phpEx);
}
if ($show == '' || $show == 'full')
{
// Select the topic information from the correct forum and set it to $grab_topics
$grab_topics = $db->sql_query("SELECT * FROM `{$table_prefix}topics` WHERE `forum_id` = '{$forum}' ORDER BY `topic_id` DESC LIMIT {$limit}");
}
else if ($show == 'topic')
{
$grab_topics = $db->sql_query("SELECT * FROM `{$table_prefix}topics` WHERE `forum_id` = '{$forum}' AND `topic_id` = '{$_GET['t']}' ORDER BY `topic_id` DESC");
}
// Grab the information using an array and set it to $echo_topic
while ($echo_topic = $db->sql_fetchrow($grab_topics))
{
// Select the post information from the correct forum and set it to $grab_posts
$grab_posts = $db->sql_query("SELECT * FROM `{$table_prefix}posts` WHERE `forum_id` = '{$forum}' AND `topic_id` = '{$echo_topic['topic_id']}' LIMIT 1");
// Grab the information using an array and set it to $echo_post
while ($echo_post = $db->sql_fetchrow($grab_posts))
{
// Now get the post_text using the post_id were looking at and sort it info $grab_posts_text
$grab_posts_text = $db->sql_query("SELECT * FROM `{$table_prefix}posts_text` WHERE `post_id` = '{$echo_post['post_id']}'");
// Grab the information using an array and set it to $echo_text
while($echo_text = $db->sql_fetchrow($grab_posts_text))
{
// Find the user the posted
$find_user = $db->sql_query("SELECT * FROM `{$table_prefix}users` WHERE `user_id` = '{$echo_post['poster_id']}'");
// Sort this users info into array for the post
while ($echo_user = $db->sql_fetchrow($find_user))
{
// Get rid of all those annoying characters from bbcode
$echo_text = preg_replace('/\:[0-9a-z\:]+\]/si', ']', $echo_text);
// BBCode
$echo_text = str_replace("[b]","<strong>",$echo_text);
$echo_text = str_replace("[/b]","</strong>",$echo_text);
$echo_text = str_replace("[i]","<em>",$echo_text);
$echo_text = str_replace("[/i]","</em>",$echo_text);
$echo_text = str_replace("[u]","<u>",$echo_text);
$echo_text = str_replace("[/u]","</u>",$echo_text);
$echo_text = preg_replace('/\[quote="(.*)"](.*)\[\/quote\]/Usi','<div class=\'hequoted\'>$2</div>',$echo_text);
$echo_text = str_replace("[quote]","<strong>Quote</strong><em>",$echo_text);
$echo_text = str_replace("[/quote][/quote]","</em>",$echo_text);
$echo_text = str_replace("Code: Select all
","<strong>Code</strong><em>",$echo_text);
$echo_text = str_replace("$echo_text = preg_replace('/\[list\](.*)\[\/list\]/si',"<div style="padding: 7px">$1</div>",$echo_text);
$echo_text = preg_replace('/\
- (.*)\[\/list\]/si',"<div style="padding: 7px">$1</div>",$echo_text);
$echo_text = str_replace("[img]","<img src="",$echo_text);
$echo_text = str_replace("[/img]","" alt="image" />",$echo_text);
$echo_text = preg_replace('/\[url\](.*)\[\/url\]/Usi','<a href="$1">$1</a>',$echo_text);
$echo_text = preg_replace('/\[url=(.*)\](.*)\[\/url\]/Usi','<a href="$1">$2</a>',$echo_text);
$echo_text = str_replace("\n", "\n<br />\n", $echo_text);
// Way to display date and time
// long
if($date_time == "long")
{
$echo_topic['topic_time'] = strftime("%A %e %B %H:%M",$echo_topic['topic_time']);
}
// short
if ($date_time == "short")
{
$echo_topic['topic_time'] = strftime("%a %e %b %H:%M",$echo_topic['topic_time']);
}
// Way to display comment link
// Go right to the topic
if ($comment == 'topic')
{
$comment_link = "{$phpbb_root_path}viewtopic.php?t={$echo_topic['topic_id']}";
}
// Go right to the reply box
if ($comment == 'reply')
{
$comment_link = "{$phpbb_root_path}posting.php?mode=reply&t={$echo_topic['topic_id']}";
}
// Topic link types
// This link goes to the topic display
if ($topic_link == 'topic')
{
$topic_link = "?show1=topic&t={$echo_topic['topic_id']}";
}
// This link goes to the actual phpbb topic
if ($topic_link == 'phpbb')
{
$topic_link = "{$phpbb_root_path}viewtopic.php?t={$echo_topic['topic_id']}";
}
##################################
## Edit for look and feel of topic
##################################
// Display just the title
if ($show != 'full' && !isset($_GET['show1']))
{
echo "<a href='{$topic_link}'>{$echo_text['post_subject']}</a><br />";
}
// Display many topics - for news, shoutbox etc
// {$echo_text['post_subject']}
// {$echo_text['post_text']}
// Posted By: {$echo_user['username']} On {$echo_topic['topic_time']}
// <a href="{$comment_link}">Comments {$echo_topic['topic_replies']}
else if ($show == 'full')
{
echo "
<table width='100%' height='124' border='0' cellpadding='0' cellspacing='0'>
<tr>
<td height='29'><table width='100%' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td width='7%' height='29' align='left' valign='top'><img src='images/small/top-left.gif' width='60' height='29'></td>
<td width='90%' align='left' valign='top' background='images/small/top-mid.gif'><div class='newstitle'>{$echo_text['post_subject']}</div></td>
<td width='3%' align='right' valign='top' background='images/small/top-mid.gif'><img src='images/small/top-right.gif' width='18' height='29'></td>
</tr>
</table></td>
</tr>
<tr>
<td height='51'><table width='100%' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td width='11' height='80' background='images/small/mid-left.gif'><img src='images/small/mid-left.gif' width='11' height='16'></td>
<td width='786' align='left' valign='top' background='images/small/mid-mid.gif'><div class='newsbody'>{$echo_text['post_text']}</div></td>
<td width='13' background='images/small/mid-right.gif'><img src='images/small/mid-right.gif' width='13' height='16'></td>
</tr>
</table></td>
</tr>
<tr>
<td height='15'><table width='100%' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td width='1%'><img src='images/small/bot-left.gif' width='11' height='31'></td>
<td background='images/small/bot-mid.gif'><div class='postedleft'>Posted By: {$echo_user['username']} On {$echo_topic['topic_time']}</div> </td>
<td background='images/small/bot-mid.gif'><div class='postedright'><a href="{$comment_link}">Comments {$echo_topic['topic_replies']}</div></td>
<td width='5%' align='right'><img src='images/small/bot-right.gif' width='62' height='31'></td>
</tr>
</table></td>
</tr><br>
</table>";
}
}
}
}
}
?>
<!--Here-->
</td>
</tr>
<tr>
<td height="11" align="center" valign="bottom"><table width="520" height="41" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td background="images/newlayou-murged_15.gif"><div class="bottom">Website Designed By: NonStopableForce ©2005</div></td>
</tr>
</table></td>
</tr>
</table>
</body>
</html>
Thats the hole code to one of the pages on my site.
Right now where the "$_GET[id]" is i have a number for what forum the code pulls the text from and shows on my site. but i want so i can tell the browser to pull off a sertain forum when i want. ex. index.php?id=15, so it will pull fourm 15 and show it.
Right now, it pulls nothing off the forum when its set like that and all i get is my layout with a blank middle where usually it pulls from, and yes i had index.php?id=15 in the browser
Anyone know how to do this? : p
-NonStopableForce
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact: