473,406 Members | 2,745 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

<a href ..>Setting a variable before the page calls itself

Hi,

This exercise (From PAM525Web Development) asks me to display a table
of reviews, then sort the reviews depending on which column heading is
clicked.

I can't find how to write this line:

<th><a
href=movie_details03.php?movie_id=$movie_id&coll_s ort=\"review_date\">"Date
of Review"</th>

in this bit of code:

$review_table_headings=<<<EOD
<tr>
<th><a
href=movie_details03.php?movie_id=$movie_id&coll_s ort=\"review_date\">"Date
of Review"</th>
<th>Review Title</th>
<th>Reviewer Name</th>
<th>Movie Review Comments</th>
<th>Ratings</th>
</tr>
EOD;

The coll_sort variable is extracted by a GET

Feb 27 '06 #1
3 2305
universalbitmapper wrote:
Hi,

This exercise (From PAM525Web Development) asks me to display a table
of reviews, then sort the reviews depending on which column heading is
clicked.

I can't find how to write this line:

<th><a
href=movie_details03.php?movie_id=$movie_id&coll_s ort=\"review_date\">"Date of Review"</th>

in this bit of code:

$review_table_headings=<<<EOD
<tr>
<th><a
href=movie_details03.php?movie_id=$movie_id&coll_s ort=\"review_date\">"Date of Review"</th>
<th>Review Title</th>
<th>Reviewer Name</th>
<th>Movie Review Comments</th>
<th>Ratings</th>
</tr>
EOD;

The coll_sort variable is extracted by a GET

Hi,

You don't want " or ' in your url.
use urlencode to pass them around safely.
So try:
<?
$myUrl = "movie_detailso3.php";

// assuming $movie_id is a number, you do not need urlencoding
$myUrl .= "?movie_id=".$movie_id;

// assuming coll_sort need encoding:
$myUrl .= "&amp;coll_sort=".urlencode("revie_date");
?>
<a href="<?= $myUrl ?>">sort on review date</a>

Now receive it like:
$sortorder = $_GET["coll_sort"];

Also note the &amp; instead of &. It was not your problem, but the &amp; is
better, according to W3C.

Regards,
Erwin Moller

Feb 27 '06 #2
universalbitmapper wrote:
Hi,

This exercise (From PAM525Web Development) asks me to display a table
of reviews, then sort the reviews depending on which column heading is
clicked.

I can't find how to write this line:

<th><a
href=movie_details03.php?movie_id=$movie_id&coll_s ort=\"review_date\">"Date
of Review"</th>

in this bit of code:

$review_table_headings=<<<EOD
<tr>
<th><a
href=movie_details03.php?movie_id=$movie_id&coll_s ort=\"review_date\">"Date
of Review"</th>
<th>Review Title</th>
<th>Reviewer Name</th>
<th>Movie Review Comments</th>
<th>Ratings</th>
</tr>
EOD;

The coll_sort variable is extracted by a GET


I may have this screwed up, but isn't this just a case of setting a
default sort order and 'href'fing the headers?

If so, the form needs some top processing...

<?php
// use the specified column for sorting or sort by ratings by default
$coll_sort = isset($_GET['coll_sort']) ? $_GET['coll_sort'] : 'rating';

// select and order based on coll_sort
$sql = <<<SQL
select
movie_id,
title,
name,
comment,
rating
from
reviews
order by
$coll_sort;

$result = ....

I've assumed a database-backed form here. If this is just an array, then
you would use array sorts to do the same thing.

Then you would need to change the references to 'Review Title',
'Reviewer Name', etc. to be href links that set the coll_sort.

For example:
<th><a
href="movie_details03.php?movie_id=$movie_id&coll_ sort=title">Review
Title</th>

Notes:
Make the coll_sort value match the column name in the database unless
you are worried about exposing that level of implementation detail to
the user. If so, make sure to map the coll_sort name into a database
column name before you do the query.

There is no need to use the double quotes around the argument to
coll_sort in your href. The entire href= argument is already quoted.

Hope this helps.
-david-

Feb 27 '06 #3
I have tested two little scripts with &amp; in the href links and got
them to work
Many thanks for your replies

Feb 28 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: DC Gringo | last post by:
I'm getting a "BC30451: Name 'CRListType' is not declared." error Here's the top of the page where I'm getting stuck... <%@ Control Language="vb" AutoEventWireup="false"...
3
by: Paul Eghbal | last post by:
Hi all, I'm trying to use the following script: <script language="javaScript"> function setrepto(){ document.aForm.repno.value = document.aForm.rep.options.value; } </script>
8
by: Jim Moon | last post by:
Hi. I'm curious about this syntax: <variable>=function(){...} I'm not finding a definition of this syntax, but I see it used at this website:...
0
by: Henri | last post by:
Hi, I've built a custom control named Tree in MyNameSpace.Tree compiled into dans MyNameSpace.Tree.dll I've then designed a page index.asp with its code in index.aspx.vb (class PageIndex)....
5
by: Steve Richter | last post by:
I have a public variable ( "mZipServiceUrl" ) in my code behind class that I am able to substitute into the HTML of the .aspx file: <span onclick="WindowOpen('<%=mZipServiceUrl%>')"...
10
by: Phil Latio | last post by:
Just playing around with the idea of using a html template page to seperate the code from design. Very basic example below <html> <!-- hello.html --> <body> Hello <b><?php echo $message...
6
by: Jeff | last post by:
Hey ASP.NET 2.0 I've added some extra properties to the Profile of users on my site. One of the new properties is of type "string" and it contain HTML data.... like for example...
1
by: =?Utf-8?B?UGV0ZXI=?= | last post by:
Hi, I’m new to aspx and asp.net. We have a huge web based application developed in ASP. I started working with ASP.net and discovered the strength of this language. The idea is to start...
2
by: optimistx | last post by:
I try to develope a bookmarklet in javascript. The charset of the bookmarklet is UTF-8, but it is supposed to work within pages, whose character set is not UTF-8, but e.g. ISO-8859-1 or...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.