Page 1 of 1
index.php?id=
Posted: Fri Apr 01, 2005 4:42 pm
by Zoxive
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
Posted: Fri Apr 01, 2005 5:02 pm
by feyd
Posted: Fri Apr 01, 2005 5:47 pm
by Zoxive
ok, thanks but now.. i have it like his
Code: Select all
<?php
$limit = '$_GETї'id']';
?>
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
Code: Select all
<?php
$limit = '{$_GETї'id']}';
?>
but that doesn't work eather..
-NonStopableForce
Posted: Fri Apr 01, 2005 5:49 pm
by feyd
single quote strings do not parse variables in them. There is no reason to use quotes around the variable name, for the most part however. If it's anything other than an array, it'll be sent to you in php as a string already.
Posted: Fri Apr 01, 2005 5:53 pm
by Zoxive
ok, thanks it worked, but not how i wanted : (
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("
","</em>",$echo_text);
$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
Posted: Fri Apr 01, 2005 6:09 pm
by brandan
$forum = '$_GET[id]';
that won't work.
$forum = $_GET[id];
Posted: Fri Apr 01, 2005 6:41 pm
by John Cartwright
brandan wrote:
$forum = $_GET[id];
Close, try:
Posted: Fri Apr 01, 2005 6:44 pm
by brandan
here's to paying attention.
Posted: Fri Apr 01, 2005 7:08 pm
by Zoxive
Awsome!
Thanks works perfect.
-NonStopableForce
Posted: Fri Apr 01, 2005 7:10 pm
by Zoxive
ok, now if i put that in more than so so, i can tell it how many diff to get, how would i put that in the address bar?
would it be like index.php?id=15?&t=5 ?
i would check, but my webserver just went down : (
-NonStopableForce
Posted: Fri Apr 01, 2005 7:28 pm
by John Cartwright
yes.
And you probably should set up a local server on your comp for developping.
You can download an apache+php+mysql bundle over at hotscripts.com