Jump to content

Recommended Posts

And if a JOIN isn't possible, just use two loops.

 

One loop doing twice the work as two won't save you much processing power. Just a little bit of code. This snippet from the php.net website even dumps the result into an array in a single line.

 

Daniel Chcouri - 333222 +A-T+ gmail 02-Apr-2009 11:45

Fetching all the results to array with one liner:

<?php 
$result = mysql_query(...); 
while(($resultArray[] = mysql_fetch_assoc($result)) || array_pop($resultArray)); 
?>

Thanks for the suggestions. As being fairly new to this I'm getting more and more confused lol. I'll see if I can make some of this work, otherwise I'll reply with the code I have so it is more clear what I am trying to achieve (there's usually a simple answer to my questions) :)

After a look at this, I simply have no idea what to do with it  :wtf:

 

So here are some more info; I am trying to list some events by date. My problem is listing 2 events happening the same day where a "variable" can be 2 things.

 

teamwartable.png

 

As picture above shows team with id "21" is both attacker and defender on same date. (disregards war_ended date)

 

When showing the events, It should show the date, the defending team name if any, and the attacking team if any.

 

my query right now is:

$sql_getevent = "SELECT DATE(war_started) AS war_started, attacker_name, defender_name, won, lost FROM teamwar_info 
WHERE attacker=".$_GET['t']."
ORDER BY DATE(war_started) DESC ";
$rs_getevent = mysql_query($sql_getevent);

 

This will show the date the right team name of the team being attacked.

The next column should show the team name of the team ATTACKING (on picture it should be "Black Beards Crew" as this team is attacking the team with id 21.

 

Using above picture: Assume our team has id 21. The event list should show date: 2011-5-10, attacking (the team WE attack): Jack Sparrow, the team attacking US: Black Beards Crew.

 

How can I do this?

 

(I am sure this is confusing, so please ask and I'll try to further explain.)

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.