Get record # from end of url error

7 posts by 2 authors in: Forums > CMS Builder
Last Post: June 3, 2015   (RSS)

By nmsinc - June 3, 2015

I have the following code below. When I submit the selected 'num' will not execute through to the URL - any ideas what I'm doing wrong here?

Thanks - nmsinc

<select name="num">
<?php foreach ($code_typesRecords as $type): ?>
<?php if ($CURRENT_USER['isAdmin']): ?>
<?php if ($type['discontinue'] = '0' || !$type['discontinue']): ?>
<option value = "<?php echo $type['num'];?>"><?php echo $type['title'];?> - <?php echo $type['company:label'];?></option>
<?php else: ?>
<option value = "<?php echo $type['num'];?>"><?php echo $type['title'];?> - DISCONTINUED - <?php echo $type['company:label'];?></option>
<?php endif; ?>
<?php elseif ($type['company'] == $CURRENT_USER['assigned_to']): ?>
<?php if ($type['discontinue'] = '0' || !$type['discontinue']): ?>
<option value = "<?php echo $type['num'];?>"><?php echo $type['title'];?></option>
<?php else: ?>
<option value = "<?php echo $type['num'];?>"><?php echo $type['title'];?> - DISCONTINUED</option>
<?php endif; ?>
<?php endif; ?>
<?php endforeach ?>
</select>
                            <input type="submit" name="submit" value="Edit Claim Type">

nmsinc

By claire - June 3, 2015

I think I need more info here. Can you tell me what kind of behaviour are you seeing when the form is submitted? What are the contents of the $_REQUEST array?

I don't see anything offhand that looks wrong about this code.

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

Claire Ryan
interactivetools.com

Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

By claire - June 3, 2015

Okay, what's the action variable on the <form> tag?

Also, this getRecords for the code type doesn't appear to be getting any specific record - is that intended?

// load record from 'code_types'
  list($code_typesRecords, $code_typesMetaData) = getRecords(array(
    'tableName'   => 'code_types',
    'orderBy'     => 'title',
    ));
  $code_typesRecord = @$claim_typesRecords[0]; // get first record

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

Claire Ryan
interactivetools.com

Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

By nmsinc - June 3, 2015

The get record should grab the record number from the end of the URL such as code_type?num=3!

Do I have an incorrect 'get' statement?

nmsinc

By claire - June 3, 2015

Yeah, you're missing a 'where' parameter there. You need to tell the getRecords that the record to get has a num of 3. like so:

// load record from 'code_types'
  list($code_typesRecords, $code_typesMetaData) = getRecords(array(
    'tableName'   => 'code_types',
    'where'       => 'num = '. mysql_escape($_REQUEST['num']),
    'orderBy'     => 'title',
    ));
  $code_typesRecord = @$claim_typesRecords[0]; // get first record

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

Claire Ryan
interactivetools.com

Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

By nmsinc - June 3, 2015

Duh!

I could just kick myself -  thanks Clair.

nmsinc