GIDForums  

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 27-Sep-2003, 16:01
misunderstood misunderstood is offline
Member
 
Join Date: Jun 2003
Posts: 121
misunderstood is on a distinguished road

php recall


Heres another problem that may be impossible

PHP Code:

elseif((($opt=="a")&&($id)) or ($opt=="b")){             print(" 



can I print dependant on the results?

ie if id is odd print this
if id is even print that

If you understand what I am trying to do you must be psychic

If it is possible How do I do it?
Last edited by Allowee : 28-Sep-2003 at 07:59.
  #2  
Old 28-Sep-2003, 08:11
Allowee's Avatar
Allowee Allowee is offline
Regular Member
 
Join Date: May 2003
Location: The Netherlands
Posts: 339
Allowee has a spectacular aura about
I did a little fix with the PHP bbcode..

I've seen some the code you want in some user note on php.net.

But i can't find it now...

I think google must be used for this

When I find it, I'll post it
__________________
Pastebin
PHP Documentation Site
Allowee's Blog http://allowee.net
  #3  
Old 28-Sep-2003, 14:07
misunderstood misunderstood is offline
Member
 
Join Date: Jun 2003
Posts: 121
misunderstood is on a distinguished road
Thanks Allowee this is a great cause of frustration at the moment
I know what I want but getting it is another matter. ??:
  #4  
Old 28-Sep-2003, 17:41
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough

Re: php recall


Quote:
Originally posted by misunderstood
...If you understand what I am trying to do you must be psychic

Sorry, I am not psychic I didn't understand your question... the solution may not be as simple as this but I thought I'd give it a shot:
PHP Code:

<?php

elseif( (($opt=="a")&&($id)) or ($opt=="b") )
{
  $prt_str = ( $id%2 ? 'is Odd' : 'is Even' );
  echo $prt_str ;
}

?>

  #5  
Old 29-Sep-2003, 03:30
misunderstood misunderstood is offline
Member
 
Join Date: Jun 2003
Posts: 121
misunderstood is on a distinguished road
sorry for being so vague:-?
I want to search a table that stores player stats. The details of the players are similar but the points are worked out on there position. ie Goalie or Striker
What I want to do is if a player whos position is Goalie is called by the select menu rather than printing all the columns in the row it just prints the relevant columns that I want displayed. Alternatively if Striker is selected the relevant columns are printed for that position.
At the moment on the selection of either position all the columns are displayed for both position. This can be a little confusing for the viewer. ??:
Is that clear as mud now?
  #6  
Old 29-Sep-2003, 03:53
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough
Unfortunately your 'clear as mud' explanation made it even worse, if before I thought I understood, now I am certain I don't!

Perhaps if you try to explain what you're trying to with some pseudocode that might help.
  #7  
Old 29-Sep-2003, 04:11
misunderstood misunderstood is offline
Member
 
Join Date: Jun 2003
Posts: 121
misunderstood is on a distinguished road
OK deep breath..... and here we go

PHP Code:

if ($opt=="teamplayerstats")
                    {
                    $stats = mysql("$db","SELECT * FROM players,stats,actplayers WHERE players.team = '$id' and players.id=actplayers.id and actplayers.active='1' and stats.season='$se' and stats.playerid=players.id");                
                    }
                else
                    {
                    $sql="SELECT * FROM players,stats,actplayers,teams WHERE players.position = '$position' and players.id=actplayers.id and actplayers.active='1' and stats.season='$se' and stats.playerid=players.id and players.team=teams.id and teams.division='$divname'";
$stats = mysql("$db",$sql);                
                    }
//$stats = mysql("$db","SELECT * FROM players,stats WHERE stats.playerid=players.id");                
$totalplayers=mysql_numrows($stats);
$j=0;
while($j < $totalplayers) 
{
$hname = mysql_result($stats,$j,"name");
$hid = mysql_result($stats,$j,"id");
$position = mysql_result($stats,$j,"position");
$manofthematch = mysql_result($stats,$j,"manofthematch");
$games = mysql_result($stats,$j,"games");
etc 
etc 




OK now if position Goalie is selected how do I get for example just games and manofthematch to print and if Striker is selected just name, position and id to print?

Or is it impossible without extensive rewritting, a bottle of jack daniels and wall to bang my head against?

Hope this as cleared the mud a little or have I now turned the light off as well?
  #8  
Old 29-Sep-2003, 04:31
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough
Actually I am still lost... but based on your last few sentences (inside your last post), I think you should think about something like this; just so you keep your code clean, clear and easier to manage:

You're trying to do 2 things based on different selects? So, I assume this is off a form? Try incorporating a 'hub' function (for lack of a better term); let's say we name it : process_player()
PHP Code:

<?php

function process_player()
{
  switch( $_POST['position'] ) // 'goalie' or 'striker'
  {
    case 'striker' :
      $html = do_striker_stuff(); // do specific stuff for this player in a custom function
      break;
    case 'goalie' :
      $html = do_goalie_stuff();  // do specific stuff for this player in a custom function
      break;
  }
  return( $html );
}

// the script now may look something like this:

if( isset($_POST['position']) )
{
  echo process_player();
}
?>

  #9  
Old 29-Sep-2003, 04:46
misunderstood misunderstood is offline
Member
 
Join Date: Jun 2003
Posts: 121
misunderstood is on a distinguished road
(screwing top onto bottle of jack daniels and removing head from wall) That looks like what I want to do.
I will give it a go and see how long it takes before the top comes off again.
Thanks JdS
  #10  
Old 29-Sep-2003, 12:38
misunderstood misunderstood is offline
Member
 
Join Date: Jun 2003
Posts: 121
misunderstood is on a distinguished road
Couldnt get it to work using the methos you suggested

BUT

Got it to work using

PHP Code:

{if ($position==Offensive){print(" <table 


etc for each position.
but my code is now really messy ??: but who cares as long as I know what it is doing

Now for the next problem
I want to limit my calculations
PHP Code:

if ($games)
{$pperg=$points/$games;
$gaa=$goals/$games;} 




how do I limit the number of decimal places and get it to round up or down? Sorry to ask so many questions but I always seem to get so far and then hit a full stop or the wall again
 

Recent GIDBlogPrepping for deployment by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Optimizing your web server with Turck MMCache for PHP JdS Web Hosting Forum 2 07-Jan-2004 07:48
apache2 - php cgi fehler - schleife inna Apache Web Server Forum 8 27-Nov-2003 09:55
Automate a data change php form mjfmn MySQL / PHP Forum 4 20-Oct-2003 09:37
[Linux] Installing PHP --with-mcrypt JdS Web Hosting Forum 0 20-Aug-2003 08:40
All the big PHP script collections that matter jrobbio MySQL / PHP Forum 5 06-Jun-2003 16:14

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 23:03.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.