Jump to content

making a report page...


ardyandkari

Recommended Posts

hello again...

 

i have a problem,

i need to make a page that will add up all of our sales people in a state...

 

i have written the following:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>

<body>
<?php 
$hostname="blah";
$username="blah";
$password="blah";
$dbname="blah";


mysql_connect($hostname,$username, $password) OR DIE ("Unable to connect to database! Please try again later.");
mysql_select_db($dbname);
?>
<?php 
$state=$_POST['state']
$query="SELECT * FROM salespeople where 'state'='{$state}'";

echo $query?>


<form name="statereport" method="post" action="report.php">
  <p>Select a state:</p>
  <p>
    <select name="state" size="1" id="state">
      <option value="AK">Alaska</option>
<option value="AS">American Samoa</option>
<option value="AZ">Arizona</option>
<option value="AR">Arkansas</option>
<option value="CA">California</option>
<option value="CO">Colorado</option>
<option value="CT">Connecticut</option>
<option value="DE">Delaware</option>
<option value="DC">District Of Columbia</option>
<option value="FM">Fdr. States Of Micronesia</option>
<option value="FL">Florida</option>
<option value="GA">Georgia</option>
<option value="GU">Guam</option>
<option value="HI">Hawaii</option>
<option value="ID">Idaho</option>
<option value="IL">Illinois</option>
<option value="IN">Indiana</option>
<option value="IA">Iowa</option>
<option value="KS">Kansas</option>
<option value="KY">Kentucky</option>
<option value="LA">Louisiana</option>
<option value="ME">Maine</option>
<option value="MH">Marshall Islands</option>
<option value="MD">Maryland</option>
<option value="MA">Massachusetts</option>
<option value="MI">Michigan</option>
<option value="MN">Minnesota</option>
<option value="MS">Mississippi</option>
<option value="MO">Missouri</option>
<option value="MT">Montana</option>
<option value="NE">Nebraska</option>
<option value="NV">Nevada</option>
<option value="NH">New Hampshire</option>
<option value="NJ">New Jersey</option>
<option value="NM">New Mexico</option>
<option value="NY">New York</option>
<option value="NC">North Carolina</option>
<option value="ND">North Dakota</option>
<option value="MP">Northern Mariana Islands</option>
<option value="OH">Ohio</option>
<option value="OK">Oklahoma</option>
<option value="OR">Oregon</option>
<option value="PW">Palau</option>
<option value="PA">Pennsylvania</option>
<option value="PR">Puerto Rico</option>
<option value="RI">Rhode Island</option>
<option value="SC">South Carolina</option>
<option value="SD">South Dakota</option>
<option value="TN">Tennessee</option>
<option value="TX">Texas</option>
<option value="UT">Utah</option>
<option value="VT">Vermont</option>
<option value="VI">Virgin Islands</option>
<option value="VA">Virginia</option>
<option value="WA">Washington</option>
<option value="WV">West Virginia</option>
<option value="WI">Wisconsin</option>
<option value="WY">Wyoming</option>    
</select>
</p>
</form>
</body>
</html>

 

i know that this will not total anything, just trying to learn and write at the same time...

 

i get the following error:

Parse error: parse error, unexpected T_VARIABLE in /home/content/d/a/v/davidskuza/html/vsadmin/statereport.php on line 21

 

line 21 is this:

$query="SELECT * FROM salespeople where 'state'='{$state}'";

 

help please...

Link to comment
Share on other sites

$query="SELECT * FROM affiliates WHERE `affilState`='.$state.'";

 

Is there a column in your affiliates database named 'affilState'?  Using the query that you have here, you are looking in the database for for specified 'affiliates' that are stated in the column 'affilState'.  If the column is named State in your database then

$query = 'SELECT * FROM affiliates WHERE state = '.$state.'';

Link to comment
Share on other sites

could this be from having the code on the same page as the form???

 

Well since you put it that way, I would think so.  The information you want would need to be pulled to the results page, not the form page.  I thought you where working on two separate pages.  For the results, you may want to put

if(isset($state->Go))

in the form page to show the results when the state is picked.

Link to comment
Share on other sites

ok...i got it to display information...now, how do i just get it to count the number of entries?

 

this is the current code:

<?php
$hostname="blah";
$username="blah";
$password="blah";
$dbname="blah";
$table="blah";

mysql_connect($hostname,$username, $password) OR DIE ("Unable to connect to database! Please try again later.");
mysql_select_db($dbname);

$state=$_POST['state'];
$query="SELECT * FROM affiliates WHERE affilState='{$state}'";
$result=mysql_query($query);

$num=mysql_numrows($result);

mysql_close();
$i=0;
while ($i < $num) {

$name=mysql_result($result,$i,"affilName");
$city=mysql_result($result,$i,"affilCity");
$email=mysql_result($result,$i,"affilEmail");

echo "Affiliate Name: '{$name}'<br>Affiliate City: '{$city}'<br>Affiliate Email: '{$email}'<br><br>";
$i++;
}

?>

 

this echoes all of the persons selling in a particular state.

basically i just need to print a report that tells how many people are selling in each state...

Link to comment
Share on other sites

<?php
$hostname="blah";
$username="blah";
$password="blah";
$dbname="blah";
$table="blah";

mysql_connect($hostname,$username, $password) OR DIE ("Unable to connect to database! Please try again later.");
mysql_select_db($dbname);

$state=$_POST['state'];
$query="SELECT * FROM affiliates WHERE affilState='{$state}'";
$result=mysql_query($query);

$num=mysql_numrows($result);

mysql_close();
$i=0;
while ($i < $num) {

$i++;
}
echo $i
?>

 

this echoes only the number of entries...

 

now, how would i get it to go through and total each state and display it on a table?

Link to comment
Share on other sites

  • 2 weeks later...

ok, it has been a while since i tried to work on this, but i have come up with an idea, and need help again..

 

i was trying to access all of the states to display sales person info on one page.

 

did some reading and then i made an array. 

 

this is the current code:

$state=array(
1=>'AS', 'AZ', 'AR', 'CA', 'CO', 'CT', 'DE', 'DC', 'FM', 'FL', 'GA', 'GU', 'HI', 'ID', 'IL', 'IN', 'IA', 'KS', 'KY', 'LA', 'ME', 'MH', 'MD', 'MA', 'MI', 'MN', 'MS', 'MO', 'MT', 'NE', 'NV', 'NH', 'NJ', 'NM', 'NY',
'NC', 'ND', 'MP', 'OH', 'OK', 'OR', 'PW', 'PA', 'PR', 'RI', 'SC', 'SD', 'TN', 'TX', 'UT', 'VT', 'VI', 'VA', 'WA', 'WV', 'WI', 'WY'  
);
reset($state);
while (list($key, $val) = each($state)) {
    

$query="SELECT * FROM affiliates WHERE affilState='{$val}'";
echo $query;
}

$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
$i=0;
while ($i < $num) {

$i++;
}
echo $i;
?>

 

it echoes the following:

SELECT * FROM affiliates WHERE affilState='AS'SELECT * FROM affiliates WHERE affilState='AZ'SELECT * FROM affiliates WHERE affilState='AR'SELECT * FROM affiliates WHERE affilState='CA'SELECT * FROM affiliates WHERE affilState='CO'SELECT * FROM affiliates WHERE affilState='CT'SELECT * FROM affiliates WHERE affilState='DE'SELECT * FROM affiliates WHERE affilState='DC'SELECT * FROM affiliates WHERE affilState='FM'SELECT * FROM affiliates WHERE affilState='FL'SELECT * FROM affiliates WHERE affilState='GA'SELECT * FROM affiliates WHERE affilState='GU'SELECT * FROM affiliates WHERE affilState='HI'SELECT * FROM affiliates WHERE affilState='ID'SELECT * FROM affiliates WHERE affilState='IL'SELECT * FROM affiliates WHERE affilState='IN'SELECT * FROM affiliates WHERE affilState='IA'SELECT * FROM affiliates WHERE affilState='KS'SELECT * FROM affiliates WHERE affilState='KY'SELECT * FROM affiliates WHERE affilState='LA'SELECT * FROM affiliates WHERE affilState='ME'SELECT * FROM affiliates WHERE affilState='MH'SELECT * FROM affiliates WHERE affilState='MD'SELECT * FROM affiliates WHERE affilState='MA'SELECT * FROM affiliates WHERE affilState='MI'SELECT * FROM affiliates WHERE affilState='MN'SELECT * FROM affiliates WHERE affilState='MS'SELECT * FROM affiliates WHERE affilState='MO'SELECT * FROM affiliates WHERE affilState='MT'SELECT * FROM affiliates WHERE affilState='NE'SELECT * FROM affiliates WHERE affilState='NV'SELECT * FROM affiliates WHERE affilState='NH'SELECT * FROM affiliates WHERE affilState='NJ'SELECT * FROM affiliates WHERE affilState='NM'SELECT * FROM affiliates WHERE affilState='NY'SELECT * FROM affiliates WHERE affilState='NC'SELECT * FROM affiliates WHERE affilState='ND'SELECT * FROM affiliates WHERE affilState='MP'SELECT * FROM affiliates WHERE affilState='OH'SELECT * FROM affiliates WHERE affilState='OK'SELECT * FROM affiliates WHERE affilState='OR'SELECT * FROM affiliates WHERE affilState='PW'SELECT * FROM affiliates WHERE affilState='PA'SELECT * FROM affiliates WHERE affilState='PR'SELECT * FROM affiliates WHERE affilState='RI'SELECT * FROM affiliates WHERE affilState='SC'SELECT * FROM affiliates WHERE affilState='SD'SELECT * FROM affiliates WHERE affilState='TN'SELECT * FROM affiliates WHERE affilState='TX'SELECT * FROM affiliates WHERE affilState='UT'SELECT * FROM affiliates WHERE affilState='VT'SELECT * FROM affiliates WHERE affilState='VI'SELECT * FROM affiliates WHERE affilState='VA'SELECT * FROM affiliates WHERE affilState='WA'SELECT * FROM affiliates WHERE affilState='WV'SELECT * FROM affiliates WHERE affilState='WI'SELECT * FROM affiliates WHERE affilState='WY'0

 

where do i go from here?  this took me about 4 hours of tinkering just to be able to get this far.  a little direction would be greatly appreciated...

 

thanks so much

ardy

Link to comment
Share on other sites

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.