PDA

View Full Version : Pass from Form to Recordset....



justjay
01-21-2004, 01:09 AM
OK so how far off in left field am I with this one??

Step ONE - Fill out the form to get the $Data we need for the RECORDSET


<form action="transportation.php" method="post" enctype="application/x-www-form-urlencoded" name="form1" target="_self">
<table width="100%" border="0" cellspacing="2" cellpadding="0">
<tr>
<td>Time</td>
<td><input name="Time" type="text" id="Time" value="00:00:00"></td>
</tr>
<tr>
<td>Bus</td>
<td align="left"><select name="Bus" id="Bus">
<option value="34">34</option>
<option value="125">125</option>
</select></td>
</tr>
<tr>
<td>Stop</td>
<td align="left"><select name="Stop" id="Stop">
<option value="Home">Home</option>
<option value="Dare">Dare</option>
<option value="Viau">Viau</option>
<option value="Papineau">Papineau</option>
</select></td>
</tr>
<tr>
<td>Direction</td>
<td align="left">East
<input name="Direction" type="radio" value="east" checked>
West
<input name="Direction" type="radio" value="west"></td>
</tr>
<tr>
<td>Schedule</td>
<td align="left"><select name="Schedule" id="Schedule">
<option value="Weekday">Weekday</option>
<option value="Saturday">Saturday</option>
<option value="Sunday">Sunday</option>
</select></td>
</tr>
<tr>
<td>&nbsp;</td>
<td align="right"><input name="Submit" type="submit" class="buttonblue" onClick="MM_openBrWindow('sched_bus.php','sched','toolbar=y es,location=yes,scrollbars=yes,resizable=yes,width =433,height=375')" value="Search"></td>
</tr>
</table>
</form>

Step 2 - Click SEARCH - new window will pop open

Step 3 - Look at new window that should display data based on a recordset thta was established from previous form



<?php require_once('../Connections/jehmconnect.php'); ?>
<?php
$maxRows_Sched = 10;
$pageNum_Sched = 0;
if (isset($_GET['pageNum_Sched'])) {
$pageNum_Sched = $_GET['pageNum_Sched'];
}
$startRow_Sched = $pageNum_Sched * $maxRows_Sched;

$colname_Sched = "08:00:00";
if (isset($_GET['Time'])) {
$colname_Sched = (get_magic_quotes_gpc()) ? $_GET['Time'] : addslashes($_GET['Time']);
}
$colname5_Sched = "Weekday";
if (isset($_GET['Schedule'])) {
$colname5_Sched = (get_magic_quotes_gpc()) ? $_GET['Schedule'] : addslashes($_GET['Schedule']);
}
$colname2_Sched = "34";
if (isset($_GET['Bus'])) {
$colname2_Sched = (get_magic_quotes_gpc()) ? $_GET['Bus'] : addslashes($_GET['Bus']);
}
$colname3_Sched = "home";
if (isset($_GET['Stop'])) {
$colname3_Sched = (get_magic_quotes_gpc()) ? $_GET['Stop'] : addslashes($_GET['Stop']);
}
$colname4_Sched = "east";
if (isset($_GET['Direction'])) {
$colname4_Sched = (get_magic_quotes_gpc()) ? $_GET['Direction'] : addslashes($_GET['Direction']);
}
mysql_select_db($database_jehmconnect, $jehmconnect);
$query_Sched = sprintf("SELECT * FROM Transportation WHERE Time = '%s' AND Bus = '%s' AND Stop = '%s' AND Direction = '%s' AND Schedule = '%s'", $colname_Sched,$colname2_Sched,$colname3_Sched,$co lname4_Sched,$colname5_Sched);
$query_limit_Sched = sprintf("%s LIMIT %d, %d", $query_Sched, $startRow_Sched, $maxRows_Sched);
$Sched = mysql_query($query_limit_Sched, $jehmconnect) or die(mysql_error());
$row_Sched = mysql_fetch_assoc($Sched);

if (isset($_GET['totalRows_Sched'])) {
$totalRows_Sched = $_GET['totalRows_Sched'];
} else {
$all_Sched = mysql_query($query_Sched);
$totalRows_Sched = mysql_num_rows($all_Sched);
}
$totalPages_Sched = ceil($totalRows_Sched/$maxRows_Sched)-1;
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>STM Bus Schedule</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="../style.css" rel="stylesheet" type="text/css">
</head>

<body>
<table width="400" border="0" cellspacing="2" cellpadding="0">
<tr>
<td><img src="http://www.thejehm.net/images/logo_colour.gif"></td>
</tr>
<tr>
<td>&nbsp;
<table border="0" cellpadding="2" cellspacing="3">
<tr>
<td>Schedule</td>
<td bgcolor="#EFEFEF"><strong>Bus</strong></td>
<td><strong>Stop</strong></td>
<td bgcolor="#EFEFEF"><strong>Direction</strong></td>
<td><strong>Time</strong></td>
</tr>
<?php do { ?>
<tr>
<td><?php echo $row_Sched['Schedule']; ?></td>
<td bgcolor="#EFEFEF"><strong><?php echo $row_Sched['Bus']; ?></strong></td>
<td><strong><?php echo $row_Sched['Stop']; ?></strong></td>
<td bgcolor="#EFEFEF"><strong><?php echo $row_Sched['Direction']; ?></strong></td>
<td><strong><?php echo $row_Sched['Time']; ?></strong></td>
</tr>
<?php } while ($row_Sched = mysql_fetch_assoc($Sched)); ?>
</table></td>
</tr>
<tr>
<td align="right"><a href="javascript:window.close();" target="_self">Close this window</a> </td>
</tr>
</table>
</body>
</html>
<?php
mysql_free_result($Sched);
?>


{bracing for replies}

no_mac_jack
01-21-2004, 06:38 PM
Have You Tried It? :D:

I don't think you can really know if it works right unless you try it. The concept should work, but it's just a matter of seing if the code is just right when you run it.

~no_mac_jack

justjay
01-22-2004, 05:35 PM
of course I tried it and it doesnt work...this is code that I copied from the page that is live on the server...

no_mac_jack
01-22-2004, 07:01 PM
What did it do when you ran it? Is the second page of code transportation.php or is there a page between them (I assume the former). Your form is posting and then you're looking for data in the $_GET collection, so you might just not be getting any data to search with.

Don't know where to start, though, without knowing what point you're at.

Thx!

~no_mac_jack