Jump to content

loop inside loop


dflow

Recommended Posts

i have inserted a horizontal loop inside another loop

 

what i want to achieve is  a table with a list of links and to repeat that for example for each city in my city_list DB table.

 

i manage to get all the cities presented but the list of links is not looped?

 

any ideas?

<?php require_once('../Connections/international.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

mysql_select_db($database_international, $international);
$query_RsCitylinks = "SELECT * FROM city_list ORDER BY CityName_heb ASC";
$RsCitylinks = mysql_query($query_RsCitylinks, $international) or die(mysql_error());
$row_RsCitylinks = mysql_fetch_assoc($RsCitylinks);
$totalRows_RsCitylinks = mysql_num_rows($RsCitylinks);

mysql_select_db($database_international, $international);
$query_RsEventTypes = "SELECT * FROM event_types";
$RsEventTypes = mysql_query($query_RsEventTypes, $international) or die(mysql_error());
$row_RsEventTypes = mysql_fetch_assoc($RsEventTypes);
$totalRows_RsEventTypes = mysql_num_rows($RsEventTypes);
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<table >
  <tr>
    <?php
$RsCitylinks_endRow = 0;
$RsCitylinks_columns = 2; // number of columns
$RsCitylinks_hloopRow1 = 0; // first row flag
do {
    if($RsCitylinks_endRow == 0  && $RsCitylinks_hloopRow1++ != 0) echo "<tr>";
   ?>
    <td><table id="Table_01" width="423" border="0" cellpadding="0" cellspacing="0">
        <tr>
          <td colspan="8"><img id="city_index_menu_01" src="images/city_index_menu_01.gif" width="422" height="40" alt="" /></td>
          <td><img src="images/spacer.gif" width="1" height="40" alt="" /></td>
        </tr>
        <tr>
          <td colspan="3" rowspan="3"><img id="city_index_menu_02" src="images/city_index_menu_02.gif" width="25" height="93" alt="" /></td>
          <td><img id="city_index_menu_03" src="images/city_index_menu_03.gif" width="99" height="6" alt="" /></td>
          <td colspan="3" rowspan="2"><img id="city_index_menu_04" src="images/city_index_menu_04.gif" width="293" height="49" alt="" /></td>
          <td rowspan="2"><img id="city_index_menu_05" src="images/city_index_menu_05.gif" width="5" height="49" alt="" /></td>
          <td><img src="images/spacer.gif" width="1" height="6" alt="" /></td>
        </tr>
        <tr>
          <td rowspan="3"><img id="city_index_menu_06" src="images/city_index_menu_06.gif" width="99" height="88" alt="" /></td>
          <td><img src="images/spacer.gif" width="1" height="43" alt="" /></td>
        </tr>
        <tr>
          <td rowspan="3"><img id="city_index_menu_07" src="images/city_index_menu_07.gif" width="4" height="50" alt="" /></td>
          <td colspan="2" rowspan="3"><img id="city_index_menu_08" src="images/city_index_menu_08.gif" width="289" height="50" alt="" /></td>
          <td rowspan="5"><img id="city_index_menu_09" src="images/city_index_menu_09.gif" width="5" height="226" alt="" /></td>
          <td><img src="images/spacer.gif" width="1" height="44" alt="" /></td>
        </tr>
        <tr>
          <td colspan="3" rowspan="2"><img id="city_index_menu_10" src="images/city_index_menu_10.gif" width="25" height="6" alt="" /></td>
          <td><img src="images/spacer.gif" width="1" height="1" alt="" /></td>
        </tr>
        <tr>
          <td><img id="city_index_menu_11" src="images/city_index_menu_11.gif" width="99" height="5" alt="" /></td>
          <td><img src="images/spacer.gif" width="1" height="5" alt="" /></td>
        </tr>
        <tr>
          <td rowspan="2"><img id="city_index_menu_12" src="images/city_index_menu_12.gif" width="5" height="176" alt="" /></td>
          <td colspan="6"><img id="city_index_menu_13" src="images/city_index_menu_13.gif" width="412" height="11" alt="" /></td>
          <td><img src="images/spacer.gif" width="1" height="11" alt="" /></td>
        </tr>
        <tr>
          <td><img id="city_index_menu_14" src="images/city_index_menu_14.gif" width="7" height="165" alt="" /></td>
          <td colspan="4" valign="top"><table width="100%" border="0">
            <tr>
              <th scope="col"><?php echo $row_RsCitylinks['CityName_heb']; ?></th>
              </tr>
          </table><table >
  <tr>
    <?php
$RsEventTypes_endRow = 0;
$RsEventTypes_columns = 3; // number of columns
$RsEventTypes_hloopRow1 = 0; // first row flag
do {
    if($RsEventTypes_endRow == 0  && $RsEventTypes_hloopRow1++ != 0) echo "<tr>";
   ?>
    <td><table >
      <tr>
        <?php
$RsEventTypes_endRow = 0;
$RsEventTypes_columns = 3; // number of columns
$RsEventTypes_hloopRow1 = 0; // first row flag
do {
    if($RsEventTypes_endRow == 0  && $RsEventTypes_hloopRow1++ != 0) echo "<tr>";
   ?>
        <td><table width="100%" border="0">
            <tr>
              <th scope="col"><?php echo $row_RsEventTypes['EventType_heb']; ?> ב<?php echo $row_RsCitylinks['CityName_heb']; ?></th>
            </tr>
        </table></td>
        <?php  $RsEventTypes_endRow++;
if($RsEventTypes_endRow >= $RsEventTypes_columns) {
  ?>
      </tr>
      <?php
$RsEventTypes_endRow = 0;
  }
} while ($row_RsEventTypes = mysql_fetch_assoc($RsEventTypes));
if($RsEventTypes_endRow != 0) {
while ($RsEventTypes_endRow < $RsEventTypes_columns) {
    echo("<td> </td>");
    $RsEventTypes_endRow++;
}
echo("</tr>");
}?>
    </table></td>
      <?php  $RsEventTypes_endRow++;
if($RsEventTypes_endRow >= $RsEventTypes_columns) {
  ?>
</tr>
  <?php
$RsEventTypes_endRow = 0;
  }
} while ($row_RsEventTypes = mysql_fetch_assoc($RsEventTypes));
if($RsEventTypes_endRow != 0) {
while ($RsEventTypes_endRow < $RsEventTypes_columns) {
    echo("<td> </td>");
    $RsEventTypes_endRow++;
}
echo("</tr>");
}?>
          </table></td>
          <td><img id="city_index_menu_16" src="images/city_index_menu_16.gif" width="8" height="165" alt="" /></td>
          <td><img src="images/spacer.gif" width="1" height="165" alt="" /></td>
        </tr>
        <tr>
          <td colspan="8"><img id="city_index_menu_17" src="images/city_index_menu_17.gif" width="422" height="17" alt="" /></td>
          <td><img src="images/spacer.gif" width="1" height="17" alt="" /></td>
        </tr>
        <tr>
          <td><img src="images/spacer.gif" width="5" height="1" alt="" /></td>
          <td><img src="images/spacer.gif" width="7" height="1" alt="" /></td>
          <td><img src="images/spacer.gif" width="13" height="1" alt="" /></td>
          <td><img src="images/spacer.gif" width="99" height="1" alt="" /></td>
          <td><img src="images/spacer.gif" width="4" height="1" alt="" /></td>
          <td><img src="images/spacer.gif" width="281" height="1" alt="" /></td>
          <td><img src="images/spacer.gif" width="8" height="1" alt="" /></td>
          <td><img src="images/spacer.gif" width="5" height="1" alt="" /></td>
          <td></td>
        </tr>
    </table></td>
    <?php  $RsCitylinks_endRow++;
if($RsCitylinks_endRow >= $RsCitylinks_columns) {
  ?>
  </tr>
  <?php
$RsCitylinks_endRow = 0;
  }
} while ($row_RsCitylinks = mysql_fetch_assoc($RsCitylinks));
if($RsCitylinks_endRow != 0) {
while ($RsCitylinks_endRow < $RsCitylinks_columns) {
    echo("<td> </td>");
    $RsCitylinks_endRow++;
}
echo("</tr>");
}?>
</table></body>
</html>
<?php
mysql_free_result($RsCitylinks);

mysql_free_result($RsEventTypes);
?>


the sql:
RsCitylinks:
SELECT *
FROM city_list


RsEventTypes
SELECT *
FROM event_types
ORDER BY CityName_heb ASC 

here is the script:

<?php require_once('../Connections/international.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

mysql_select_db($database_international, $international);
$query_RsCitylinks = "SELECT * FROM city_list ORDER BY CityName_heb ASC";
$RsCitylinks = mysql_query($query_RsCitylinks, $international) or die(mysql_error());
$row_RsCitylinks = mysql_fetch_assoc($RsCitylinks);
$totalRows_RsCitylinks = mysql_num_rows($RsCitylinks);

mysql_select_db($database_international, $international);
$query_RsEventTypes = "SELECT * FROM event_types";
$RsEventTypes = mysql_query($query_RsEventTypes, $international) or die(mysql_error());
$row_RsEventTypes = mysql_fetch_assoc($RsEventTypes);
$totalRows_RsEventTypes = mysql_num_rows($RsEventTypes);
?>
<table >
  <tr valign="top">
    <?php
$RsCitylinks_endRow = 0;
$RsCitylinks_columns = 2; // number of columns
$RsCitylinks_hloopRow1 = 0; // first row flag
do {
    if($RsCitylinks_endRow == 0  && $RsCitylinks_hloopRow1++ != 0) echo "<tr>";
   ?>
    <td><table id="Table_01" width="423" border="0" cellpadding="0" cellspacing="0">
        <tr>
          <td colspan="8"><img id="city_index_menu_01" src="images/city_index_menu_01.gif" width="422" height="40" alt="" /></td>
          <td><img src="images/spacer.gif" width="1" height="40" alt="" /></td>
        </tr>
        <tr>
          <td colspan="3" rowspan="3"><img id="city_index_menu_02" src="images/city_index_menu_02.gif" width="25" height="93" alt="" /></td>
          <td><img id="city_index_menu_03" src="images/city_index_menu_03.gif" width="99" height="6" alt="" /></td>
          <td colspan="3" rowspan="2"><img id="city_index_menu_04" src="images/city_index_menu_04.gif" width="293" height="49" alt="" /></td>
          <td rowspan="2"><img id="city_index_menu_05" src="images/city_index_menu_05.gif" width="5" height="49" alt="" /></td>
          <td><img src="images/spacer.gif" width="1" height="6" alt="" /></td>
        </tr>
        <tr>
          <td rowspan="3"><img id="city_index_menu_06" src="images/city_index_menu_06.gif" width="99" height="88" alt="" /></td>
          <td><img src="images/spacer.gif" width="1" height="43" alt="" /></td>
        </tr>
        <tr>
          <td rowspan="3"><img id="city_index_menu_07" src="images/city_index_menu_07.gif" width="4" height="50" alt="" /></td>
          <td colspan="2" rowspan="3"><img id="city_index_menu_08" src="images/city_index_menu_08.gif" width="289" height="50" alt="" /></td>
          <td rowspan="5"><img id="city_index_menu_09" src="images/city_index_menu_09.gif" width="5" height="226" alt="" /></td>
          <td><img src="images/spacer.gif" width="1" height="44" alt="" /></td>
        </tr>
        <tr>
          <td colspan="3" rowspan="2"><img id="city_index_menu_10" src="images/city_index_menu_10.gif" width="25" height="6" alt="" /></td>
          <td><img src="images/spacer.gif" width="1" height="1" alt="" /></td>
        </tr>
        <tr>
          <td><img id="city_index_menu_11" src="images/city_index_menu_11.gif" width="99" height="5" alt="" /></td>
          <td><img src="images/spacer.gif" width="1" height="5" alt="" /></td>
        </tr>
        <tr>
          <td rowspan="2"><img id="city_index_menu_12" src="images/city_index_menu_12.gif" width="5" height="176" alt="" /></td>
          <td colspan="6"><img id="city_index_menu_13" src="images/city_index_menu_13.gif" width="412" height="11" alt="" /></td>
          <td><img src="images/spacer.gif" width="1" height="11" alt="" /></td>
        </tr>
        <tr>
          <td><img id="city_index_menu_14" src="images/city_index_menu_14.gif" width="7" height="165" alt="" /></td>
          <td colspan="4" valign="top"><table width="100%" border="0">
            <tr>
              <th scope="col"><?php echo $row_RsCitylinks['CityName_heb']; ?></th>
              </tr>
          </table><table >
  <tr>
    <?php
$RsEventTypes_endRow = 0;
$RsEventTypes_columns = 3; // number of columns
$RsEventTypes_hloopRow1 = 0; // first row flag
do {
    if($RsEventTypes_endRow == 0  && $RsEventTypes_hloopRow1++ != 0) echo "<tr>";
   ?>
    <td><table >
      <tr>
        <?php
$RsEventTypes_endRow = 0;
$RsEventTypes_columns = 3; // number of columns
$RsEventTypes_hloopRow1 = 0; // first row flag
do {
    if($RsEventTypes_endRow == 0  && $RsEventTypes_hloopRow1++ != 0) echo "<tr>";
   ?>
        <td><table width="100%" border="0">
            <tr>
              <th scope="col"><?php echo $row_RsEventTypes['EventType_heb']; ?> ב<?php echo $row_RsCitylinks['CityName_heb']; ?></th>
            </tr>
        </table></td>
        <?php  $RsEventTypes_endRow++;
if($RsEventTypes_endRow >= $RsEventTypes_columns) {
  ?>
      </tr>
      <?php
$RsEventTypes_endRow = 0;
  }
} while ($row_RsEventTypes = mysql_fetch_assoc($RsEventTypes));
if($RsEventTypes_endRow != 0) {
while ($RsEventTypes_endRow < $RsEventTypes_columns) {
    echo("<td> </td>");
    $RsEventTypes_endRow++;
}
echo("</tr>");
}?>
    </table></td>
      <?php  $RsEventTypes_endRow++;
if($RsEventTypes_endRow >= $RsEventTypes_columns) {
  ?>
</tr>
  <?php
$RsEventTypes_endRow = 0;
  }
} while ($row_RsEventTypes = mysql_fetch_assoc($RsEventTypes));
if($RsEventTypes_endRow != 0) {
while ($RsEventTypes_endRow < $RsEventTypes_columns) {
    echo("<td> </td>");
    $RsEventTypes_endRow++;
}
echo("</tr>");
}?>
          </table></td>
          <td><img id="city_index_menu_16" src="images/city_index_menu_16.gif" width="8" height="165" alt="" /></td>
          <td><img src="images/spacer.gif" width="1" height="165" alt="" /></td>
        </tr>
        <tr>
          <td colspan="8"><img id="city_index_menu_17" src="images/city_index_menu_17.gif" width="422" height="17" alt="" /></td>
          <td><img src="images/spacer.gif" width="1" height="17" alt="" /></td>
        </tr>
        <tr>
          <td><img src="images/spacer.gif" width="5" height="1" alt="" /></td>
          <td><img src="images/spacer.gif" width="7" height="1" alt="" /></td>
          <td><img src="images/spacer.gif" width="13" height="1" alt="" /></td>
          <td><img src="images/spacer.gif" width="99" height="1" alt="" /></td>
          <td><img src="images/spacer.gif" width="4" height="1" alt="" /></td>
          <td><img src="images/spacer.gif" width="281" height="1" alt="" /></td>
          <td><img src="images/spacer.gif" width="8" height="1" alt="" /></td>
          <td><img src="images/spacer.gif" width="5" height="1" alt="" /></td>
          <td></td>
        </tr>
    </table></td>
    <?php  $RsCitylinks_endRow++;
if($RsCitylinks_endRow >= $RsCitylinks_columns) {
  ?>
  </tr>
  <?php
$RsCitylinks_endRow = 0;
  }
} while ($row_RsCitylinks = mysql_fetch_assoc($RsCitylinks));
if($RsCitylinks_endRow != 0) {
while ($RsCitylinks_endRow < $RsCitylinks_columns) {
    echo("<td> </td>");
    $RsCitylinks_endRow++;
}
echo("</tr>");
}?>
</table>
<?php
mysql_free_result($RsCitylinks);

mysql_free_result($RsEventTypes);
?>

 

(edited by kenrbnsn to add


tags)

 

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.