Ok. Starting over. Here is the script that "generates" the variable "new_passengers_curr_customers":<br><br>#!/usr/bin/python<br><br>import cgitb; cgitb.enable()<br>import cgi<br>import sys,os<br>sys.path.append(os.getcwd())<br>
import MySQLdb<br>from login import login<br>from Curr_Passengers_Table import Curr_Passengers_Table<br><br>def create_edit_passengers():<br>  print "Content-Type: text/html"<br>  print<br>  print '''<br>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "<a href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd</a>"><br><head xmlns="<a href="http://www.w3.org/1999/xhtml">http://www.w3.org/1999/xhtml</a>"><br>
</head><br><body><br>'''<br>  user, passwd, db, host = login()<br>  database = MySQLdb.connect(host, user, passwd, db)<br>  cursor = database.cursor()<br>  form = cgi.FieldStorage()<br>  flight = form.getfirst('flight')<br>
  try:<br>    cursor.execute('select <a href="http://c.id">c.id</a>, <a href="http://p.name">p.name</a>, p.weight, c.first_name, c.middle_name, c.last_name, c.suffix from Passengers p join Customers c where p.flights_id=%s;', flight)<br>
    passengers = cursor.fetchall()<br>  except MySQLdb.ProgrammingError:<br>    passengers = []<br>  cursor.execute('select * from Flights where id=%s;', flight)<br>  flight_data = cursor.fetchone()<br>  print "<b>You have selected flight #%s, departing %s from %s and arriving %s at %s.</b><br /><br />" % (flight_data[0], flight_data[2], flight_data[5], flight_data[3], flight_data[6])<br>
  if len(passengers) > 0:<br>    print '<form method="post" action="create_edit_passengers3.py">\n'<br>    Curr_Passengers_Table(passengers)<br>    print "<h2>Add Passengers</h2>"<br>
  else:<br>    print "There are currently no passengers enrolled in this flight. Please enter some."<br>    print '<form method="post" action="create_edit_passengers3.py">\n'<br>
<br>*** RIGHT HERE! ***<br><br>  print "<input type='text' size='2' maxlength='2' name='new_passengers_curr_customers' /><br />"<br>                                                         ^^^^^<br>
*** SEE IT? ***<br><br>  print "<input type='submit' value=' Send ' />"<br>  print '</body>\n</html>'<br>  cursor.close()<br><br>create_edit_passengers()<br><br><br><br>
Now, here's the form that *should* be able to access that variable:<br><br>!/usr/bin/python<br><br>import cgitb; cgitb.enable()<br>import cgi<br>import sys,os<br>sys.path.append(os.getcwd())<br>import MySQLdb<br>from login import login<br>
import fpformat<br>from New_Passengers_Curr_Customers import New_Passengers_Curr_Customers<br>from New_Passengers_Addl_Customers import New_Passengers_Addl_Customers<br>from New_Passenger import New_Passenger<br><br>form = cgi.FieldStorage()<br>
<br>def sortedDictValues(adict):<br>  items = adict.items()<br>  items.sort()<br>  return [value for key, value in items]<br><br>def create_edit_passengers3():<br>  print "Content-Type: text/html"<br>  print<br>
  print '''<br><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "<a href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd</a>"><br>
<head xmlns="<a href="http://www.w3.org/1999/xhtml">http://www.w3.org/1999/xhtml</a>"><br></head><br><body><br>'''<br>  user, passwd, db, host = login()<br>  database = MySQLdb.connect(host, user, passwd, db)<br>
  cursor = database.cursor()<br>  cursor.execute('select id from Flights;')<br>  flights = [itm[0] for itm in cursor]<br>  cursor.execute('select id, first_name, middle_name, last_name, suffix from Customers;')<br>
  customers = cursor.fetchall()<br>  try:<br>    cursor.execute('select <a href="http://p.id">p.id</a>, c.first_name, c.middle_name, c.last_name, c.suffix, c.discount, p.flights_id, <a href="http://p.name">p.name</a>, f.price, <a href="http://c.id">c.id</a> from Customers c join Passengers p on <a href="http://c.id">c.id</a>=p.customer_id join Flights f on p.flights_id=<a href="http://f.id">f.id</a>;')<br>
    passengers = cursor.fetchall()<br>    print '<form method="post" action="create_edit_passengers4.py">\n'<br>    start_html = "<table border='2'>\n  <tr>\n    <td><b>Delete?</b></td>\n    <td><b>Flight</b></td>\n    <td><b>Name</b></td>\n    <td><b>Discount</b></td>\n    <td><b>Price</b></td>\n  </tr>\n"<br>
    passengers_html = []<br>    ids = []<br>    i = 0<br>    for passenger in passengers:<br>      do_delete = form.getfirst('%s:delete' % passenger[0])<br>      passengers_html, i = New_Passenger(passengers_html, passenger, do_delete, flights, ids, i)<br>
    printHTML = sortedDictValues(dict(zip(ids, passengers_html)))<br>    if len(printHTML) > 0:<br>      print start_html<br>    for html in printHTML:<br>      print html<br>    print "</table>"<br>  except MySQLdb.ProgrammingError:<br>
    pass<br><br>*** NOTE THIS: ****<br>  new_passengers_curr_customers = New_Passengers_Curr_Customers(customers, flights)<br>*** THAT LINE ****<br><br>  if new_passengers_curr_customers > 0:<br>    print "<input type='submit' value=' Send ' />"<br>
  print '</body>\n</html>'<br>  cursor.close()<br><br>create_edit_passengers3()<br><br><br>See that line that I marked right at the end? So here's that script:<br><br>#!/usr/bin/python<br><br>import cgitb; cgitb.enable()<br>
import cgi<br><br>form = cgi.FieldStorage()<br><br>def New_Passengers_Curr_Customers(customers, flights):<br><br>*** RIGHT HERE. SEE THIS LINE? WHY DOES IT WORK HERE AND NOT IN THE 2ND SCRIPT IN THIS HERE EMAIL WHERE IT SHOULD WORK???***<br>
  new_passengers_curr_customers = int(form.getfirst('new_passengers_curr_customers', 0))<br>*** THAT LINE ABOVE. RIGHT ABOVE HERE. OK?? ***<br><br>  print "<input type='hidden' name='new_passengers_curr_customers' value='%d' />" % new_passengers_curr_customers<br>
  if new_passengers_curr_customers > 0:<br>    print "<table border='1'>\n"<br>    print "  <tr>\n    <td colspan='2' align='center'><b>From Current Customers</b></td>\n  </tr>"<br>
    print "  <tr>\n    <td><b>Flight</b></td>\n    <td><b>Customer</b></td>\n  </tr>"<br>  i = 0<br>  while i < new_passengers_curr_customers:<br>    print "  <tr>"<br>
    print "    <td><select name='%d:curr:flight'>" % i<br>    for flight in flights:<br>      print "      <option>%s</option>" % flight<br>    print "    </select></td>"<br>
    print "    <td><select name='%d:curr:customer'>" % i<br>    for customer in customers:<br>      print "      <option value='%s'>%s %s %s %s</option>" % (customer[0], customer[1], customer[2], customer[3], customer[4])<br>
    print "    </select></td>"<br>    print "  </tr>"<br>    i += 1<br>  if new_passengers_curr_customers > 0:<br>    print "</table>"<br>  return new_passengers_curr_customers<br>
<br>Ok. So I think that was clear now. <br>TIA,<br>beno<br>