sql results loop for ever

Started by JayBachatero, June 30, 2005, 11:34:57 PM

Previous topic - Next topic

JayBachatero

i wrote this but the sql results loop for ever can any help.  im not done wit this script but cant continue w/o gettin this fixed.
<?php
/*********************************************

*/

//load connection file
require_once('/usr/local/psa/home/vhosts/kevmundial.com/httpdocs/connect2.php');

  echo 
'
  <form action="dropdown.php?submit" method="post" enctype="multipart/form-data" name="form1">
      <table width="375" border="0">
        <tr>
          <td width="113">Name</td>
          <td width="251"><input type="text" name="name"></td>
        </tr>
        <tr>
          <td>Group</td>
          <td><select name="groupID">
            <option value="Admin" selected>Admin</option>
            <option value="Music Crew">Music Crew</option>
            <option value="Lyriqs Crew">Lyriqs Crew</option>
            <option value="Media Journalist">Media Journalist</option>
          </select></td>
        </tr>
        <tr>
          <td>E-Mail</td>
          <td><input type="text" name="email"></td>
        </tr>
        <tr>
          <td>AIM</td>
          <td><input type="text" name="aim"></td>
        </tr>
        <tr>
          <td>MSN</td>
          <td><input type="text" name="msn"></td>
        </tr>
        <tr>
          <td>Yahoo</td>
          <td><input type="text" name="yahoo"></td>
        </tr>
        <tr>
          <td>Image:</td>
          <td><input type="file" name="img"></td>
        </tr>
        <tr>
          <td>&nbsp;</td>
          <td align="center"><input type="submit" name="Submit" value="Submit"></td>
        </tr>
      </table>
  </form>'
;
  
if (isset(
$submit))
{
  
$uploaddir 'images';
  if(
is_uploaded_file($_FILES['img']['tmp_name']))
  {
    
move_uploaded_file($_FILES['img']['tmp_name'],$uploaddir.'/'.$_FILES['img']['name']);
  }
  foreach (
$_POST as $key => $var)
        $
$key $var;
  
$con db_connect();
  
$img $uploaddir.'/'.$_FILES['img']['name'];
  
mysql_query("INSERT INTO con_info SET `groupID`='$groupID', `name`='$name', `aim`='$aim', `msn`='$msn', `yahoo`='$yahoo', `email`='$email',`img`='$img'");
  
mysql_close($con);
}

if (empty(
$_REQUEST['action']))
{
  
$settings['images_url'] = "http://www.kevmundial.com/board/Themes/MidBlue/images/";
  
$con db_connect();
  
$result mysql_query("SELECT * FROM con_info") or die ("MySQL Error: ".mysql_error());
  
$row mysql_fetch_array($result);
  if
  (
$row['groupID'] == "Music Crew")
  {
    echo
'
      <table width="500" border="0">
      <tr>
        <td width="500" valign="top">123</td>
      </tr>'
;
    while (
$row['groupID'] == "Music Crew")
    {
        echo
'
  <tr>
    <td valign="top"> <table width="500" border="0">
        <tr>
          <td width="155" valign="top"><table width="155" border="0" bgcolor="#0099FF">
              <tr>
                <td width="155" align="center"><img src="'
$row['img'] .'"></td>
              </tr>
              <tr>
                <td align="center">'
$row['name'] .'</td>
              </tr>
            </table></td>
          <td width="345"><table width="345" border="0">
              <tr>
                <td width="103">Site Position: </td>
                <td width="162">'
$row['groupID'] .'</td>
              </tr>
              <tr>
                <td>E-Mail:</td>
                <td><a href="mailto:'
.$row['email'].'">'$row['email'] .'</a></td>
              </tr>
              <tr>
                <td>AIM</td>
                <td><a href="aim:goim?screenname=' 
$row['aim'] . '&message=Hello Are you there?" target="_blank"><img src="http://big.oscar.aol.com/' $row['aim'] . '?on_url=' $settings['images_url'] . '/aim_on.gif&off_url=' $settings['images_url'] . '/aim_off.gif" alt="' $row['aim'] . '" border="0" /></a></td>
              </tr>
              '
;
              if (empty(
$row['yahoo'])) {echo' ';} else{ echo'
              <tr>
                <td>YAHOO</td>
                <td> <a href="http://edit.yahoo.com/config/send_webmesg?.target=' 
$row['yahoo'] . '&.src=pg"> <img border=0 src="http://opi.yahoo.com/online?u=' $row['yahoo'] . '&m=g&t=0"></a> </td>
              </tr>
              '
;} echo'
              <tr>
                <td>MSN</td>
                <td>&nbsp;</td>
              </tr>
            </table></td>
        </tr>
      </table></td>
  </tr>
</table>
'
;
    }
  }
if
  (
$row['groupID'] == "Admin")
  {
    echo
'
      <table width="500" border="0">
      <tr>
        <td width="500" valign="top">456</td>
      </tr>'
;
    while (
$row['groupID'] == "Admin")
    {
        echo
'
  <tr>
    <td valign="top"> <table width="500" border="0">
        <tr>
          <td width="155" valign="top"><table width="155" border="0" bgcolor="#0099FF">
              <tr>
                <td width="155" align="center"><img src="'
$row['img'] .'"></td>
              </tr>
              <tr>
                <td align="center">'
$row['name'] .'</td>
              </tr>
            </table></td>
          <td width="345"><table width="345" border="0">
              <tr>
                <td width="103">Site Position: </td>
                <td width="162">'
$row['groupID'] .'</td>
              </tr>
              <tr>
                <td>E-Mail:</td>
                <td><a href="mailto:'
.$row['email'].'">'$row['email'] .'</a></td>
              </tr>
              <tr>
                <td>AIM</td>
                <td><a href="aim:goim?screenname=' 
$row['aim'] . '&message=Hello. Are you there?" target="_blank"><img src="http://big.oscar.aol.com/' $row['aim'] . '?on_url=' $settings['images_url'] . '/aim_on.gif&off_url=' $settings['images_url'] . '/aim_off.gif" alt="' $row['aim'] . '" border="0" /></a></td>
              </tr>
              '
;
              if (empty(
$row['yahoo'])) {echo' ';} else{ echo'
              <tr>
                <td>YAHOO</td>
                <td> <a href="http://edit.yahoo.com/config/send_webmesg?.target=' 
$row['yahoo'] . '&.src=pg"> <img border=0 src="http://opi.yahoo.com/online?u=' $row['yahoo'] . '&m=g&t=0"></a> </td>
              </tr>
              '
;} echo'
              <tr>
                <td>MSN</td>
                <td>&nbsp;</td>
              </tr>
            </table></td>
        </tr>
      </table></td>
  </tr>
</table>
'
;
    }
  }
}
?>
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

[Unknown]

Since $row is never changing, I wouldn't expect it to do any differently.

-[Unknown]

JayBachatero

so how would i put it. to make it valid?
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

Grudge

You want to put the while loop in the mysql_fetch_array function and NOT the two comparison areas (groupID == bits). Something like:

while ($row = mysql_fetch_array($result))

Where you look through your "if" statements inside it. That way the while statement will keep executing until there are no more entries left. As you have it now (As [Unknown] points out) it will get ONE result - and as the result isn't changing loop infinitely.
I'm only a half geek really...

JayBachatero

ok i changed it but the results only show now for the first if statement  not the rest.
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

JayBachatero

ok i started working on this again but now it shows all the results exect 1 and its supposed to she shown in groups and everything comes out in the admin group exept the admin row itself.
<?php
/*********************************************




**********************************************/

//load connection
require_once('/usr/local/psa/home/vhosts/kevmundial.com/httpdocs/connect2.php');

echo 
'
  <form action="dropdown.php?submit" method="post" enctype="multipart/form-data" name="form1">
      <table width="375" border="0">
        <tr>
          <td width="113">Name</td>
          <td width="251"><input type="text" name="name"></td>
        </tr>
        <tr>
          <td>Group</td>
          <td><select name="groupID">
            <option value="Admin" selected>Admin</option>
            <option value="Music Group">Music Group</option>
            <option value="Lyriqs Crew">Lyriqs Crew</option>
            <option value="Media Journalist">Media Journalist</option>
          </select></td>
        </tr>
        <tr>
          <td>E-Mail</td>
          <td><input type="text" name="email"></td>
        </tr>
        <tr>
          <td>AIM</td>
          <td><input type="text" name="aim"></td>
        </tr>
        <tr>
          <td>MSN</td>
          <td><input type="text" name="msn"></td>
        </tr>
        <tr>
          <td>Yahoo</td>
          <td><input type="text" name="yahoo"></td>
        </tr>
        <tr>
          <td>Image:</td>
          <td><input type="file" name="img"></td>
        </tr>
        <tr>
          <td>&nbsp;</td>
          <td align="center"><input type="submit" name="Submit" value="Submit"></td>
        </tr>
      </table>
  </form>'
;

if (isset(
$submit))
{
  
$uploaddir 'images';
  if(
is_uploaded_file($_FILES['img']['tmp_name']))
  {
    
move_uploaded_file($_FILES['img']['tmp_name'],$uploaddir.'/'.$_FILES['img']['name']);
  }
  foreach (
$_POST as $key => $var)
        $
$key $var;
  
$con db_connect();
  
$img $uploaddir.'/'.$_FILES['img']['name'];
  
mysql_query("INSERT INTO con_info SET `groupID`='$groupID', `name`='$name', `aim`='$aim', `msn`='$msn', `yahoo`='$yahoo', `email`='$email',`img`='$img'");
  
mysql_close($con);
}

if (empty(
$_REQUEST['action']))
{
  
$settings['images_url'] = "http://www.kevmundial.com/board/Themes/MidBlue/images/";
  
$con db_connect();
  
$result mysql_query("SELECT * FROM con_info") or die ("MySQL Error: ".mysql_error());
  
$row mysql_fetch_array($result);


if
  (
$row['groupID'] == "Admin")
  {
    echo
'
      <table width="500" border="0">
      <tr>
        <td width="500" valign="top">Admin</td>
      </tr>'
;
    while (
$row mysql_fetch_array($result))
    {
        echo
'
  <tr>
    <td valign="top"> <table width="500" border="0">
        <tr>
          <td width="155" valign="top"><table width="155" border="0" bgcolor="#0099FF">
              <tr>
                <td width="155" align="center"><img src="'
$row['img'] .'"></td>
              </tr>
              <tr>
                <td align="center">'
$row['name'] .'</td>
              </tr>
            </table></td>
          <td width="345"><table width="345" border="0">
              <tr>
                <td width="103">Site Position: </td>
                <td width="162">'
$row['groupID'] .'</td>
              </tr>
              <tr>
                <td>E-Mail:</td>
                <td><a href="mailto:'
.$row['email'].'">'$row['email'] .'</a></td>
              </tr>
              <tr>
                <td>AIM</td>
                <td><a href="aim:goim?screenname=' 
$row['aim'] . '&message=Hello. Are you there?" target="_blank"><img src="http://big.oscar.aol.com/' $row['aim'] . '?on_url=' $settings['images_url'] . '/aim_on.gif&off_url=' $settings['images_url'] . '/aim_off.gif" alt="' $row['aim'] . '" border="0" /></a></td>
              </tr>
              '
;
              if (empty(
$row['yahoo'])) {echo' ';} else{ echo'
              <tr>
                <td>YAHOO</td>
                <td> <a href="http://edit.yahoo.com/config/send_webmesg?.target=' 
$row['yahoo'] . '&.src=pg"> <img border=0 src="http://opi.yahoo.com/online?u=' $row['yahoo'] . '&m=g&t=0"></a> </td>
              </tr>
              '
;} echo'
              <tr>
                <td>MSN</td>
                <td>&nbsp;</td>
              </tr>
            </table></td>
        </tr>
      </table></td>
  </tr>
</table>
'
;
    }
  }
if
  (
$row['groupID'] == "Music Group")
  {
    echo
'
      <table width="500" border="0">
      <tr>
        <td width="500" valign="top">Music Group</td>
      </tr>'
;
    while (
$row mysql_fetch_array($result))
    {
        echo
'
  <tr>
    <td valign="top"> <table width="500" border="0">
        <tr>
          <td width="155" valign="top"><table width="155" border="0" bgcolor="#0099FF">
              <tr>
                <td width="155" align="center"><img src="'
$row['img'] .'"></td>
              </tr>
              <tr>
                <td align="center">'
$row['name'] .'</td>
              </tr>
            </table></td>
          <td width="345"><table width="345" border="0">
              <tr>
                <td width="103">Site Position: </td>
                <td width="162">'
$row['groupID'] .'</td>
              </tr>
              <tr>
                <td>E-Mail:</td>
                <td><a href="mailto:'
.$row['email'].'">'$row['email'] .'</a></td>
              </tr>
              <tr>
                <td>AIM</td>
                <td><a href="aim:goim?screenname=' 
$row['aim'] . '&message=Hello Are you there?" target="_blank"><img src="http://big.oscar.aol.com/' $row['aim'] . '?on_url=' $settings['images_url'] . '/aim_on.gif&off_url=' $settings['images_url'] . '/aim_off.gif" alt="' $row['aim'] . '" border="0" /></a></td>
              </tr>
              '
;
              if (empty(
$row['yahoo'])) {echo' ';} else{ echo'
              <tr>
                <td>YAHOO</td>
                <td> <a href="http://edit.yahoo.com/config/send_webmesg?.target=' 
$row['yahoo'] . '&.src=pg"> <img border=0 src="http://opi.yahoo.com/online?u=' $row['yahoo'] . '&m=g&t=0"></a> </td>
              </tr>
              '
;} echo'
              <tr>
                <td>MSN</td>
                <td>&nbsp;</td>
              </tr>
            </table></td>
        </tr>
      </table></td>
  </tr>
</table>
'
;
    }
  }
if
  (
$row['groupID'] == "Lyriqs Crew")
  {
    echo
'
      <table width="500" border="0">
      <tr>
        <td width="500" valign="top">Lyriqs Crew</td>
      </tr>'
;
    while (
$row mysql_fetch_array($result))
    {
        echo
'
  <tr>
    <td valign="top"> <table width="500" border="0">
        <tr>
          <td width="155" valign="top"><table width="155" border="0" bgcolor="#0099FF">
              <tr>
                <td width="155" align="center"><img src="'
$row['img'] .'"></td>
              </tr>
              <tr>
                <td align="center">'
$row['name'] .'</td>
              </tr>
            </table></td>
          <td width="345"><table width="345" border="0">
              <tr>
                <td width="103">Site Position: </td>
                <td width="162">'
$row['groupID'] .'</td>
              </tr>
              <tr>
                <td>E-Mail:</td>
                <td><a href="mailto:'
.$row['email'].'">'$row['email'] .'</a></td>
              </tr>
              <tr>
                <td>AIM</td>
                <td><a href="aim:goim?screenname=' 
$row['aim'] . '&message=Hello. Are you there?" target="_blank"><img src="http://big.oscar.aol.com/' $row['aim'] . '?on_url=' $settings['images_url'] . '/aim_on.gif&off_url=' $settings['images_url'] . '/aim_off.gif" alt="' $row['aim'] . '" border="0" /></a></td>
              </tr>
              '
;
              if (empty(
$row['yahoo'])) {echo' ';} else{ echo'
              <tr>
                <td>YAHOO</td>
                <td> <a href="http://edit.yahoo.com/config/send_webmesg?.target=' 
$row['yahoo'] . '&.src=pg"> <img border=0 src="http://opi.yahoo.com/online?u=' $row['yahoo'] . '&m=g&t=0"></a> </td>
              </tr>
              '
;} echo'
              <tr>
                <td>MSN</td>
                <td>&nbsp;</td>
              </tr>
            </table></td>
        </tr>
      </table></td>
  </tr>
</table>
'
;
    }
  }
if
  (
$row['groupID'] == "Media Journalist")
  {
    echo
'
      <table width="500" border="0">
      <tr>
        <td width="500" valign="top">Media Journalist</td>
      </tr>'
;
    while (
$row mysql_fetch_array($result))
    {
        echo
'
  <tr>
    <td valign="top"> <table width="500" border="0">
        <tr>
          <td width="155" valign="top"><table width="155" border="0" bgcolor="#0099FF">
              <tr>
                <td width="155" align="center"><img src="'
$row['img'] .'"></td>
              </tr>
              <tr>
                <td align="center">'
$row['name'] .'</td>
              </tr>
            </table></td>
          <td width="345"><table width="345" border="0">
              <tr>
                <td width="103">Site Position: </td>
                <td width="162">'
$row['groupID'] .'</td>
              </tr>
              <tr>
                <td>E-Mail:</td>
                <td><a href="mailto:'
.$row['email'].'">'$row['email'] .'</a></td>
              </tr>
              <tr>
                <td>AIM</td>
                <td><a href="aim:goim?screenname=' 
$row['aim'] . '&message=Hello. Are you there?" target="_blank"><img src="http://big.oscar.aol.com/' $row['aim'] . '?on_url=' $settings['images_url'] . '/aim_on.gif&off_url=' $settings['images_url'] . '/aim_off.gif" alt="' $row['aim'] . '" border="0" /></a></td>
              </tr>
              '
;
              if (empty(
$row['yahoo'])) {echo' ';} else{ echo'
              <tr>
                <td>YAHOO</td>
                <td> <a href="http://edit.yahoo.com/config/send_webmesg?.target=' 
$row['yahoo'] . '&.src=pg"> <img border=0 src="http://opi.yahoo.com/online?u=' $row['yahoo'] . '&m=g&t=0"></a> </td>
              </tr>
              '
;} echo'
              <tr>
                <td>MSN</td>
                <td>&nbsp;</td>
              </tr>
            </table></td>
        </tr>
      </table></td>
  </tr>
</table>
'
;
    }
  }
}
?>
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

Advertisement: