TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 06-30-2008, 01:54 PM   #1 (permalink)
Super Moderator
Inquisitive 
 
codefreek's Avatar
 
Join Date: Sep 2007
Location: Near you.
Posts: 791
Thanks: 241
codefreek is on a distinguished road
Help I need of some help here

Sorry i misspell the topic name xD

Is the problem in this script
that i am not calling out the news part
with
PHP Code:
while($website_row mysql_fetch_array($web_result))
{
print 
$website_row['rest'];

? or something else it just wont work :S

It is suposed to switch around to news cat 1 news cat 2
so all the post with cat id 1 gets that in cat 1 etc..

it worked with my links but not on this so whats
wrong ??..

Thank you in advance




PHP Code:
<?php
include('db_connect.php');
$webq "select id, name, des from news ";
if(isset(
$_GET['cat']))
 {
   
$webq .= sprintf("where cat_id = '%s'"mysql_real_escape_string($_GET['cat']));
 }
 
$web_result mysql_query($webq);
 if(!
cat_result)
{
echo 
mysql_error();
}
$catq "select id, name from cat";
$cat_result mysql_query($catq);
 
?>
 
<?php
while($cat_row mysql_fetch_array($cat_result))
{
?>
<a href="test.php?cat=<?php echo $cat_row['id'];?>"><?php echo $cat_row['name'];?></a>
<?php
}
?>




My cat table,

Code:
CREATE TABLE `cat` (
  `id` int(11) NOT NULL auto_increment,
  `name` varchar(100) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;

--
-- Data in table `cat`
--

INSERT INTO `cat` (`id`, `name`) VALUES
(1, 'news one'),
(2, 'news two');


my news table

Code:
CREATE TABLE `news` (
  `id` int(11) NOT NULL auto_increment,
  `name` varchar(100) NOT NULL,
  `des` varchar(150) NOT NULL,
  `rest` text NOT NULL,
  `tim` date NOT NULL,
  `valid` int(11) NOT NULL,
  `users_id` int(11) NOT NULL,
  `cat_id` int(11) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=7 ;

--
-- Data in table `news`
--

INSERT INTO `news` (`id`, `name`, `des`, `rest`, `tim`, `valid`, `users_id`, `cat_id`) VALUES
(1, 'lol', 'omg this is the edit title', '<p>Lorem ipsum dolor sit amet beatae iste aperiam vitae magni aperiam omnis omnis, doloremque ut odit illo aperiam inventore inventore illo natus unde voluptas consequuntur aperiam sunt dicta iste dolores eos aspernatur aspernatur, perspiciatis dicta aut sit </p>\r\n<p>Lorem ipsum dolor sit amet beatae iste aperiam vitae magni aperiam omnis omnis, doloremque ut odit illo aperiam inventore inventore illo natus unde voluptas consequuntur aperiam sunt dicta iste dolores eos aspernatur aspernatur, perspiciatis dicta aut sit </p>\r\n<p>Lorem ipsum dolor sit amet beatae iste aperiam vitae magni aperiam omnis omnis, doloremque ut odit illo aperiam inventore inventore illo natus unde voluptas consequuntur aperiam sunt dicta iste dolores eos aspernatur aspernatur, perspiciatis dicta aut sit </p>', '2008-06-22', 1, 0, 1),
(5, 'admin', 'hello', '<p>Lorem ipsum dolor sit amet beatae iste aperiam vitae magni aperiam omnis omnis, doloremque ut odit illo aperiam inventore inventore illo natus unde voluptas consequuntur aperiam sunt dicta iste dolores eos aspernatur aspernatur, perspiciatis dicta aut sit </p>\r\n<p>Lorem ipsum dolor sit amet beatae iste aperiam vitae magni aperiam omnis omnis, doloremque ut odit illo aperiam inventore inventore illo natus unde voluptas consequuntur aperiam sunt dicta iste dolores eos aspernatur aspernatur, perspiciatis dicta aut sit </p>\r\n', '2008-06-22', 1, 0, 1),
(6, 'roland', 'hello sir', 'mertius del miro candiburia smorjamertius del miro candiburia smorjamertius del miro candiburia smorjamertius del miro candiburia smorjamertius del miro candiburia smorjamertius del miro candiburia smorjamertius del miro candiburia smorjamertius del miro candiburia smorjamertius del miro candiburia smorjamertius del miro candiburia smorjamertius del miro candiburia smorjamertius del miro candiburia smorjamertius del miro candiburia smorjamertius del miro candiburia smorjamertius del miro candiburia smorjamertius del miro candiburia smorjamertius del miro candiburia', '2008-06-28', 1, 0, 2);
my users table

Code:
CREATE TABLE `users` (
  `id` int(11) NOT NULL auto_increment,
  `username` varchar(30) NOT NULL,
  `password` varchar(40) NOT NULL,
  `email` text NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=16 ;

--
-- Data in table `users`
--

INSERT INTO `users` (`id`, `username`, `password`, `email`) VALUES
(1, 'user', 'password', 'lol@info.com'),
Thank you!
codefreek is offline  
Reply With Quote
 



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 05:19 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design