Imperitus
03-20-2001, 05:47 PM
I was looking fro a news hack that would take the stories posted in a particular forum and rip them to post automaticly on my news page...
unfortunatly I haven't been able to find a simple script to do it that made sense to me. So I started looking into learning php and sql and making my own... :)
So here's the results so far:
--------
<html>
<head><title>News ripping script</title></head>
<body>
<?
/* declare some relevant variables */
$DBhost = "your server name or ip";
$DBuser = "the user name for the server";
$DBpass = "the pass word for the server";
$DBName = " the name of the database you're useing for vbulletin";
$DBTable = "thread";
$DBForum = "The number of the forum you want to use to post news";
mysql_connect($DBhost,$DBuser,$DBpass) or die("Unable toconnect to database");
@mysql_select_db("$DBName") or die("Unable to select database $DBName");
$sqlquery = "SELECT * FROM $DBTable WHERE forumid = $DBForum ORDER by dateline DESC";
$result = mysql_query($sqlquery);
$number = mysql_numrows($result);
$i = 0;
if ($number < 1) {
print "<CENTER><P>There Were No Results for Your Search</CENTER>";
}
else {
while ($number > $i) {
$thename = mysql_result($result,$i,"title");
$theid = mysql_result($result,$i,"threadid");
$name = mysql_result($result,$i,"postusername");
print "<p><A href=forums/showthread.php?threadid=$theid>$thename</a> <br>posted by: $name
";
$i++;
}
}
?>
</BODY></HTML>
--------
I then call it with the tag:
<?php include('news.php');?>
Pretty simple, and not too functional but it works and is easy to understand for a novice like me.
I'm going to try and get it to pull the content of the posts as well next... any comments?
unfortunatly I haven't been able to find a simple script to do it that made sense to me. So I started looking into learning php and sql and making my own... :)
So here's the results so far:
--------
<html>
<head><title>News ripping script</title></head>
<body>
<?
/* declare some relevant variables */
$DBhost = "your server name or ip";
$DBuser = "the user name for the server";
$DBpass = "the pass word for the server";
$DBName = " the name of the database you're useing for vbulletin";
$DBTable = "thread";
$DBForum = "The number of the forum you want to use to post news";
mysql_connect($DBhost,$DBuser,$DBpass) or die("Unable toconnect to database");
@mysql_select_db("$DBName") or die("Unable to select database $DBName");
$sqlquery = "SELECT * FROM $DBTable WHERE forumid = $DBForum ORDER by dateline DESC";
$result = mysql_query($sqlquery);
$number = mysql_numrows($result);
$i = 0;
if ($number < 1) {
print "<CENTER><P>There Were No Results for Your Search</CENTER>";
}
else {
while ($number > $i) {
$thename = mysql_result($result,$i,"title");
$theid = mysql_result($result,$i,"threadid");
$name = mysql_result($result,$i,"postusername");
print "<p><A href=forums/showthread.php?threadid=$theid>$thename</a> <br>posted by: $name
";
$i++;
}
}
?>
</BODY></HTML>
--------
I then call it with the tag:
<?php include('news.php');?>
Pretty simple, and not too functional but it works and is easy to understand for a novice like me.
I'm going to try and get it to pull the content of the posts as well next... any comments?