Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> PHP
Author Message
hinksta
Worker
Worker



Joined: Dec 23, 2005
Posts: 226
Location: UK

PostPosted: Tue Dec 12, 2006 11:10 am Reply with quote

Me again, I'm trying to include a html file into a page if a word in the database is used in a search

in the database each word has an url so if a word is found I want the url to be printed
Code:
CREATE TABLE `nuke_mywords` (

`id` int(10) NOT NULL auto_increment,
`no` varchar(255) default NULL,
`keyword` varchar(255) NOT NULL default '',
`keyword_full` varchar(255) NOT NULL default '',
`include_url` varchar(255) default NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;


INSERT INTO `nuke_mywords` VALUES (1, 0, 'word1', 'Word 1', 'word1.html');
INSERT INTO `nuke_mywords` VALUES (2, 0, 'word2', 'Word 2', 'word2.html');
INSERT INTO `nuke_mywords` VALUES (3, 0, 'word3', 'Word 3', 'word3.html');
INSERT INTO `nuke_mywords` VALUES (4, 8, 'word4', 'Word 4', 'word4.html');
INSERT INTO `nuke_mywords` VALUES (5, 11, 'word5', 'Word 5', 'word5.html');
INSERT INTO `nuke_mywords` VALUES (6, 11, 'word6', 'Word 6', 'word6.html');


So far i'm playing with the code below, It's a bit of a mess.
Code:
$word = $db->sql_query("SELECT keyword,include_url FROM ".$prefix."_mywords". "WHERE keyword = $search");

while ($row = $db->sql_fetchrow($word)) {
   $url = $db->sql_fetchrow($db->sql_query("SELECT * FROM ".$prefix."_mywords WHERE **I'm stuck here**"));

if (**stuck** == **here**) {
 include("modules/Mywords/".$url."");
 }
}
 
View user's profile Send private message Visit poster's website
Gremmie
Former Moderator in Good Standing



Joined: Apr 06, 2006
Posts: 2415
Location: Iowa, USA

PostPosted: Tue Dec 12, 2006 11:58 am Reply with quote

Warning: not tested at all.

Code:


$result = $db->sql_query('SELECT keyword,include_url FROM '.$prefix."_mywords WHERE keyword = '$search'");
while ($row = $db->sql_fetchrow($result))
{
   $url = $row['include_url'];

   if (isset($url) && $url != '')
   {
      include 'modules/MyWords/' . $url;
   }
}
 
View user's profile Send private message
hinksta







PostPosted: Tue Dec 12, 2006 2:13 pm Reply with quote

Perfect, thank you.
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> PHP

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©