Jump to content

[SOLVED] While / Array Question


JSHINER

Recommended Posts

<?php
$array = "SELECT id FROM table_b";
$array = mysql_query($array) or die("Error: " . mysql_error());  
$array = mysql_fetch_array($array);


    while($row = mysql_fetch_array($result)){

}
?>

 

The $array returns results such as 01, 02, 03 etc and the $row has table.id with numbers that MAY match 01,02,03 etc. How can I get an if statement in the while loop that only displays something if the table.id DOES NOT match the table_b.id result in the $array.

Link to comment
https://forums.phpfreaks.com/topic/135520-solved-while-array-question/
Share on other sites

The solution would be in your SQL:

 

SELECT table_b.id FROM table_b, table
WHERE table_b.id != table.id

 

I've not tested that but looks kinda right!

 

I'd suggest tidying up your code, what you supplied barely makes sense. Also I'd avoid using predefined names for tables such as "table" and "$array" for arrays... Try to avoid reusing your variables like that as well, just confusing!

 

Adam

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.