Need a little assistance

16 posts by 2 authors in: Forums > CMS Builder
Last Post: February 15, 2013   (RSS)

I have 2 small issues I not really sure how to deal with  - 

1. Autofill a drop list

http://www.stockpiledefensefsnv.com/classlist.php  at the bottom of the page you will see I cant even get the day to autofill

2. Merge the day and name into one array??? Is that the term?  So when they make a selection from the drop menu it has the day and name of the class

Here is my code and I have done this several times before on other sites  but now I cant get it to work at all ..I dont seem to have a value and a label for 'day' and 'name'

 <form id="form" action="classlist.php?day_name"> 

<select name="day_match" class="dropdown" id="type" size="1" style="font-family: Verdana; color: #821789; font-size: 10pt">
<option selected value="day">Select A Day</option>
<?php
$tablename = $options['classes'];
$fieldname = 'day';
$schema = loadSchema($tablename);
$fieldSchema = $schema[$fieldname];
$fieldOptions = getListOptionsFromSchema($fieldSchema);

foreach ($fieldOptions as $valueAndLabel) {
list($value, $label) = $valueAndLabel;
$encodedValue = htmlspecialchars($value);
$encodedLabel = htmlspecialchars($label);
print "<option value='$encodedValue'>$encodedLabel</option>\n";
}
?>
</select>
<input type="submit" name="submit" value="Click to Search" >

</form>

thanks

Patricia

www.thenetgirl.com
Attachments:

classlist.php 3K

Hi,

1) I notice that the table name is called $options['classes'], but I couldn't find a variable with that name in the file, and it doesn't look like there are any other files it could be loaded from. Does it need renaming?

2) So do you want to set it up so that when a user selects a day, they have a second drop down with the classes in that filters items for only that day? Or one drop down that contains all of the days and classes in one list. 

Thanks!

Greg

Greg Thomas







PHP Programmer - interactivetools.com

By thenetgirl - February 7, 2013 - edited: February 7, 2013

 'tableName'   => 'classes', - isn't that is what suppose to be there??

// load records from 'classes'
list($classesRecords, $classesMetaData) = getRecords(array(
'tableName' => 'classes',
'loadUploads' => true,
'allowSearch' => true,
));

I would like -  one drop down that contains all of the days and names in drop list that auto populates. 

Day: <?php echo htmlencode($record['day']) ?>
Name: <?php echo htmlencode($record['name']) ?>

thanks

Patricia

www.thenetgirl.com

Hi,

In the classlist.php file attached to the previous post, line 55 has:

$tablename = $options['classes'];

Does it return anything if you have the tablename set as just 'classes'?

Creating a drop down of both dates and names should be fairly straight forward, could you run this code so  I can see how you have your sections set up?

<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php
  /* STEP 1: LOAD RECORDS - Copy this PHP code block near the TOP of your page */
  
  // load viewer library
  $libraryPath = 'cmsAdmin/lib/viewer_functions.php';
  $dirsToCheck = array('/home/stockfsnv/www/stockpiledefensefsnv.com/','','../','../../','../../../');
  foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
  if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }

  // load records from 'classes'
  list($classesRecords, $classesMetaData) = getRecords(array(
    'tableName'   => 'classes',
    'loadUploads' => true,
    'allowSearch' => true,
     'joinTable'   => 'prices',

  ));

  showme($classesRecords['0']);
  exit;
?>

Then paste what is output on the page into a post. Then I'll be able to see how I need to structure the select menu.

Thanks!

Greg

Greg Thomas







PHP Programmer - interactivetools.com

I spent the last few days re working the whole thing  I seem to have been able to auto populate the drop menu..however I seem to have a new problem with the drop.

The classes are only  allowed to show for the next 60 days. So they are really important that I have control to pass them through the shopping cart and  if they aren't on the drop list they can't purchase yet

<p align="center">&nbsp;<font size="4" face="Verdana">Step 2: Tell Us Your Front Sight Date &amp; Course </font>


<select name="custom7" style="color: #800000; font-weight:bold; font-family:Verdana; font-size:10px" size="1">
<?php foreach ($classesRecords as $record): ?>
<option value="<?php echo $record['num'] ?>"><?php echo $record['cday'] ?> -<?php echo $record['cname'] ?> </option>
<?php endforeach ?>
</select></p>

I have tried to insert the drop but I cant seem to pass the info to the cart. I think that I still need to figure out how to make some kind of array and join the 2 tables classes and prices but not quite sure how. I think my issue is the 'num' as both tables have it.

I have  placed a text box where  I need to info but that requires them to manually fill out the info with no control of  the class date and that doesn't work really.

stockpiledefensefsnv.com/handgunorder.php  I attached the file

Patricia

www.thenetgirl.com
Attachments:

handgunorder.php 7K

Dansie and NO

PG

Patricia

www.thenetgirl.com

Hi PG

I've not used the Dansie cart system before, so i'm not sure how you would pass a variable into it. I would suggest looking at the documentation that comes with it to see if can be done. 

Are you still having trouble creating the dropdown? 

Thanks!

Greg

Greg Thomas







PHP Programmer - interactivetools.com

Sorry for the delay - I figureded out how to get the info in the cart  - just removed it from the prices page and put it on the order page by itself

It seems that it loads the drop however it passes the very last day of classes that I have listed to the cart every time.

AND YES .... I think its the drop which needs help to add num, cday and cname to and array or a concatenation to say -  

$classNum = $classesRecords['num, cday, cname'];   <<<<<<<<<<< but I dont think I have this correct?

< you can see it here with the error    stockpiledefensefsnv.com/3order.php

Here is my code- 
 // load records from 'classes'
  list($classesRecords, $classesMetaData) = getRecords(array(
    'tableName'   => 'classes',
    'loadUploads' => true,
    'allowSearch' => true,
  ));
 
   $classNum = $classesRecords['num, cday, cname'];
  ?>

 <style type="text/css">
  .norm        { line-height: 120%; font-family: verdana; font-size: 10pt }

  </style>


  <?php include "top.php"; ?>

<FORM METHOD=POST ACTION="http://ssl.securesites.com/cart.pl">
<p align="center">
<b><font size="4" face="Verdana">Step 1: <font color="#800000">Tell Us Your Front Sight Date &amp; Course</font><br></font>


<select name="custom"  size="1">

<?php foreach ($classesRecords as $record): ?>
<option value="<?php echo $record['classNum'] ?> "/><?php echo $record['classNum'] ?> </option>
<?php endforeach ?></select>
</b>

<INPUT TYPE=HIDDEN NAME=return VALUE="http://www.stockpiledefensefsnv.com/order.php">
<INPUT TYPE=HIDDEN NAME=merchant  VALUE="exedor1">
<INPUT TYPE=HIDDEN NAME=name   VALUE="Front Sight Date &amp; Course"/>

<INPUT TYPE=HIDDEN NAME=custom2  VALUE="<?php echo $record['cname'] ?> "/>
<INPUT TYPE=HIDDEN NAME=custom1  VALUE="<?php echo $record['cday'] ?> "/>
<INPUT TYPE=HIDDEN NAME=price  VALUE="$0.00"/>

<INPUT TYPE=submit NAME="add"   VALUE="STEP 1: Add Class to Cart"></p>
</FORM>

<p align="center">


<b><font size="4" face="Verdana"><font color="#800000">Select your preference</font>&nbsp;
<a target="handgun" href="handgunorder.php">Handgun</a> | <a target="handgun" href="shotgunorder.php">Shotgun</a> | <a target="handgun" href="skitsorder.php">Shotgun Kits</a>
| <a target="handgun" href="rifleorder.php">Rifle</a> </font></b></p>
</p>
<p align="center">
<iframe width="948" height="1755" src="plist.php" name="handgun" border="0" frameborder="0"></iframe>
 </p>

 <?php include "footer.php"; ?>

Patricia

www.thenetgirl.com

Hi,

So you want to combine the num, cday and cname field values into one value, and display it in the options for the drop down?  

I think you need to modify your code slightly so that it looks like this:

<?php
Here is my code- 
  // load records from 'classes'
  list($classesRecords, $classesMetaData) = getRecords(array(
    'tableName'   => 'classes',
    'loadUploads' => true,
    'allowSearch' => true,
  ));
  
  ?>

 <style type="text/css">
  .norm        { line-height: 120%; font-family: verdana; font-size: 10pt }

  </style>


  <?php include "top.php"; ?>

<FORM METHOD=POST ACTION="http://ssl.securesites.com/cart.pl">
<p align="center">
<b><font size="4" face="Verdana">Step 1: <font color="#800000">Tell Us Your Front Sight Date &amp; Course</font><br></font>


<select name="custom"  size="1">

<?php foreach ($classesRecords as $record): ?>
   $classNum = $record['num'].$record['cday'].$record['cname'];
<option value="<?php echo $classNum; ?> "/><?php echo $classNum; ?> </option>
<?php endforeach ?></select>
</b>

<INPUT TYPE=HIDDEN NAME=return VALUE="http://www.stockpiledefensefsnv.com/order.php">
<INPUT TYPE=HIDDEN NAME=merchant  VALUE="exedor1">
<INPUT TYPE=HIDDEN NAME=name   VALUE="Front Sight Date &amp; Course"/>

<INPUT TYPE=HIDDEN NAME=custom2  VALUE="<?php echo $record['cname'] ?> "/>
<INPUT TYPE=HIDDEN NAME=custom1  VALUE="<?php echo $record['cday'] ?> "/>
<INPUT TYPE=HIDDEN NAME=price  VALUE="$0.00"/>

<INPUT TYPE=submit NAME="add"   VALUE="STEP 1: Add Class to Cart"></p>
</FORM>

<p align="center">


<b><font size="4" face="Verdana"><font color="#800000">Select your preference</font>&nbsp;
<a target="handgun" href="handgunorder.php">Handgun</a> | <a target="handgun" href="shotgunorder.php">Shotgun</a> | <a target="handgun" href="skitsorder.php">Shotgun Kits</a>
| <a target="handgun" href="rifleorder.php">Rifle</a> </font></b></p>
</p>
<p align="center">
<iframe width="948" height="1755" src="plist.php" name="handgun" border="0" frameborder="0"></iframe>
 </p>

 <?php include "footer.php"; ?>

So each $classesRecord value is combined into a string in the value classNum. Then the value is displayed and the option and value for each drop down item.

Let me know if you have any questions. 

Thanks!

Greg

Greg Thomas







PHP Programmer - interactivetools.com