Forum Moderators: coopster
Is there something magic about working with space divided character strings that I've missed in the documentation?!
The following is the otherwise working current code:
These variable assignments are in the header:
$State = ($_POST['State']);
$Stop = ($_POST['Stop']);
These assignments are used in various queries to pull data from a number of different tables to render the page, including a means to tour the current stop, if any tour data exists, by this code:
function TourLink()
{
global $Category, $State, $Stop;
$query1 = "SELECT * FROM `Contacts` WHERE `Category` IN ( 'Visitor Source', 'Accommodation', 'Activity', 'Attraction', 'Business', 'Food/Beverage', 'Service - General', 'Health Service', 'Official', 'Shopping', 'Link Only') AND `PriSt` = '$State' AND `Stop` = '$Stop' ";
$result1 = mysql_query($query1)
or die ("No Visitors' Services Found.");
$num_rows1 = mysql_num_rows($result1);
if ($num_rows1!= 0)
{
echo "<form action='../Current/TourStop.php' method='POST'>\n";
echo "<input type='hidden' name='Stop' value=$Stop>";
echo "<input type='hidden' name='State' value=$State>";
echo "<input type='submit' value=\"Tour $Stop\">";
echo "</form>";
There is also dynamic selection of subsequent westward or eastward stops available to the view, based on the current stop selection.
Westward stops available are provided by this means (eastward is the same, with E replacing the W:
function MPWest()
{
global $State, $Stop, $MPWB, $MPW_FrStop, $MPW_FrState ;
$query2 = "SELECT DISTINCT `MPWB`,`MPW_FrStop`,`MPW_FrState` FROM `Stops` WHERE `Stop` = '$Stop' AND `State` = '$State' AND `MPWB` > 0 ORDER BY `MPWB` ASC";
$result2 = mysql_query($query2)
or die ("MPWest query failed.");
$num_rows2 = mysql_num_rows($result2);
if ($num_rows2 == 0)
{
echo "<tr><td colspan=\"2\">End of Line</td></tr>";
}
while ($row2 = mysql_fetch_array($result2,MYSQL_ASSOC))
{
extract ($row2);
$MPWB =$row2["MPWB"];
$MPW_FrStop =$row2["MPW_FrStop"];
$MPW_FrState =$row2["MPW_FrState"];
echo "<tr><td>$MPWB</td>";
echo "<td>$MPW_FrStop, $MPW_FrState</td></tr>";
}
}
This is my absolute last barrier to releasing this to my site, and I really want to finish and take some time off.
PLEASE HELP!
Deb :{
echo "<input type='hidden' name='Stop' value=$Stop>";
echo "<input type='hidden' name='State' value=$State>";
Deb,
try changing the line above to this:
echo "<input type='hidden' name='Stop' value='".$Stop."'>";
If you don't have quotes around the value, it won't understand that what is after the space is part of the value. If you do have the quotes, it will take everything inside the quotes as part of the string.
It worked perfect in the TourLink (); function -- thank you!
BUT (and I just saw that I pasted the wrong function for the Next Stops code, above), when I tried including the same quotation sequences in the Next Stop function, it broke!
Here's the function:
function NextStops()
{
global $Line_Subdiv, $Stop, $State, $NextWestStop, $NextWestState, $NextEastStop, $NextEastState;
$query4 = "SELECT DISTINCT `Line_Subdiv`,`Stop`,`State`,`NextWestStop`,`NextWestState`,`NextEastStop`,`NextEastState` FROM `Stops` WHERE `Stop` = '$Stop' AND `State` = '$State' ORDER BY `Line_Subdiv` ASC";;
$result4 = mysql_query($query4)
or die ("NextStops query failed.");
$num_rows4 = mysql_num_rows($result4);
if ($num_rows4 == 0)
{
echo "<tr><td colspan=\"4\">No Destinations Found.</td></tr>";
}
while ($row4 = mysql_fetch_array($result4,MYSQL_ASSOC))
{
extract ($row4);
$Line_Subdiv = $row4["Line_Subdiv"];
$NextWestStop = $row4["NextWestStop"];
$NextWestState = $row4["NextWestState"];
$NextEastStop = $row4["NextEastStop"];
$NextEastState = $row4["NextEastState"];
echo "<tr>";
if ($NextWestStop == '')
{
echo "<td width=\"25%\"></td>";
}
else
{
echo "<td width=\"25%\">";
echo "<form action='../Current/StopIndex.php' method='POST'>\n";
echo "<input type='hidden' name='Stop' value='".$NextWestStop."'>";
echo "<input type='hidden' name='State' value=$NextWestState>";
echo "<input type='submit' value=\"$NextWestStop, $NextWestState\">";
echo "</form>";
echo "</td>";
}
echo "<td class=\"Welcome\" width=\"50%\"><h5>$Line_Subdiv</h5></td>";
if ($NextEastStop == '')
{
echo "<td width=\"25%\"></td>";
}
else
{
echo "<td width=\"25%\">";
echo "<form action='../Current/StopIndex.php' method='POST'>\n";
echo "<input type='hidden' name='Stop' value='".$NextEastStop."'>";
echo "<input type='hidden' name='State' value=$NextEastState>";
echo "<input type='submit' value=\"$NextEastStop, $NextEastState\">";
echo "</form>";
}
echo "</tr>";
}
}
Obviously, I've misunderstood the need to add the '". before and ."' after the variable name, but I am open to instructions!
Thanks, again, for the fix on the TourLink function!
Deb 8)
$text1 = "anybody";
$text2 = "Is there $text1 in there?"; // Is there anybody in there
$text3 = 'Is there $text1 in there?'; // Is there $text1 in there - the variable is not being parsed
$text4 = 'Is there '. $text1 .' in there?'; // Is there anybody in there - the variable is outside quotes, concatenated by dot.
I would correct all of them to:
else
{
?>
<td width="25%">
<form action="../Current/StopIndex.php" method="POST">
<input type="hidden" name="Stop" value="<?php echo $NextWestStop;?>">
<input type="hidden" name="State" value="<?php echo $NextWestState;?>">
<input type="submit" name="action" value="<?php echo "$NextWestStop, $NextWestState";?>">
</form>
</td>
<?php
}
echo "<td class=\"Welcome\" width=\"50%\"><h5>$Line_Subdiv</h5></td>";
if ($NextEastStop == '')
{
echo "<td width=\"25%\"></td>";
}
else
{
echo "<td width=\"25%\">";
echo "<form action=\"../Current/StopIndex.php\" method=\"POST\">\n";
echo "<input type=\"hidden\" name=\"Stop\" value=\"$NextEastStop\">";
echo "<input type=\"hidden\" name=\"State\" value=\"$NextEastState\">";
echo "<input type=\"submit\" value=\"$NextEastStop, $NextEastState\">";
echo "</form>";
}
echo "</tr>";
I mixed two ways to write this on purpose.
Hope this cleares some things for you, and works fine
Regards
Michal
brevetoxin;
Sorry - by "broke, I mean that the page renders but the display indicates that the truncated character string did not result in any query results -- as it should, since no stops exist in that character string.
mcibor;
I was confused by your recommendation to name the variables "outside the quotes" -- this is all in a function. I probably am not communicating well, because I'm a little dazed from trying to get these working over the past four month.
How does it help to turn off PHP then reopening it to pick up the variables? Am I missing something?
Deb