• Howdy! Welcome to our community of more than 130.000 members devoted to web hosting. This is a great place to get special offers from web hosts and post your own requests or ads. To start posting sign up here. Cheers! /Peo, FreeWebSpace.net
managed wordpress hosting

[PHP]Confusing Question

dawizman

New Member
OK, first I'll post a part of the script I am writing:

PHP:
include("./data/db_info.php");
mysql_connect($host, $user, $pass);
mysql_select_db($db);
$processor = mysql_query("SELECT * FROM processor WHERE processor.platform = '$platform' ORDER BY name ASC");
$processor_no_display= "blah blah blah"
while ($row = mysql_fetcharray($processor) && $row['field'] <> $processor_no_display)
{
echo $row['field'] \n;
}

Now my question is, would that show all the values of $row['field] minus the one that has the same value as $processor_no_display or would that just display nothing at all?
 
firstoff, it's mysql_fetch_array :p

i don't think it will work because you should use != ( not equal ) and not <> ( mysql syntax )

and here's another way ( via mysql query )

PHP:
include("./data/db_info.php");
mysql_connect($host, $user, $pass);
mysql_select_db($db);
$processor_no_display= "blah blah blah";
$processor = mysql_query("SELECT * FROM processor WHERE processor.platform = '$platform' AND field<>'$processor_no_display' ORDER BY name ASC");
while ($row = mysql_fetch_array($processor))
{
echo $row['field']."\n";
}
 
Thanks, but I would rather have the query grab all the columns and just not display the ones that have the same value as $processor_no_display. Anyway, the nice people at [H]ardforums helped me out to get this:




PHP:
include("./data/db_info.php");
mysql_connect($host, $user, $pass);
mysql_select_db($db);
$processor = mysql_query("SELECT * FROM processor WHERE processor.platform = '$platform' ORDER BY name ASC");
$processor_no_display= "blah blah blah";
while ($row = mysql_fetch_array($processor) )
{
  if( $row['field'] <> $processor_no_display ) {
    echo $row['field'];
  }
}
 
Back
Top