472,958 Members | 2,047 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,958 software developers and data experts.

If/else statements - help.

Sorry to post so much code all at once but I'm banging my head against
the wall trying to get this to work!

Does anyone have any idea where I'm going wrong?

Thanks in advance and sorry again for adding so much code...
<TABLE border="1" bordercolor="#000000" cellspacing="0">
<TR>
<TD>

<?php

include("misc.inc");

$connection = mysql_connect($host,$user,$password)
or die ("Couldn't connect to the server");

$db = mysql_select_db($database,$connection)
or die ("Couldn't select the database");
/* based upon the selection from the drop-down list, select the
player's basic details and format his
birthdate to the english format */

$query = "SELECT *, DATE_FORMAT(birthdate, '%d/%m/%y') AS birth FROM
player WHERE playerid='{$_POST['interest']}'";
$result = mysql_query($query)
or die ("Couldn't execute query");

$row = mysql_fetch_array($result);
/* again, based upon the selection from the drop-down list, select
all the player's historical details from
the playerhistory table ensuring the date joined is in the english
format */

$query2 = "SELECT *, DATE_FORMAT(joined, '%d/%m/%Y') AS joined FROM
playerhistory WHERE playerid='{$_POST['interest']}'";
$result2 = mysql_query($query2)
or die ("Couldn't execute query2");

$row2 = mysql_fetch_array($result2);

/* This selects all records from player appearances table and links
with playerhistory table

$query3 = "SELECT * FROM playerapps LEFT JOIN playerhistory ON
playerapps.playerhistid = playerhistory.playerhistid";
$result3 = mysql_query($query3)
or die ("Couldn't execute query3");

$rows3 = mysql_fetch_array($result3);
$nrows3 = mysql_num_rows($result3);
/* display the results in a table */

print "<TABLE border='1' bordercolor='#000000' width='800'
class='table'>\n";

print "<tr valign='top'>\n";
printf ("<td width='90'><b>%s</b>\n",$row['forename']);
printf ("<b>%s</b></td>\n",$row["surname"]);
print "<td width='70'></td>\n";
print "<td width='70'></td>\n";
print "<td width='70'></td>\n";
print "<td width='70'></td>\n";
print "<td width='70'></td>\n";
print "<td width='70'></td>\n";
print "</tr>\n";

print "<tr>\n";
print "<td>BIRTHDATE:</td>\n";
printf ("<td>%s</td>\n",$row["birth"]);
print "</tr>\n";

print "<tr>\n";
print "<td>BIRTHPLACE:</td>\n";
printf ("<td>%s</td>\n",$row['birthplace']);
print "</tr>\n";

print "<tr>\n";
print "<td>NATIONALITY:</td>\n";
printf ("<td>%s</td>\n",$row['nationality']);
print "<tr>\n";

print "<tr>\n";
print "<td>POSITION:</td>\n";
printf ("<td>%s</td>\n",$row['position']);
print "</tr>\n";
print "</TABLE>\n";

print "<TABLE border='1' bordercolor='#000000' width='700'
class='table'>\n";
print "<tr align='center' class='heading'>\n";
print "<td bgcolor='#000066' width='70'>JOINED</td>\n";
print "<td bgcolor='#000066' width='70'>FROM</td>\n";
print "<td bgcolor='#000066' width='70'>TO</td>\n";
print "<td bgcolor='#000066' width='70'>VALUE</td>\n";

print "<td bgcolor='#000066' width='70'>FULL APPS</td>\n";
print "<td bgcolor='#000066' width='70'>SUB APPS</td>\n";
print "<td bgcolor='#000066' width='70'>GOALS</td>\n";
print "<td bgcolor='#000066' width='70'>RED CARDS</td>\n";
print "<td bgcolor='#000066' width='70'>YELLOW CARDS</td>\n";
print "</tr>\n";

while ($rows3 = mysql_fetch_array($result3))

{

print "<tr align='center'>\n";
printf ("<td width='70'>%s</td>\n",$row2['joined']);
printf ("<td width='70'>%s</td>\n",$row2['goals']);
printf ("<td width='70'>%s</td>\n",$row2['toclub']);
printf ("<td width='70'>%s</td>\n",$row2['boughtfor']);
print "</tr>\n";

if ($nrows3 == 1)

{
printf ("<td width='70'>%s</td>\n",$rows3['apps']);
printf ("<td width='70'>%s</td>\n",$rows3['subapps']);
printf ("<td width='70'>%s</td>\n",$rows3['goals']);
printf ("<td width='70'>%s</td>\n",$rows3['redcards']);
printf ("<td width='70'>%s</td>\n",$rows3['yellowcards']);
print "</tr>\n";
}
else
{
while ($rows3 = mysql_fetch_array($result3))
{
printf ("<td width='70'>%s</td>\n",$rows3['apps']);
printf ("<td width='70'>%s</td>\n",$rows3['subapps']);
printf ("<td width='70'>%s</td>\n",$rows3['goals']);
printf ("<td width='70'>%s</td>\n",$rows3['redcards']);
printf ("<td width='70'>%s</td>\n",$rows3['yellowcards']);
print "</tr>\n";
print "<tr>\n";
print "<td></td>\n";
print "<td></td>\n";
print "<td></td>\n";
print "<td></td>\n";
}

}

}

print "</TABLE>\n";
?>

</TD>
</TR>
</TABLE>
Jul 16 '05 #1
1 4018
On 28 Jun 2003 06:24:13 -0700, hs****@hotmail.com (Chris) wrote:
Sorry to post so much code all at once but I'm banging my head against
the wall trying to get this to work!

Does anyone have any idea where I'm going wrong?

Thanks in advance and sorry again for adding so much code...
This not a good way to ask a question - you've sent 160 lines of code, but
you've not said anything about:

- What's going wrong
- What errors you get, if any
- What output you get, if any
- What you were expecting
- What you've tried to fix the code
- And you haven't tried to cut down the code to the minimum required to show
your (unstated) problem.

The only clue is in your subject line, that it's something to do with an
if/else.

[big snip]
$query3 = "SELECT * FROM playerapps LEFT JOIN playerhistory ON
playerapps.playerhistid = playerhistory.playerhistid";
$result3 = mysql_query($query3)
or die ("Couldn't execute query3");

$rows3 = mysql_fetch_array($result3);
$nrows3 = mysql_num_rows($result3);
[another big snip]
while ($rows3 = mysql_fetch_array($result3))
You've fetched one row from $result3 here.

[snip]
if ($nrows3 == 1)
If there is one row then...
{ [snip print of $rows3]

You print this row.
}
else
{
while ($rows3 = mysql_fetch_array($result3))
Else, you start a loop by fetching another row - but you've not yet printed
out the $row3 you fetched the first time you fetched from $result3 above, so
you've lost that row now.
{ [snip print of $rows3] }

}

}


[another snip]

So you're missing some data, but is that the problem you were asking about?
You've not said what you wanted, so no idea if that's what's missing.

--
Andy Hassall (an**@andyh.co.uk) icq(5747695) (http://www.andyh.co.uk)
Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)
Jul 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: dmbkiwi | last post by:
I am new to this group, and relatively new to python programming, however, have encountered a problem I just cannot solve through reading the documentation, and searching this group on google. I...
33
by: Diez B. Roggisch | last post by:
Hi, today I rummaged through the language spec to see whats in the for ... else: for me. I was sort of disappointed to learn that the else clauses simply gets executed after the loop-body -...
6
by: Bart Nessux | last post by:
Should an if statement have a corresponding else statement? Or, is it OK to have an if statement by itself. For completeness, it seems the two should be together, but from experience I know that a...
3
by: Patrice | last post by:
Hi, I need to do multi-conditional statements like below, but this error is displayed : Expected 'End' /myFilepath, line x else response.write(arrCorpo(sparam,sdiv)) end if I don't...
3
by: Amy | last post by:
Hi, I have 6 If Then Else statements I was supposed to write. I did so but I know that they have to be wrong because they all look the same. Could someone take a look at them and point me in the...
4
by: Brie_Manakul | last post by:
I need to set up an if else to show different weather scripts based on the city selection they choose. Any help on this would be great. Thanks! <%@ page language="java" import="java.util.*,...
32
by: cj | last post by:
Another wish of mine. I wish there was a way in the Try Catch structure to say if there wasn't an error to do something. Like an else statement. Try Catch Else Finally. Also because I...
5
by: sam_cit | last post by:
Hi Everyone, I read somewhere that there are some compile time operations behind switch-case, which is why it can work for cases which evaluates to an integer or character and not strings and...
2
by: pradeep.thekkottil | last post by:
I'm setting up an auction website using PHP and MySQL. There in the section where logged in members can put up new auction in a form, I want to run a form validation where I used if else statements...
23
by: bearophileHUGS | last post by:
So far in Python I've almost hated the 'else' of the 'for' loops: - I have problems to remember its meaning; - It gives me little problems when I later want to translate Python code to other...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...

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.