473,513 Members | 2,595 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

array needed to compare to other values

15 New Member
$row = mysql_fetch_array(mysql_query("SELECT enemies FROM $tab[crew] WHERE id='$cid'"));
$array = explode (",", $row[0]);

$crewupdate = mysql_query("SELECT id,name,founder FROM $tab[crew] WHERE id>0 AND id!=$array[] ORDER BY name ASC;");




This doesn't yeild anyresults since you cant use '[]' in query, however i have tried just the name but that doesnt work, when i try [0] it only uses the first array space to compare not the others

when i print the array after explode I get this

Array ( [0] => 8 [1] => 2 [2] => 14 [3] => 10 )

Basically I want to desplay all the information of the crews that are not 'enemies'

i know php fairly well but im not to familiar with more advance query formats
Mar 30 '07 #1
6 1739
mdburton
15 New Member
help = ( (10characters))
Mar 31 '07 #2
devsusen
136 New Member
hi,

you need to run the 2nd query within a for loop and and you need to pass the loop counter in the query as -
Expand|Select|Wrap|Line Numbers
  1. $crewupdate = mysql_query("SELECT id,name,founder FROM $tab[crew] WHERE id>0 AND id!=$array[$counter] ORDER BY name ASC;");
susen
Mar 31 '07 #3
mdburton
15 New Member
ok ill try that out later today lol

hopefully i can get it working otherwise if anyone else can explain this in more details go ahead otherwise i think i understand what susen said
Mar 31 '07 #4
mdburton
15 New Member
i couldnt get what i thought you said lol

<td id="crewList">
<div><b>Crews </b></div><select name="crew_idz" id="crew_id" size="10" width="20">
<?
$row = mysql_fetch_array(mysql_query("SELECT enemies FROM $tab[crew] WHERE id='$cid'"));
$row['array'] = $row[0];
$array = explode (",", $row[0]);
$sizeof= count($array);
for($counter = 0; $counter< $sizeof; $counter++){
$crewupdate = mysql_query("SELECT id,name,founder FROM $tab[crew] WHERE id>0 AND id!=$array[$counter] ORDER BY name ASC;");
}
//$crewupdate = mysql_query("SELECT id,name,founder,city,icon,networth,members,rank,wo rth,crewthug,crewmoney FROM $tab[crew] WHERE id>0 AND id!=explode(",", $row[0]) ORDER BY name ASC;");
while ($t10 = mysql_fetch_array($crewupdate))
{?><option value="<?=$t10[0]?>"><?=$t10[1]?></option>

<?}?></select>
</td>


I want it to display all the ones that arent enemies, but it doesnt work

ill do more edits later tonight to see if i can do it myself but if anyone has a clue = )
Apr 2 '07 #5
mdburton
15 New Member
alright well i got it to work but i think the coding is horrible lol

also some of the code might not be needed persay lol i used most of it for troubleshooting

<td id="organizationList">
<div><b>Crews <?=$array[6]?></b></div><select name="crew_idz" id="crew_id" size="10" width="20">
<?
$row = mysql_fetch_array(mysql_query("SELECT enemies FROM $tab[crew] WHERE id='$cid'"));
$row['array'] = $row[0];
$array = explode (",", $row[0]);
$sizeof= count($array);
$sizeof2= count($array);
$all= mysql_query("SELECT count(*) FROM $tab[crew]");
$total = mysql_result($all, 0, 0);
$sizeof= $sizeof;
$sizeof = $total-$sizeof;

$counterplus= $counter+1;

$crewupdate = mysql_query("SELECT id,name,founder FROM $tab[crew] WHERE id!='$cid' ORDER BY name;");


while ($t10 = mysql_fetch_array($crewupdate))
{
//$t10 = mysql_fetch_array($crewupdate);
$error=0;
for($counter2 = 0; $counter2< $total;$counter2++){
if($array[$counter2] == $t10[0]){
$error=1;
}
}
if($error==0){
?>

<option value="<?=$t10[0]?>"><?=$t10[1]?></option>

<?

}
}?></select>
</td>
<td id="enemyList">
<div><b>Enemies</b></div><select id="enemy_id" size="10">
<?
$sizeof= count($array);

for($counter = 0; $counter< $sizeof; $counter++){
$crewupdate = mysql_query("SELECT id,name,founder FROM $tab[crew] WHERE id>0 AND id=$array[$counter] ORDER BY name ASC;");
while ($t10 = mysql_fetch_array($crewupdate))
{?><option value="<?=$t10[0]?>"><?=$t10[1]?></option>
<?}}?></select>
</td>
Apr 3 '07 #6
gypsygal
1 New Member
$row = mysql_fetch_array(mysql_query("SELECT enemies FROM $tab[crew] WHERE id='$cid'"));
$array = explode (",", $row[0]);

$crewupdate = mysql_query("SELECT id,name,founder FROM $tab[crew] WHERE id>0 AND id!=$array[] ORDER BY name ASC;");

hmm..i m not sure if this is wat u want, but i think u might not need to create an array to compare.

if ur id in first query is equal to the enemies in second query.


SELECT id,name,founder FROM $tab[crew] WHERE id>0 AND id NOT IN (SELECT enemies FROM $tab[crew] WHERE id='$cid')
ORDER BY name ASC;
Apr 6 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

16
41742
by: herbertF | last post by:
Hi guys, In a program (not my own) I encountered the declaration of a constant pointer to an array consisting of two other const pointers to arrays. Not quite sure why they do it so complicated,...
67
4391
by: Ike Naar | last post by:
Hi, Asking your advice on the following subject: Suppose I want to find out whether a given pointer (say, p) of type *T points to an element of a given array (say, a) of type T. A way to...
23
2686
by: Leon Brodskiy | last post by:
Hi, Could please anyone clarify about pointer and array in C? If I have: int arr; The following two commands will be the same: arr and &arr.
18
2427
by: bsder | last post by:
Hi, Can anyone please tell me how to calculate the size of the following 4-dimensional array, and now to use qsort for sorting on this array? double sp = { 4.0, 5.0, 6.0 }; double spa = { {...
28
2416
by: anonymous | last post by:
I have couple of questions related to array addresses. As they belong to the same block, I am putting them here in one single post. I hope nobody minds: char array; int address; Questions...
30
2900
by: josh | last post by:
Hi all, what does it meaning that strange sintax (look at the object :) ? if I have i.e. array.length I can use array. and is it IE/Firefox compatible??
15
1718
by: DL | last post by:
say, we have the following: // declare an array myArray = ; // short hand? same as myArray = new Array ? // populate it myArray = 0; myArray = 0; myArray = 1; myArray = 0;
17
2296
by: Ben Bacarisse | last post by:
candide <toto@free.frwrites: These two statements are very different. The first one is just wrong and I am pretty sure you did not mean to suggest that. There is no object in C that is the...
6
1701
by: The Natural Philosopher | last post by:
I am trying to create what amounts to an array of 'structures'. I.e. I want to dynamically add to and access an object as myobject.anothernumber // actually represents a nesting level. and ...
0
7260
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7384
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7099
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
5086
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4746
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3222
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1594
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
799
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
456
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.