Forum 2

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Data
Forum Newbie
Posts: 15
Joined: Tue Jun 25, 2002 4:14 am
Location: Aberdeen, Scotland

Forum 2

Post by Data »

I print out my posts using a while statement.

Some posts however may have been deleted, although they are actually still there, just with a message that says they were deleted.
Each post has an edit and delete option.

However, I don't want this available for a post that has been deleted.

I tried this:

Code: Select all

while ($myrow = mysql_fetch_array( $threadresult )) 
{
if ( $myrowї'deleted'] = 1 )
{
//print posts that have been deleted, without the edit/delete option.
}
		
elseif ( $myrowї'deleted'] = 0)
{
//print posts that haven't been deleted, with the edit/delete option.		
}
}
This didn't work - it made all the posts be viewed without the edit option.

Is there any other way to do this?
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

You need two equals signs for if loop comparisons, try:

Code: Select all

while ($myrow = mysql_fetch_array( $threadresult )) { 
    if ( $myrowї'deleted'] == 1 ) { 
        //print posts that have been deleted, without the edit/delete option. 
    } elseif ( $myrowї'deleted'] == 0) { 
        //print posts that haven't been deleted, with the edit/delete option.       
    } 
}
Otherwise you just set the value of the variable to whatever it was you were trying to compare it against.

Mac
Data
Forum Newbie
Posts: 15
Joined: Tue Jun 25, 2002 4:14 am
Location: Aberdeen, Scotland

Post by Data »

Thankyou.

Works perfectly!
jason
Site Admin
Posts: 1767
Joined: Thu Apr 18, 2002 3:14 pm
Location: Montreal, CA
Contact:

Post by jason »

twigletmac: "if loop comparisons" hrm? Hehe..we now have an if loop?

/me being smart ass

:D
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

:P
Post Reply