Re: [PHP] index.php?page=1
Is your problem similar to this: http://forum.ragezone.com/f144/help-...nloads-656923/ ?
Do you catch the ?page= anywhere.. What is it supposed to do? :)
Re: [PHP] index.php?page=1
Quote:
Originally Posted by
Way[2]Death
Not quite sure how should it be done, as I have never done this before.
Something like that you have a database, where you can add stuff into (basically, like news)
For example like in this.
PHP Code:
echo '<a href="index.php?page='.$row['ID'].'">'.$row['Text'].'</a>';
The ?page= is set up for the ID. I've got a table with ID, Text and such. The Text will be the links title, like you normally would do.
<a href="index.php">This text here</a>.
When you click on the link, it looks up for its ID and with that takes the other data from the row.
Re: [PHP] index.php?page=1
Ah ok, then you'd need to catch the ?page..
first you need to catch it with: $_GET['page']
When you echo that, it will return 1, 2, 3 etc (the number you insert at IDHERE: ?page=IDHERE).
After that, if you dont already have it, you need to create a MYSQL/MSSQL connection, and look for the id with a SELECT. after that you can output the result of this :)
If you are new to programming you could ask someone to do it for you.. not sure who will, else you could google my instructions and such :)
hope that helps
Re: [PHP] index.php?page=1
I wanted to learn how to do this, but it seems too complicated for me.
I think I would need some example of how to do this, and then look of it, and make it work for mine.
Re: [PHP] index.php?page=1
Re: [PHP] index.php?page=1
like...
Code:
$db = "SELECT id,news,content,title,etc,thisshit FROM db_news"
while($row = mysql_fetch_array($db)) {
echo "<a href='index.php?page=".$row['id']."'>".$row['title']."</a>
}
something like that? didn't exactly understand the problem, so lol.
Re: [PHP] index.php?page=1
Quote:
Originally Posted by
Sparkly
like...
Code:
$db = "SELECT id,news,content,title,etc,thisshit FROM db_news"
while($row = mysql_fetch_array($db)) {
echo "<a href='index.php?page=".$row['id']."'>".$row['title']."</a>
}
something like that? didn't exactly understand the problem, so lol.
Basically, this is what I've got so far.
I tried with that, but it did not solve my problem.
@Way[2]Death Thanks, I will check out those links and then post if I got it working or not.
EDIT: Those stuff on the website, atleast Connect was what I had already. Post & Get, well somehow, but how do I use them for links? That helps in doing it with forms.
Re: [PHP] index.php?page=1
PHP Code:
$db = mysql_query("SELECT id,news,content,title,etc,thisshit FROM db_news");
while($row = mysql_fetch_array($db)) {
echo "<a href='index.php?page=".$row['id']."'>".$row['title']."</a>
}
Well if you copied it right away, then you'd need to add a query first see above XD
Re: [PHP] index.php?page=1
boy do i love switch case in this kind of problem.
PHP Code:
<?php
$ID = $_GET['id'];
switch($ID) {
case 1:inlcude('./1.php');break;
case 2:inlcude('./2.php');break;
case 3:inlcude('./3.php');break;
default:include('./home.php');break;
}
?>
this is going off the top of my head lol.
Re: [PHP] index.php?page=1
Quote:
Originally Posted by
holthelper
boy do i love switch case in this kind of problem.
PHP Code:
<?php
$ID = $_GET['id'];
switch($ID) {
case 1:include('./1.php');break;
case 2:include('./2.php');break;
case 3:include('./3.php');break;
default:include('./home.php');break;
}
?>
this is going off the top of my head lol.
only one little problem bro, it's not inlcude, it's include :P try typing slower
Re: [PHP] index.php?page=1
what eva i was at school and the teacher was on my ass about being on this site. i guess i cant be on a "message board" LOL.
anyways, you know what i meant and i made that in the quick reply add-on...
Re: [PHP] index.php?page=1
Quote:
Originally Posted by
Way[2]Death
PHP Code:
$db = mysql_query("SELECT id,news,content,title,etc,thisshit FROM db_news");
while($row = mysql_fetch_array($db)) {
echo "<a href='index.php?page=".$row['id']."'>".$row['title']."</a>
}
Well if you copied it right away, then you'd need to add a query first see above XD
No, I did not copy it, because thats like exactly what I had before.
PHP Code:
<?php
require("config.php");
$query = mysql_query('SELECT * FROM news ORDER BY ID DESC LIMIT 10');
while($row = mysql_fetch_assoc($query))
echo '<tr><td><a href="index.php?id='.$row['ID'].'">'.$row['Subject'].'</a></td><td><a href="users.php?u='.$row['User'].'">'.$row['User'].'</td><td>'.$row['Date'].'</td></tr>';
?>
This is my index.php file, actually, just the PHP part of it.
To explain what I am looking for, I'll clear it up!
I'm trying to create a news system, that you have a index.php, where you see like "Subject" which is a link, exactly like on these forums those posts.
When you click on it, the text written for the news shows up.
The main idea was not how to create something such as ?page=1, I think I should had explained it different way.
Basically like, once you click on the "Subject" it takes you to a page index.php?id=1 and shows the content written for news ID 1.
So what it should do, is to send the ID of the subject to another file to take the other information on the row into it aswell, at the moment it takes all the information which is in the whole table, but I wanted just the one row to appear.
Re: [PHP] index.php?page=1
Not sure if this is the kind of thing you are trying to do but here goes.
index.php
PHP Code:
<?
include ('mysql_connect.php');
$query = "SELECT id, title, author, post, DATE_FORMAT(date, '%M <b>%d</b>') as sd FROM news_posts ORDER BY date DESC LIMIT 3";
$result = @mysql_query($query);
if ($result) {
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
$view = 'entry.php?id='.$row['id'];
echo '<a href="'.$view.'">'.$row['title'].'</a>';
}
} else {
echo 'There are no news posts to display';
}
?>
entry.php
PHP Code:
<?php
include ('mysql_connect.php');
if (isset($_GET['id'])) {
$id = $_GET['id'];
} else {
echo "Error Occured. Article Doesn't Exist Or Has An Invaild ID";
exit();
}
$query = "SELECT id, title, author, post, DATE_FORMAT(date, '%M <b>%d</b>') as sd FROM news_posts WHERE id=$id LIMIT 1";
$result = @mysql_query($query);
if ($result) {
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo '<p class="date">'.$row['sd'].'</p>
<h2 class="title">'.$row['title'].'</h2>
<p class="meta"><small>Posted By: '.$row['author']. ' </small></p>
<div class="entry">
<p>'.$row['post'].'</p>
</div><br>';
}
}