Jump to content
Sign in to follow this  
eric_jbdotcom

Site Rep Program Contribution

Recommended Posts

I am trying to make a contribution that adds a dropdown selection for the user to select the site rep that referred them to the site. As of right now I have been able to create the DB tables and have been able to make the admin-end of this contribution PARTIALLY work.

 

Right now I am receiving these problems:

1. When editing a site rep, the state dropdown list only shows ID #'s not state initials.

 

2. The ID # of the state is shown under the states column on the main sitereps.php page

 

3. The select rank option only shows one radio button with no text, and when its selected, the value defaults to 0.

 

4. The ID # of the rank under the ranks column on the main sitereps.php page

 

Here is the file:

/admin/sitereps.php

 

<?php

/*

  $Id: sitereps.php,v 1.28 2003/06/29 22:50:51 hpdl Exp $

 

  osCommerce, Open Source E-Commerce Solutions

  http://www.oscommerce.com

 

  Copyright ? 2003 osCommerce

 

  Released under the GNU General Public License

*/

 

  require('includes/application_top.php');

 

  $action = (isset($HTTP_GET_VARS['action']) ? $HTTP_GET_VARS['action'] : '');

 

  if (tep_not_null($action)) {

    switch ($action) {

      case 'insert':

        $sitereps_id = tep_db_prepare_input($HTTP_POST_VARS['sitereps_id']);

        $sitereps_name = tep_db_prepare_input($HTTP_POST_VARS['sitereps_name']);

  $sitereps_city = tep_db_prepare_input($HTTP_POST_VARS['sitereps_city']);

        $sitereps_state = tep_db_prepare_input($HTTP_POST_VARS['sitereps_state']);

        $sitereps_rank = tep_db_prepare_input($HTTP_POST_VARS['sitereps_rank']);

 

        tep_db_query("insert into " . TABLE_SITEREPS . " (sitereps_id, sitereps_name, sitereps_city, sitereps_state, sitereps_rank) values ('" . tep_db_input($sitereps_id) . "', '" . tep_db_input($sitereps_name) . "', '" . tep_db_input($sitereps_state) . "', '" . (int)$sitereps_rank . "')");

 

        tep_redirect(tep_href_link(FILENAME_SITEREPS));

        break;

      case 'save':

        $sitereps_id = tep_db_prepare_input($HTTP_GET_VARS['cID']);

        $sitereps_id = tep_db_prepare_input($HTTP_POST_VARS['sitereps_id']);

        $sitereps_name = tep_db_prepare_input($HTTP_POST_VARS['sitereps_name']);

  $sitereps_city = tep_db_prepare_input($HTTP_POST_VARS['sitereps_city']);

        $sitereps_state = tep_db_prepare_input($HTTP_POST_VARS['sitereps_state']);

        $sitereps_rank = tep_db_prepare_input($HTTP_POST_VARS['sitereps_rank']);

 

        tep_db_query("update " . TABLE_SITEREPS . " set sitereps_id = '" . tep_db_input($sitereps_id) . "', sitereps_name = '" . tep_db_input($sitereps_name) . "', sitereps_city = '" . tep_db_input($sitereps_city) . "', sitereps_state = '" . tep_db_input($sitereps_state) . "', sitereps_rank = '" . (int)$sitereps_rank . "' where sitereps_id = '" . (int)$sitereps_id . "'");

 

        tep_redirect(tep_href_link(FILENAME_SITEREPS, 'page=' . $HTTP_GET_VARS['page'] . '&cID=' . $sitereps_id));

        break;

      case 'deleteconfirm':

        $sitereps_id = tep_db_prepare_input($HTTP_GET_VARS['cID']);

 

        tep_db_query("delete from " . TABLE_SITEREPS . " where sitereps_id = '" . (int)$sitereps_id . "'");

 

        tep_redirect(tep_href_link(FILENAME_SITEREPS, 'page=' . $HTTP_GET_VARS['page']));

        break;

    }

  }

?>

<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">

<html <?php echo HTML_PARAMS; ?>>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">

<title><?php echo TITLE; ?></title>

<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">

<script language="javascript" src="includes/general.js"></script>

</head>

<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF" onload="SetFocus();">

<!-- header //-->

<?php require(DIR_WS_INCLUDES . 'header.php'); ?>

<!-- header_eof //-->

 

<!-- body //-->

<table border="0" width="100%" cellspacing="2" cellpadding="2">

  <tr>

    <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft">

<!-- left_navigation //-->

<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>

<!-- left_navigation_eof //-->

    </table></td>

<!-- body_text //-->

    <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">

      <tr>

        <td><table border="0" width="100%" cellspacing="0" cellpadding="0">

          <tr>

            <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>

            <td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>

          </tr>

        </table></td>

      </tr>

      <tr>

        <td><table border="0" width="100%" cellspacing="0" cellpadding="0">

          <tr>

            <td valign="top">

                  <table border="0" width="100%" cellspacing="0" cellpadding="2">

                    <tr class="dataTableHeadingRow">

                      <td class="dataTableHeadingContent" width="2%" align="center">

                        <?php echo TABLE_HEADING_SITEREPS_ID; ?>

                      </td>

                      <td class="dataTableHeadingContent" align="left" width="31%">

                        <?php echo TABLE_HEADING_SITEREPS_NAME; ?>

                      </td>

                      <td class="dataTableHeadingContent" align="center" width="15%">

                        <?php echo TABLE_HEADING_SITEREPS_CITY; ?>

                      </td>

                      <td class="dataTableHeadingContent" align="center" width="15%">

                        <?php echo TABLE_HEADING_SITEREPS_STATE; ?>

                      </td>

                      <td class="dataTableHeadingContent" align="right" width="16%">

                        <?php echo TABLE_HEADING_SITEREPS_RANK; ?>

                      </td>

                      <td class="dataTableHeadingContent" align="right" width="23%">

                        <?php echo TABLE_HEADING_SITEREPS_ACTION; ?>

                         </td>

                    </tr>

                    <?php

  $sitereps_query_raw = "select sitereps_id, sitereps_name, sitereps_name, sitereps_city, sitereps_state, sitereps_rank from " . TABLE_SITEREPS . " order by sitereps_name";

  $sitereps_split = new splitPageResults($HTTP_GET_VARS['page'], MAX_DISPLAY_SEARCH_RESULTS, $sitereps_query_raw, $sitereps_query_numrows);

  $sitereps_query = tep_db_query($sitereps_query_raw);

  while ($sitereps = tep_db_fetch_array($sitereps_query)) {

    if ((!isset($HTTP_GET_VARS['cID']) || (isset($HTTP_GET_VARS['cID']) && ($HTTP_GET_VARS['cID'] == $sitereps['sitereps_id']))) && !isset($cInfo) && (substr($action, 0, 3) != 'new')) {

      $cInfo = new objectInfo($sitereps);

    }

 

    if (isset($cInfo) && is_object($cInfo) && ($sitereps['sitereps_id'] == $cInfo->sitereps_id)) {

      echo '                  <tr id="defaultSelected" class="dataTableRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_SITEREPS, 'page=' . $HTTP_GET_VARS['page'] . '&cID=' . $cInfo->sitereps_id . '&action=edit') . '\'">' . "\n";

    } else {

      echo '                  <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_SITEREPS, 'page=' . $HTTP_GET_VARS['page'] . '&cID=' . $sitereps['sitereps_id']) . '\'">' . "\n";

    }

?>

                    <tr>

                      <td class="dataTableContent" width="2%" align="center">

                        <?php echo $sitereps['sitereps_id']; ?>

                      </td>

                      <td class="dataTableContent" align="left" width="31%">

                        <?php echo $sitereps['sitereps_name']; ?>

                      </td>

                      <td class="dataTableContent" align="center" width="15%">

                        <?php echo $sitereps['sitereps_city']; ?>

                      </td>

                      <td class="dataTableContent" align="center" width="15%">

                        <?php echo $sitereps['sitereps_state']; ?>

                      </td>

                      <td class="dataTableContent" align="right" width="16%">

                        <?php echo $sitereps['sitereps_rank']; ?>

                      </td>

                      <td class="dataTableContent" align="right" width="23%">

                        <?php if (isset($cInfo) && is_object($cInfo) && ($sitereps['sitereps_id'] == $cInfo->sitereps_id) ) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', ''); } else { echo '<a href="' . tep_href_link(FILENAME_SITEREPS, 'page=' . $HTTP_GET_VARS['page'] . '&cID=' . $sitereps['sitereps_id']) . '">' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?>

                         </td>

                    </tr>

                    <?php

  }

?>

                    <tr>

                      <td colspan="6">

                        <table border="0" width="100%" cellspacing="0" cellpadding="2">

                          <tr>

                            <td class="smallText" valign="top">

                              <?php echo $sitereps_split->display_count($sitereps_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, $HTTP_GET_VARS['page'], TEXT_DISPLAY_NUMBER_OF_SITEREPS); ?>

                            </td>

                            <td class="smallText" align="right">

                              <?php echo $sitereps_split->display_links($sitereps_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $HTTP_GET_VARS['page']); ?>

                            </td>

                          </tr>

                          <?php

  if (empty($action)) {

?>

                          <tr>

                            <td colspan="2" align="right">

                              <?php echo '<a href="' . tep_href_link(FILENAME_SITEREPS, 'page=' . $HTTP_GET_VARS['page'] . '&action=new') . '">' . tep_image_button('button_new_siterep.gif', IMAGE_NEW_SITEREP) . '</a>'; ?>

                            </td>

                          </tr>

                          <?php

  }

?>

                        </table>

                      </td>

                    </tr>

                  </table>

                </td>

<?php

  $heading = array();

  $contents = array();

 

  switch ($action) {

    case 'new':

      $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_NEW_SITEREPS . '</b>');

 

      $contents = array('form' => tep_draw_form('sitereps', FILENAME_SITEREPS, 'page=' . $HTTP_GET_VARS['page'] . '&action=insert'));

      $contents[] = array('text' => TEXT_INFO_INSERT_INTRO);

      $contents[] = array('text' => '<br>' . TEXT_INFO_SITEREPS_ID . '<br>' . tep_draw_input_field('sitereps_id'));

      $contents[] = array('text' => '<br>' . TEXT_INFO_SITEREPS_NAME . '<br>' . tep_draw_input_field('sitereps_name'));

  $contents[] = array('text' => '<br>' . TEXT_INFO_SITEREPS_CITY . '<br>' . tep_draw_input_field('sitereps_city'));

      $contents[] = array('text' => '<br>' . TEXT_INFO_SITEREPS_STATE . '<br>' . tep_draw_pull_down_menu('sitereps_state', tep_get_sitereps_states()));

      $contents[] = array('text' => '<br>' . TEXT_INFO_SITEREPS_RANK . '<br>' . tep_draw_radio_field('sitereps_rank', tep_get_sitereps_ranks()));

      $contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_insert.gif', IMAGE_INSERT) . ' <a href="' . tep_href_link(FILENAME_SITEREPS, 'page=' . $HTTP_GET_VARS['page']) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');

      break;

    case 'edit':

      $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_EDIT_SITEREPS . '</b>');

 

      $contents = array('form' => tep_draw_form('sitereps', FILENAME_SITEREPS, 'page=' . $HTTP_GET_VARS['page'] . '&cID=' . $cInfo->sitereps_id . '&action=save'));

      $contents[] = array('text' => TEXT_INFO_EDIT_INTRO);

      $contents[] = array('text' => '<br>' . TEXT_INFO_SITEREPS_ID . '<br>' . tep_draw_input_field('sitereps_id', $cInfo->sitereps_id));

      $contents[] = array('text' => '<br>' . TEXT_INFO_SITEREPS_NAME . '<br>' . tep_draw_input_field('sitereps_name', $cInfo->sitereps_name));

      $contents[] = array('text' => '<br>' . TEXT_INFO_SITEREPS_CITY . '<br>' . tep_draw_input_field('sitereps_city', $cInfo->sitereps_city));

  $contents[] = array('text' => '<br>' . TEXT_INFO_SITEREPS_STATE . '<br>' . tep_draw_pull_down_menu('sitereps_state', tep_get_sitereps_states(), $cInfo->sitereps_state));

      $contents[] = array('text' => '<br>' . TEXT_INFO_SITEREPS_RANK . '<br>' . tep_draw_radio_field('sitereps_rank', tep_get_sitereps_ranks(), $cInfo->sitereps_rank));

      $contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_update.gif', IMAGE_UPDATE) . ' <a href="' . tep_href_link(FILENAME_SITEREPS, 'page=' . $HTTP_GET_VARS['page'] . '&cID=' . $cInfo->sitereps_id) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');

      break;

    case 'delete':

      $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_DELETE_SITEREPS . '</b>');

 

      $contents = array('form' => tep_draw_form('sitereps', FILENAME_SITEREPS, 'page=' . $HTTP_GET_VARS['page'] . '&cID=' . $cInfo->sitereps_id . '&action=deleteconfirm'));

      $contents[] = array('text' => TEXT_INFO_DELETE_INTRO);

      $contents[] = array('text' => '<br><b>' . $cInfo->sitereps_name . '</b>');

      $contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_delete.gif', IMAGE_UPDATE) . ' <a href="' . tep_href_link(FILENAME_SITEREPS, 'page=' . $HTTP_GET_VARS['page'] . '&cID=' . $cInfo->sitereps_id) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');

      break;

    default:

      if (is_object($cInfo)) {

        $heading[] = array('text' => '<b>' . $cInfo->sitereps_name . '</b>');

 

        $contents[] = array('align' => 'center', 'text' => '<a href="' . tep_href_link(FILENAME_SITEREPS, 'page=' . $HTTP_GET_VARS['page'] . '&cID=' . $cInfo->sitereps_id . '&action=edit') . '">' . tep_image_button('button_edit.gif', IMAGE_EDIT) . '</a> <a href="' . tep_href_link(FILENAME_SITEREPS, 'page=' . $HTTP_GET_VARS['page'] . '&cID=' . $cInfo->sitereps_id . '&action=delete') . '">' . tep_image_button('button_delete.gif', IMAGE_DELETE) . '</a>');

        $contents[] = array('text' => '<br>' . TEXT_INFO_SITEREPS_ID . ' ' . $cInfo->sitereps_id);

        $contents[] = array('text' => '<br>' . TEXT_INFO_SITEREPS_NAME . ' ' . $cInfo->sitereps_name);

  $contents[] = array('text' => '<br>' . TEXT_INFO_SITEREPS_CITY . ' ' . $cInfo->sitereps_city);

        $contents[] = array('text' => '<br>' . TEXT_INFO_SITEREPS_STATE . ' ' . $cInfo->sitereps_state);

        $contents[] = array('text' => '<br>' . TEXT_INFO_SITEREPS_RANK . ' ' . $cInfo->sitereps_rank);

      }

      break;

  }

 

  if ( (tep_not_null($heading)) && (tep_not_null($contents)) ) {

    echo '            <td width="25%" valign="top">' . "\n";

 

    $box = new box;

    echo $box->infoBox($heading, $contents);

 

    echo '            </td>' . "\n";

  }

?>

          </tr>

        </table></td>

      </tr>

    </table></td>

<!-- body_text_eof //-->

  </tr>

</table>

<!-- body_eof //-->

 

<!-- footer //-->

<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>

<!-- footer_eof //-->

<br>

</body>

</html>

<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

 

 

These are the databases tables I have added:

 

TABLE NAME: sitereps

sitereps_id              (int)        11        autoincrement

sitereps_name      (vars)      64

sitereps_city          (vars)      24

sitereps_state        (char)      2

sitereps_rank        (char)      5

 

SET:

sitereps_id to PRIMARY

sitereps_name to IDX_REFERRERS_NAME

 

 

-----------------------------------------------------------------

 

 

TABLE NAME: referrers_state

sitereps_state        (varchar)    64    no

sitereps_state_id        (int)        11    no  autoincrement

 

SET:

sitereps_state to PRIMARY

 

 

i want to be able to link the states (im listing the 48 mainland ones) so that when i add a new site rep to my site reps list (going to be like the countries section) i can use a dropdown to get the states.

 

-----------------------------------------------------------------

 

 

TABLE NAME: sitereps_rank

sitereps_rank          (varchar)    5      No 

sitereps_rank_id        (int)        1        No    auto_increment

 

SET:

sitereps_rank to PRIMARY

 

I want to be able to make the rank have two choices, State or City, and be selectable via radio button when editing a Site Rep.

 

------------------------------------------------------------------------------------

 

 

heres the table data i entered in for the configuration TABLE:

 

configuration_id: 956

configuration_title: Site Rep State

configuration_key: SITEREPS_STATE

configuration_value:

configuration_description: Select the Site Rep's State

configuration_group_id: 0

sort_order: 0

last_modified: 2004-01-11 16:38:48

date_added: 0000-00-00 00:00:00

use_function: tep_get_sitereps_state

set_function: tep_cfg_pull_down_sitereps_state(

 

configuration_id: 957

configuration_title: Site Rep Rank

configuration_key: SITEREPS_RANK

configuration_value:

configuration_description: Select the Site Rep's Rank

configuration_group_id: 0

sort_order: 0

last_modified: 2004-01-11 16:38:48

date_added: 0000-00-00 00:00:00

use_function: NULL

set_function: tep_cfg_radio_field(array('City', 'State'),

 

I guess this is pretty for a 16yr old with about a months worth of PHP/mySQL knowledge. Any help is appreciated.

 

 

PS In the future I will try to add a table for the "overall referrals" (total # of customer sign ups under a site rep); a "total purchases" (total # of purchases made by customers signed up under each site rep); and last a "total price of all purchases" (total $ amount of all purchases made my customers signed up under each site rep).

Share this post


Link to post
Share on other sites

oops i needed to fix this

 

SET:

sitereps_id to PRIMARY

sitereps_name to IDX_SITEREPS_NAME

 

 

-----------------------------------------------------------------

 

 

TABLE NAME: sitereps_state

sitereps_state        (varchar)    64    no

sitereps_state_id        (int)        11    no  autoincrement

Share this post


Link to post
Share on other sites

ok i got it to work ADMIN-SIDE.

 

theres one problem though, when i delete a site rep then add a new one, it just adds 1 to the last #.

 

EX. Id= 1 SiteRep= Bob

Id= 2 SiteRep= Jack

 

I delete Jack, Id=2.

 

Then make Bill, ID=3 not #2

Share this post


Link to post
Share on other sites

        $sitereps_state = tep_db_prepare_input($HTTP_POST_VARS['sitereps_state']);

       tep_db_query("insert into " . TABLE_SITEREPS . " (sitereps_id, sitereps_name, sitereps_city, sitereps_state, sitereps_rank) values ('" . tep_db_input($sitereps_id) . "', '" . tep_db_input($sitereps_name) . "', '" . tep_db_input($sitereps_state) . "', '" . (int)$sitereps_rank . "')");

                      <td class="dataTableContent" align="center" width="15%"> 
                       <?php echo $sitereps['sitereps_state']; ?>
                     </td>

      $contents[] = array('text' => '<br>' . TEXT_INFO_SITEREPS_STATE . '<br>' . tep_draw_pull_down_menu('sitereps_state', tep_get_sitereps_states()));

It is hard to help when there is this much code. Particularly as it is spread over *six* threads. Part of the reason why I didn't post last night is that I started trying to read through the three threads that you PMed to me and just gave up. I think that I have distilled the relevant code from what you posted (for questions 1 and 2). I am missing at least one piece of code that would be relevant, the definition of function tep_get_sitereps_states.

 

tep_draw_pull_down_menu expects to get passed a two dimensional array. The inner dimension is just a number representing position in the menu. The outer dimension is associative (i.e. keyed by a string), with keys of 'id' and 'text'. The 'text' is what appears in the menu; the 'id' is what the menu passes when you submit the form with that entry selected. In your case, you should be setting the 'text' to the state initials in your tep_get_sitereps_states function. I am guessing that your current function does not do it that way. Without seeing the function, this is the best that I can do with #1.

 

As to #2, remember that the pull down menu passes the contents of the 'id' field when the page is submitted. As such, it is to be expected that what you put in the database (and therefore what appears when you read from the database) will be the id. You can change this behavior by adding a lookup to the states table to get the abbreviation. You can do this: before database insertion; when looking up data from the database; or by making the abbreviations the 'id' fields in the array.

 

In regards to #3, I see many uses of tep_cfg_select_option in the oscommerce.sql, but none of tep_cfg_radio_field. I would try using tep_cfg_select_option instead (remainder of syntax would stay the same).

 

My first guess on #4 is that it is the same problem as #2. What is tep_get_sitereps_ranks() returning?

 

Hth,

Matt

Share this post


Link to post
Share on other sites

here is the code for /admin/functions/general.php

 

I have already edited and modified it so that ALL OF THE CODE (so far) works ADMIN side.

 

////

// Get list of sitereps_state's

? function tep_get_sitereps_states() {

? ? $sitereps_state_query = tep_db_query("select sitereps_state from " . TABLE_SITEREPS_STATE . " order by sitereps_state_id");

? ? $sitereps_state_array = array();

? ? while ($sitereps_state_values = tep_db_fetch_array($sitereps_state_query)) {

? ? ? $sitereps_state_array[] = array('id' => $sitereps_state_values['sitereps_state'],

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 'text' => $sitereps_state_values['sitereps_state']);

? ? }

? ? return $sitereps_state_array;

? }

?

////

// Get list of sitereps_rank's

? function tep_get_sitereps_ranks() {

? ? $sitereps_rank_query = tep_db_query("select sitereps_rank from " . TABLE_SITEREPS_RANK . " order by sitereps_rank_id");

? ? $sitereps_rank_array = array();

? ? while ($sitereps_rank_values = tep_db_fetch_array($sitereps_rank_query)) {

? ? ? $sitereps_rank_array[] = array('id' => $sitereps_rank_values['sitereps_rank'],

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 'text' => $sitereps_rank_values['sitereps_rank']);

? ? }

? ? return $sitereps_rank_array;

? }

 

i also changed these DB entries to this order:

 

TABLE NAME: sitereps_state

sitereps_state_id        (int)        11    no  autoincrement

sitereps_state        (varchar)    64    no

 

TABLE NAME: sitereps_rank

sitereps_rank_id        (int)        1        No    auto_increment

sitereps_rank          (varchar)    5      No 

 

sorry about spreading this over so many posts, i have been trying to track my own progress and with each thread, when i make an error to a post, i made a new one. not a good idea. but this is the thread with the most progress so far.

Edited by eric_jbdotcom

Share this post


Link to post
Share on other sites

Ok i am completely redoing this, so now there will be 2 pages, one for state reps, and one for city reps.

 

The state reps page will have these:

id #

name

telephone #

city

state

email

 

the city reps pages will have the same, but with this extra field:

State Rep (above them)

 

I will be able to select the State Rep that is in charge of the city reps from a dropdown list when adding a NEW CITY REP.

 

here is the new database tables:

TABLE NAME: city_sitereps

city_sitereps_id            (int)      11        autoincrement

city_sitereps_name          (vars)      64

city_sitereps_number        (vars)      10

sitereps_state              (char)      2

city_sitereps_email        (vars)      64

 

SET:

sitereps_id to PRIMARY

sitereps_name to IDX_CITY_SITEREPS_NAME

 

 

TABLE NAME: state_sitereps

state_sitereps_id            (int)      11        autoincrement

state_sitereps_name          (vars)      64

state_sitereps_number        (vars)      10

sitereps_state              (char)      2

state_sitereps_email        (vars)      64

 

SET:

state_sitereps_id to PRIMARY

state_sitereps_name to IDX_STATE_SITEREPS_NAME

Share this post


Link to post
Share on other sites

ok i got it to work.

 

theres one problem though, when i delete a site rep then add a new one, it just adds 1 to the last #.

 

EX. Id= 1 SiteRep= Bob

Id= 2 SiteRep= Jack

 

I delete Jack, Id=2.

 

Then make Bill, ID=3 not #2

Share this post


Link to post
Share on other sites

That's how an auto-increment field works. Once you go past a number, it won't go back unless you manually alter the table. If you do not want that behavior, remove the auto-increment and set the id to something like MAX(id)+1 manually.

 

Hth,

Matt

Share this post


Link to post
Share on other sites

well im fine, i just removed the column in the admin page so i dont see the ID #'s anymore and wont be bugged by it.

 

 

but now i am trying to figure out how to show the # of cityreps i have under each site rep. anyone got any clues?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×