[Zope-DB] How to pass variables?

Keith Klein kklein@ix.netcom.com
Wed, 31 Dec 1969 16:00:00 0000 ()


Iam a newbies in zope I need some assistance with passing of variables.
Iam connecting to a Msql DB with student table, l need to be able to
display the student, delete and update them. I've several ZSQL and DTML
method as below to assist me to achieve that. The showstudent dtml methord
is refferancing the edit, delete and addstudent DTML Methods. The
Showstudent form has buttons for the above, but when l click on the Edit
or
Delete button l get "error value Student_ID". And both delete and edit
DTML
method gives me an error "Missing input variable Student_ID"
How do l go about doing this? How do l pass the Student_ID variable into
those Dtml method.
I will be grateful for your assistance



DTML Method "ListStudent" to list all student

<h2>Listing of Students</h2>
<ul>
    <dtml-in SelectAll>
    <li><dtml-var Student_ID><dtml-var Name>
    <br>
    <font size="-1"><a href="edit?Student_ID=<dtml-var
Student_ID>">Edit</a>|<a
  href="delete?Student_ID=<dtml-var Student_ID>">Delete</a></font>
   <p>
   </dtml-in>
</ul>
<a href="AddStudent">Add a New Student</a>



ZSQL Method "SelectAll" to select all  from student table

select * from Student



ZSQL Method "SelectStudent" to select one student


select * from Student where
Student_ID=<dtml-sqlvar Student_ID type="int">



ZSQL Method "UpdateStudent" to update student

Update Student set
Student_ID=<dtml-sqlvar Student_ID type="int">,
Name=<dtml-sqlvar Name type="string">,
Advisor_Name=<dtml-sqlvar Advisor_Name type="string">,
Grade=<dtml-sqlvar Grade type="string">,
Homeroom=<dtml-sqlvar Homeroom type="string">
where Student_ID=<dtml-sqlvar Student_ID type="int">



DTML Methord "delete" to delete a record

<dtml-var standard_html_header>

<dtml-call deleteMethord>
<h2>Student record deleted!</h2>
<p>
<a href="ListStudent">View a listing of students</a> or <a
href="AddStudent">Add another Student</a>
<dtml-var standard_html_footer>


ZSQL Methord to "deleteMethod" one row from student table

Delete from Student where Student_ID=<dtml-sqlvar Student_ID type="int">



DTML Method "edit" to edit a record

<dtm-var standard_html_header>

<dtml-if submit>

<dtml-call UpdateStudent>
<h2>Record Edited</h2>
<p>
<a href="ListStudent">View Student Listing</a><a href="AddStudent">Add
another Student</a>

<dtml-else>
<h2 align="center">Edit Student Record</h2>

<dtml-in SelectStudent>

<form action="edit" method="Post">
<table bgcolor="#00dcfd" align="center" border="6" cellpadding="3"
cellspacing="1" width="60%">
<tr>
<th align="center">Student_ID</th>
<th align="center">Name</th>
<th align="center">Advisor_Name</th>
<th align="center">Grade</th>
<th align="center">Homeroom</th>
</tr>
<tr>
<td><input name="Student_ID" width="10" value="<dtml-var
name="Student_ID">"></td>
<td><input name="Name" width="20" value="<dtml-var name="Name">"></td>
<td><input name="Advisor_Name" width=20 value="<dtml-var
name="Advisor_Name">"></td>
<td><input name="Grade" width=10 value="<dtml-var name="Grade">"></td>
<td><input name="Homeroom" width=20 value="<dtml-var
name="Homeroom">"></td>
</tr>
<tr></tr>
<tr>
<td colspan="5" align="center">
<input type="hidden" name="Student_ID" value=<dtml-var name="Student_ID">>
<input type="submit" name="submit" value="Edit Rec"></td></tr>
</table>
</form>
</dtml-in>
</dtml-if>
<dtml-var standard_html_footer>



DTML Method "ShowStudent" to display all student in a form with
Edit,Delete,Addstudent buttons.

<dtml-var standard_html_header>
<h2>Listing of Students</h2>
<table border="1" cellspacing="3" cellpadding="5" width="60%">
<tr>
<td>Student Id</td><td>Student Name</td>
</tr>
<tr>
<td>
<dtml-in SelectAll>
   <table border="1" align="center" width="100%">
   <dtml-if sequence-even>
   <tr bgcolor="#0cbea4">
   <dtml-else></tr>
   </dtml-if>
   <td>
      <form action="." methord="get">
      <input type="checkbox" name="Student_ID" value="<dtml-var
Student_ID>"></td>
      <td size="10" width="20%"><dtml-var Student_ID></td>
      <td size="45" width="100%"><dtml-var Name></td>
      </form>
   </tr>
   </table>
</dtml-in>
</td>
</tr>
<tr>
   <table border="0" width="40%">
   <tr>
   <td><form action="edit?Student_ID=<dtml-var Student_ID>" method="get">
       <input type="submit" name="edit" value="Edit"></form></td>
   <td><form action="delete?Student_ID=<dtml-var Student_ID>"
method="get">
       <input type="submit" name="delete" value="Delete"><form></td>
   <td><form action="AddStudent" method="get">
       <input type="submit" name="AddStudent" value="Add A
Student"></form></td>
   </tr>
   </table>
</tr>
</table>








_______________________________________________
Zope-DB mailing list
Zope-DB@zope.org
<a target=_blank
href="http://mail.zope.org/mailman/listinfo/zope-db">http://mail.zope.org/mailman/listinfo/zope-db</a>