Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
code to display only certain things from mysql
Old 11-12-2009, 02:32 PM code to display only certain things from mysql
bswinnerton's Avatar
Skilled Talker

Posts: 57
Location: Montville, CT
Trades: 0
Hey everyone,

I'm new to the forum (as well as php), and I'm looking for a bit of help on a blog-like solution I'm trying to build up. On my front page I have three columns (technology, music, and movies) and I would like to have the php pull the content out of the mysql database and display it on my website.. Which I've been able to successfully do.

However I have a field in my mysql database called disclude_categories which is numeric and what I would like to have is when it is set to 1 it doesn't show up on my front page. I thought that maybe I could include it on my while loop, but can't seem to get it to work.

Here's the code that I have so far:

Code:
mysql_connect($host,$user,$pass) or die("ERROR:".mysql_error());
mysql_select_db($database) or die("ERROR DB:".mysql_error());
$query = "select * from blog WHERE categories='Technology' ORDER BY date DESC";
$result = mysql_query($query) or die(mysql_error());
while ($row = mysql_fetch_assoc($result)) {         
            echo $row['content'];                                                                        }
bswinnerton is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 11-12-2009, 02:38 PM Re: code to display only certain things from mysql
orionoreo's Avatar
Ultra Talker

Posts: 335
Name: Jerry
Trades: 0
like

PHP Code:
$query "select * from blog WHERE categories='Technology' AND disclude_categories!='1' ORDER BY date DESC"
?? this doesn't even pull the row out if its set to 1
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
orionoreo is offline
Reply With Quote
View Public Profile
 
Old 11-12-2009, 02:40 PM Re: code to display only certain things from mysql
bswinnerton's Avatar
Skilled Talker

Posts: 57
Location: Montville, CT
Trades: 0
Not too sure what you mean by "?? this doesn't even pull the row out if its set to 1" but that worked perfectly.

Thank you
bswinnerton is offline
Reply With Quote
View Public Profile
 
Old 11-12-2009, 02:49 PM Re: code to display only certain things from mysql
orionoreo's Avatar
Ultra Talker

Posts: 335
Name: Jerry
Trades: 0
i just wasn't sure if you wanted to use the data is any other ways... the method above excludes all of the ones set to 1...

its the proper way so glad it works for you
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
orionoreo is offline
Reply With Quote
View Public Profile
 
Old 11-12-2009, 04:31 PM Re: code to display only certain things from mysql
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,519
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
disclude_categories!='1' would be searching for a STRING value NOT a numeric value
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 11-12-2009, 04:48 PM Re: code to display only certain things from mysql
bswinnerton's Avatar
Skilled Talker

Posts: 57
Location: Montville, CT
Trades: 0
I don't plan on using the data in any other way (at least on this page). But thank you for looking out for that.

Quote:
Originally Posted by chrishirst View Post
disclude_categories!='1' would be searching for a STRING value NOT a numeric value
what would be searching for a numerical value? Using quotation marks instead?
bswinnerton is offline
Reply With Quote
View Public Profile
 
Old 11-12-2009, 04:58 PM Re: code to display only certain things from mysql
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,519
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
using nothing around the value
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 11-12-2009, 05:11 PM Re: code to display only certain things from mysql
bswinnerton's Avatar
Skilled Talker

Posts: 57
Location: Montville, CT
Trades: 0
Ohhhh, that makes sense now that I think about it. I'll change it.
bswinnerton is offline
Reply With Quote
View Public Profile
 
Old 11-12-2009, 09:42 PM Re: code to display only certain things from mysql
orionoreo's Avatar
Ultra Talker

Posts: 335
Name: Jerry
Trades: 0
Quote:
Originally Posted by chrishirst View Post
disclude_categories!='1' would be searching for a STRING value NOT a numeric value

my apologies so disclude_categories!=1
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
orionoreo is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to code to display only certain things from mysql
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

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





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.28484 seconds with 12 queries