$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
6 1739
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 - - $crewupdate = mysql_query("SELECT id,name,founder FROM $tab[crew] WHERE id>0 AND id!=$array[$counter] ORDER BY name ASC;");
susen
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
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 = )
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>
$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;
Sign in to post your reply or Sign up for a free account.
Similar topics |
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,...
|
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...
|
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.
|
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 = {
{...
|
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...
| |
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??
|
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;
|
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...
|
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
...
|
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,...
|
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,...
| |
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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 ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |