missed one record from mysql_fetch array...???

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

mahara
Forum Commoner
Posts: 37
Joined: Wed Nov 13, 2002 1:08 am
Location: Bandung, Jawa Barat, Indonesia

Post by mahara »

What about this one, $_POST["type"]?
User avatar
apek
Forum Commoner
Posts: 96
Joined: Tue Jan 06, 2004 11:19 pm
Location: Holiday Plaza Johor Bahru

Post by apek »

that one also...
it echoes the correct item..
but still no solution...
pls help... :(
mahara
Forum Commoner
Posts: 37
Joined: Wed Nov 13, 2002 1:08 am
Location: Bandung, Jawa Barat, Indonesia

Post by mahara »

Please try this.

I think you miss the equivalent of expression in the 'if ... else ...'. You should only use '==' or '===' instead of '=' when comparing expression. '=' is used to assign a value to a variable.

Code: Select all

if ( $_POST["type"] == "ALL" )
{
    $SQL = "Select * from komponen";
    echo $SQL . "<br/>\n";
    echo "Blok 'ALL' dieksekusi.<br/>\n";
    $result=query($SQL, $link, __LINE__, __FILE__); 
    //$senarai=mysql_fetch_array($result, MYSQL_ASSOC); 
} 
elseif ( $_POST["type"] == "KATEGORI" )
{ 
    $SQL = "Select * from komponen where kategori = '$kategori'";
    echo $SQL . "<br/>\n";
    echo "Blok 'KATEGORI' dieksekusi.<br/>\n";
    $result=query($SQL, $link, __LINE__, __FILE__); 
    //$senarai=mysql_fetch_array($result, MYSQL_ASSOC); 
} 
elseif ($_POST["type"] == "KOMPONEN") 
{ 
    $SQL = "SELECT * FROM komponen where alat = '$alat'";
    echo $SQL . "<br/>\n";
    echo "Blok 'KOMPONEN' dieksekusi.<br/>\n";
    $result=query($SQL, $link, __LINE__, __FILE__); 
    //$senarai=mysql_fetch_array($result, MYSQL_ASSOC); 
}
According to your previous code, only the first if block is executed.

Hope helps.
User avatar
apek
Forum Commoner
Posts: 96
Joined: Tue Jan 06, 2004 11:19 pm
Location: Holiday Plaza Johor Bahru

Post by apek »

hmmm...
this is good...

it really shows me something...
whatever i choose...it always execut only this:

Code: Select all

if ( $_POST["type"] == "ALL" )
{
    $SQL = "Select * from komponen";
    echo $SQL . "<br/>\n";
    echo "Blok 'ALL' dieksekusi.<br/>\n";
    $result=query($SQL, $link, __LINE__, __FILE__);
    //$senarai=mysql_fetch_array($result, MYSQL_ASSOC);
}
why???
the $_POST["type"] is correct....
mahara
Forum Commoner
Posts: 37
Joined: Wed Nov 13, 2002 1:08 am
Location: Bandung, Jawa Barat, Indonesia

Post by mahara »

Well, now it's getting closer...
The only thing I want to know is "does the variable $_POST["type"] always returns value 'ALL'? Can it return other value except 'ALL'?".
Note that you should be aware to case-sensitivity in comparing expression of string.

Code: Select all

<?php
if ( strtoupper($_POST["type"]) == "ALL" ) 
{ 
    $SQL = "Select * from komponen"; 
    echo $SQL . "<br/>\n"; 
    echo "Blok 'ALL' dieksekusi.<br/>\n"; 
    $result=query($SQL, $link, __LINE__, __FILE__); 
    //$senarai=mysql_fetch_array($result, MYSQL_ASSOC); 
}
?>
User avatar
apek
Forum Commoner
Posts: 96
Joined: Tue Jan 06, 2004 11:19 pm
Location: Holiday Plaza Johor Bahru

Post by apek »

gee...it works!!!!!!!!!!
thanx a bunch!!
Post Reply