TrinitySJ
asked on
need to get the number of rows
i need to get the number of rows
this is what i have so far.. and i get the last one....
more info if needed... please ask me...
this is what i have so far.. and i get the last one....
more info if needed... please ask me...
echo'<IMG SRC="char_test3.php?tournament='.$tournament.'';
$zips = $z->get_zips_in_range($tzip, $distance, _ZIPS_SORT_BY_DISTANCE_DESC, true);
foreach ($zips as $key => $value) {
$count = count($zips);
$sqlcc2="SELECT COUNT(wname) FROM wrestler where wzip = '$key'";
$resultcc2 = mysql_query($sqlcc2) or die(mysql_error());
while($rowcc2 = mysql_fetch_array($resultcc2)){
$count_class = $rowcc2[0];
}
echo'&zip'.$key.'='.$count_class.'';
}
for( $i = 0; $i < $count; $i++)
{
}
echo'">';
ASKER
ah.. no that count is working fine.. it is the $count= count($zips)
i need to know the number of returned zips in the for each line...
i need to know the number of returned zips in the for each line...
Try to move it outside the loop
$count = count($zips);
foreach ($zips as $key => $value) {
$sqlcc2="SELECT COUNT(wname) FROM wrestler where wzip = '$key'";
$resultcc2 = mysql_query($sqlcc2) or die(mysql_error());
while($rowcc2 = mysql_fetch_array($resultc c2)){
$count_class = $rowcc2[0];
}
echo'&zip'.$key.'='.$count _class.'';
}
$count = count($zips);
foreach ($zips as $key => $value) {
$sqlcc2="SELECT COUNT(wname) FROM wrestler where wzip = '$key'";
$resultcc2 = mysql_query($sqlcc2) or die(mysql_error());
while($rowcc2 = mysql_fetch_array($resultc
$count_class = $rowcc2[0];
}
echo'&zip'.$key.'='.$count
}
ASKER
I tried that and i only get one return when i do that..
this is the part of the code that i'm working through that is giving me a hard time
the count that i need to get it the number of zips not the count_class.
I get the count_class fine
it is the number of returned zips that i need in the top of the foreach loop... make sense?
echo'<IMG SRC="char_test3.php?tourna ment='.$to urnament.' ';
$zips = $z->get_zips_in_range($tzi p, $distance, _ZIPS_SORT_BY_DISTANCE_DES C, true);
foreach ($zips as $key => $value) {
$count = count($zips);
$sqlcc2="SELECT COUNT(wname) FROM wrestler where wzip = '$key'";
$resultcc2 = mysql_query($sqlcc2) or die(mysql_error());
while($rowcc2 = mysql_fetch_array($resultc c2)){
$count_class = $rowcc2[0];
}
}
///here
for( $i = 0; $i < $count; $i++)
{
echo'&zip'.$key.'='.$count _class.'';
}
///////here
echo'">';
this is the part of the code that i'm working through that is giving me a hard time
the count that i need to get it the number of zips not the count_class.
I get the count_class fine
it is the number of returned zips that i need in the top of the foreach loop... make sense?
echo'<IMG SRC="char_test3.php?tourna
$zips = $z->get_zips_in_range($tzi
foreach ($zips as $key => $value) {
$count = count($zips);
$sqlcc2="SELECT COUNT(wname) FROM wrestler where wzip = '$key'";
$resultcc2 = mysql_query($sqlcc2) or die(mysql_error());
while($rowcc2 = mysql_fetch_array($resultc
$count_class = $rowcc2[0];
}
}
///here
for( $i = 0; $i < $count; $i++)
{
echo'&zip'.$key.'='.$count
}
///////here
echo'">';
not sure if this helps
but
after a loop
foreach ($zips as $key => $value) {
$count = count($zips);
$sqlcc2="SELECT COUNT(wname) FROM wrestler where wzip = '$key'";
$resultcc2 = mysql_query($sqlcc2) or die(mysql_error());
while($rowcc2 = mysql_fetch_array($resultc c2)){
$count_class = $rowcc2[0];
}
}
you have the last key HERE ($key)
///here
for( $i = 0; $i < $count; $i++)
{
echo'&zip'.$key.'='.$count _class.'';
}
///////here
maybe you should move the second loop into the end of the first one ?
but
after a loop
foreach ($zips as $key => $value) {
$count = count($zips);
$sqlcc2="SELECT COUNT(wname) FROM wrestler where wzip = '$key'";
$resultcc2 = mysql_query($sqlcc2) or die(mysql_error());
while($rowcc2 = mysql_fetch_array($resultc
$count_class = $rowcc2[0];
}
}
you have the last key HERE ($key)
///here
for( $i = 0; $i < $count; $i++)
{
echo'&zip'.$key.'='.$count
}
///////here
maybe you should move the second loop into the end of the first one ?
ASKER
that did not work..
here is what i'm getting...
i get the count. $count=4
but it is doing the loop 4 times for each that it finds.. and i just need the one per loop..
Pre-Season All-American Slam<br>
<IMG SRC="char_test3.php?tourna ment=Pre-S eason All-American Slam&zip0=15&zip0=38&zip0= 44&zip0=82 &zip1=15&z ip1=38&zip 1=44&zip1= 82&zip2=15 &zip2=38&z ip2=44&zip 2=82&zip3= 15&zip3=38 &zip3=44&z ip3=82">
here is what i'm getting...
i get the count. $count=4
but it is doing the loop 4 times for each that it finds.. and i just need the one per loop..
Pre-Season All-American Slam<br>
<IMG SRC="char_test3.php?tourna
echo'<IMG SRC="char_test3.php?tournament='.$tournament.'';
$zips = $z->get_zips_in_range($tzip, $distance, _ZIPS_SORT_BY_DISTANCE_DESC, true);
$count = count($zips);
for( $i = 0; $i < $count; $i++)
{
foreach ($zips as $key => $value) {
$sqlcc2="SELECT COUNT(wname) FROM wrestler where wzip = '$key'";
$resultcc2 = mysql_query($sqlcc2) or die(mysql_error());
while($rowcc2 = mysql_fetch_array($resultcc2)){
$count_class = $rowcc2[0];
}
echo'&zip'.$i.'='.$count_class.'';
}
}
echo'">';
the solution is near
this is the bad result
Pre-Season All-American Slam<br>
<IMG SRC="char_test3.php?tourna ment=Pre-S eason All-American Slam&zip0=15&zip0=38&zip0= 44&zip0=82 &zip1=15&z ip1=38&zip 1=44&zip1= 82&zip2=15 &zip2=38&z ip2=44&zip 2=82&zip3= 15&zip3=38 &zip3=44&z ip3=82">
what do you expect to have as an good result
this is the bad result
Pre-Season All-American Slam<br>
<IMG SRC="char_test3.php?tourna
what do you expect to have as an good result
ASKER
Pre-Season All-American Slam<br>
<IMG SRC="char_test3.php?tourna ment=Pre-S eason All-American Slam&zip1=15&zip2=38&zip3= 44&zip4=82 ">
<IMG SRC="char_test3.php?tourna
ASKER
the previous comment is what i would like to have as the good result.. however i cannot get that no matter what i do.
what is the result for (switch in proper place)
foreach ($zips as $key => $value) {
$sqlcc2="SELECT COUNT(wname) FROM wrestler where wzip = '$key'";
$resultcc2 = mysql_query($sqlcc2) or die(mysql_error());
$rowcc2 = mysql_fetch_array($resultc c2);
$count_class = $rowcc2[0];
}
zip0=15&zip1=15&zip2=15 etc. ?
foreach ($zips as $key => $value) {
$sqlcc2="SELECT COUNT(wname) FROM wrestler where wzip = '$key'";
$resultcc2 = mysql_query($sqlcc2) or die(mysql_error());
$rowcc2 = mysql_fetch_array($resultc
$count_class = $rowcc2[0];
}
zip0=15&zip1=15&zip2=15 etc. ?
try this and paste the result
echo'<IMG SRC="char_test3.php?tournament='.$tournament.'';
$zips = $z->get_zips_in_range($tzip, $distance, _ZIPS_SORT_BY_DISTANCE_DESC, true);
$count = count($zips);
for( $i = 0; $i < $count; $i++)
{
foreach ($zips as $key => $value) {
$sqlcc2="SELECT COUNT(wname) FROM wrestler where wzip = '$key' limit $i,1";
$resultcc2 = mysql_query($sqlcc2) or die(mysql_error());
$rowcc2 = mysql_fetch_array($resultcc2);
$count_class = $rowcc2[0];
echo'&zip'.$i.'='.$count_class.'';
}
}
echo'">';
ASKER
Pre-Season All-American Slam<br><IMG SRC="char_test3.php?tourna ment=Pre-S eason All-American Slam&zip0=15&zip0=38&zip0= 44&zip0=82 &zip1=&zip 1=&zip1=&z ip1=&zip2= &zip2=&zip 2=&zip2=&z ip3=&zip3= &zip3=&zip 3=">
that is the result that i get...
that is the result that i get...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
ok i think were getting somewhere...
that is working.. but the zip0 does not work.. i have to have it start at zip1
Pre-Season All-American Slam<br><IMG SRC="char_test3.php?tourna ment=Pre-S eason All-American Slam&zip0=15&zip1=38&zip2= 44&zip3=82 ">
is the return that i get from the code now..
this is great...
that is working.. but the zip0 does not work.. i have to have it start at zip1
Pre-Season All-American Slam<br><IMG SRC="char_test3.php?tourna
is the return that i get from the code now..
this is great...
ASKER
i fixed it.. changed
$i = 0
to
$i = 1
$i = 0
to
$i = 1
right, index from 1
the issue was that there was two loops, simply unnecessary...
the issue was that there was two loops, simply unnecessary...
ASKER
//===========
$i = 0;
can be
$i = 1;
//================
either will work
$i = 0;
can be
$i = 1;
//================
either will work
ASKER
i have another question about this.. can you help me...
make another question and post a link to it here
ASKER
the new question is here
https://www.experts-exchange.com/questions/24088600/need-to-get-the-number-of-rows-V2-followup.html
https://www.experts-exchange.com/questions/24088600/need-to-get-the-number-of-rows-V2-followup.html
try
$sqlcc2="SELECT COUNT(wname) FROM wrestler where wzip = '$key'";
$resultcc2 = mysql_query($sqlcc2) or die(mysql_error());
////// here
$test = mysql_num_rows($resultcc2)
//////
while($rowcc2 = mysql_fetch_array($resultc
$count_class = $rowcc2[0];
}
echo"$test";