|
Convenient web based access to our favorite web design Usenet groups
|
 |
This is Interesting: Free Magazines for Graphics designers and webmasters
| Author |
| Thread |
 |
|
|
|
|
|
 |
 |
|
|
 |
|
|
 |
|
|
 |
 |
Re: Sorting a Dynamic Table - is there a tutorial yet? |
 |
|
 |
|
|
|
  12-29-05 - 03:15 AM
|
Thanks Peter, but surely there's a way to learn this without having to pay f
or
the lesson? Or buy an extension?
Patty, this is kinda continued from this thread http://tinyurl.com/8hfha -
from the General Discussion here.
I can only work with PHP ... and perl, maybe? - my host/server can't handle
ASP or ColdFusion.
Operating system Linux
Apache version 1.3.33 (Unix)
PHP version 4.3.10
MySQL version 4.0.25-standard
I know how to create recordsets and dynamic tables in Dreamweaver. I need t
o
be able to sort the tables though. An example of what I've got is here
http://www.lady18wheels.com/phpbb_data/by_userID_02.php
It's pulling from the database of my phpBB2 message board.
The code looks like this:
<?php require_once('Connections/conn01.php'); ?>
<?php
$currentPage = $_SERVER["PHP_SELF"];
$maxRows_Recordset1 = 100;
$pageNum_Recordset1 = 0;
if (isset($_GET['pageNum_Recordset1'])) {
$pageNum_Recordset1 = $_GET['pageNum_Recordset1'];
}
$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;
mysql_select_db($database_conn01, $conn01);
$query_Recordset1 = "SELECT * FROM phpbb_users ORDER BY user_id DESC";
$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1,
$startRow_Recordset1, $maxRows_Recordset1);
$Recordset1 = mysql_query($query_limit_Recordset1, $conn01) or
die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
if (isset($_GET['totalRows_Recordset1'])) {
$totalRows_Recordset1 = $_GET['totalRows_Recordset1'];
} else {
$all_Recordset1 = mysql_query($query_Recordset1);
$totalRows_Recordset1 = mysql_num_rows($all_Recordset1);
}
$totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;
$queryString_Recordset1 = "";
if (!empty($_SERVER['QUERY_STRING'])) {
$params = explode("&", $_SERVER['QUERY_STRING']);
$newParams = array();
foreach ($params as $param) {
if (stristr($param, "pageNum_Recordset1") == false &&
stristr($param, "totalRows_Recordset1") == false) {
array_push($newParams, $param);
}
}
if (count($newParams) != 0) {
$queryString_Recordset1 = "&" . htmlentities(implode("&", $newParams));
}
}
$queryString_Recordset1 = sprintf("&totalRows_Recordset1=%d%s",
$totalRows_Recordset1, $queryString_Recordset1);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Sorted by UserID</title>
<style type="text/css">
<!--
.style1 {
font-family: Tahoma;
font-size: 10px;
font-weight: bold;
color: #000066;
}
-->
</style>
</head>
<body>
<span class="style1">Records <?php echo ($startRow_Recordset1 + 1) ?> to <?p
hp
echo min($startRow_Recordset1 + $maxRows_Recordset1, $totalRows_Recordset1)
?>
of <?php echo $totalRows_Recordset1 ?></span>
<table border="2" class="style1">
<tr>
<td><div align="center">user_id</div></td>
<td><div align="center">user_lastvisit</div></td>
<td><div align="center">user_regdate</div></td>
<td><div align="center">user_posts</div></td>
</tr>
<?php do { ?>
<tr align="center" valign="top">
<td><div align="center"><?php echo $row_Recordset1['user_id'];
?></div></td>
<td><div align="center"><!-- <?php echo $row_Recordset1['user_lastvisit'
];
?> --><?php echo date("m/d/y", ($row_Recordset1['user_lastvisit']));
?></div></td>
<td><div align="center"><!--<?php echo $row_Recordset1['user_regdate'];
?>
--><?php echo date("m/d/y", ($row_Recordset1['user_regdate'])); ?></div>
</td>
<td><div align="center"><?php echo $row_Recordset1['user_posts'];
?></div></td>
</tr>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
</table>
<table border="0" width="50%" align="left">
<tr align="left">
<td width="23%"><?php if ($pageNum_Recordset1 > 0) { // Show if not fir
st
page ?>
<a href="<?php printf("%s?pageNum_Recordset1=%d%s", $currentPage, 0,
$queryString_Recordset1); ?>">First</a>
<?php } // Show if not first page ?>
</td>
<td width="31%"><?php if ($pageNum_Recordset1 > 0) { // Show if not fir
st
page ?>
<a href="<?php printf("%s?pageNum_Recordset1=%d%s", $currentPage,
max(0, $pageNum_Recordset1 - 1), $queryString_Recordset1); ?>">Previous</a>
<?php } // Show if not first page ?>
</td>
<td width="23%"><?php if ($pageNum_Recordset1 < $totalPages_Recordset1)
3;
// Show if not last page ?>
<a href="<?php printf("%s?pageNum_Recordset1=%d%s", $currentPage,
min($totalPages_Recordset1, $pageNum_Recordset1 + 1), $queryString_Recordset
1);
?>">Next</a>
<?php } // Show if not last page ?>
</td>
<td width="23%"><?php if ($pageNum_Recordset1 < $totalPages_Recordset1)
3;
// Show if not last page ?>
<a href="<?php printf("%s?pageNum_Recordset1=%d%s", $currentPage,
$totalPages_Recordset1, $queryString_Recordset1); ?>">Last</a>
<?php } // Show if not last page ?>
</td>
</tr>
</table>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>
I will be forever grateful if somebody, ANYBODY, can tell me how to make thi
s
thing sort!
|
|
|
| [
Post Follow-Up to this message ]
|
|
|
|
|
 |
|
|
 |
 |
Re: Sorting a Dynamic Table - is there a tutorial yet? |
 |
|
 |
|
|
|
  12-30-05 - 03:17 AM
|
Here's the idea.
In your SQL SELECT statement you can specify how to sort the recordset.
Make the SORT part depend on a fieldname variable. Make the column heads
link to the same page and pass the fieldname via a URL parameter, e.g.,
<a href="thispage.php?fieldtosortby">
Make the page use that URL variable in the SQL SORT clause, e.g.,
SELECT * FROM tablename SORT variable ASC
--
Murray --- ICQ 71997575
Team Macromedia Volunteer for Dreamweaver
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================
"Lady18wheels" <webforumsuser@macromedia.com> wrote in message
news:doviou$kq1$1@forums.macromedia.com...
> Thanks Peter, but surely there's a way to learn this without having to pay
> for
> the lesson? Or buy an extension?
> Patty, this is kinda continued from this thread
> http://tinyurl.com/8hfha -
> from the General Discussion here.
>
> I can only work with PHP ... and perl, maybe? - my host/server can't
> handle
> ASP or ColdFusion.
> Operating system Linux
> Apache version 1.3.33 (Unix)
> PHP version 4.3.10
> MySQL version 4.0.25-standard
>
> I know how to create recordsets and dynamic tables in Dreamweaver. I need
> to
> be able to sort the tables though. An example of what I've got is here
>
> http://www.lady18wheels.com/phpbb_data/by_userID_02.php
>
> It's pulling from the database of my phpBB2 message board.
>
> The code looks like this:
>
> <?php require_once('Connections/conn01.php'); ?>
> <?php
> $currentPage = $_SERVER["PHP_SELF"];
>
> $maxRows_Recordset1 = 100;
> $pageNum_Recordset1 = 0;
> if (isset($_GET['pageNum_Recordset1'])) {
> $pageNum_Recordset1 = $_GET['pageNum_Recordset1'];
> }
> $startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;
>
> mysql_select_db($database_conn01, $conn01);
> $query_Recordset1 = "SELECT * FROM phpbb_users ORDER BY user_id DESC";
> $query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1,
> $startRow_Recordset1, $maxRows_Recordset1);
> $Recordset1 = mysql_query($query_limit_Recordset1, $conn01) or
> die(mysql_error());
> $row_Recordset1 = mysql_fetch_assoc($Recordset1);
>
> if (isset($_GET['totalRows_Recordset1'])) {
> $totalRows_Recordset1 = $_GET['totalRows_Recordset1'];
> } else {
> $all_Recordset1 = mysql_query($query_Recordset1);
> $totalRows_Recordset1 = mysql_num_rows($all_Recordset1);
> }
> $totalPages_Recordset1 =
> ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;
>
> $queryString_Recordset1 = "";
> if (!empty($_SERVER['QUERY_STRING'])) {
> $params = explode("&", $_SERVER['QUERY_STRING']);
> $newParams = array();
> foreach ($params as $param) {
> if (stristr($param, "pageNum_Recordset1") == false &&
> stristr($param, "totalRows_Recordset1") == false) {
> array_push($newParams, $param);
> }
> }
> if (count($newParams) != 0) {
> $queryString_Recordset1 = "&" . htmlentities(implode("&",
> $newParams));
> }
> }
> $queryString_Recordset1 = sprintf("&totalRows_Recordset1=%d%s",
> $totalRows_Recordset1, $queryString_Recordset1);
> ?>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
> "http://www.w3.org/TR/html4/loose.dtd">
> <html>
> <head>
> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
> <title>Sorted by UserID</title>
> <style type="text/css">
> <!--
> .style1 {
> font-family: Tahoma;
> font-size: 10px;
> font-weight: bold;
> color: #000066;
> }
> -->
> </style>
> </head>
>
> <body>
> <span class="style1">Records <?php echo ($startRow_Recordset1 + 1) ?> to
> <?php
> echo min($startRow_Recordset1 + $maxRows_Recordset1,
> $totalRows_Recordset1) ?>
> of <?php echo $totalRows_Recordset1 ?></span>
> <table border="2" class="style1">
> <tr>
> <td><div align="center">user_id</div></td>
> <td><div align="center">user_lastvisit</div></td>
> <td><div align="center">user_regdate</div></td>
> <td><div align="center">user_posts</div></td>
> </tr>
> <?php do { ?>
> <tr align="center" valign="top">
> <td><div align="center"><?php echo $row_Recordset1['user_id'];
> ?></div></td>
> <td><div align="center"><!-- <?php echo
> $row_Recordset1['user_lastvisit'];
> ?> --><?php echo date("m/d/y", ($row_Recordset1['user_lastvisit']));
> ?></div></td>
> <td><div align="center"><!--<?php echo
> $row_Recordset1['user_regdate']; ?>
> --><?php echo date("m/d/y", ($row_Recordset1['user_regdate']));
> ?></div></td>
> <td><div align="center"><?php echo $row_Recordset1['user_posts'];
> ?></div></td>
> </tr>
> <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
> </table>
>
> <table border="0" width="50%" align="left">
> <tr align="left">
> <td width="23%"><?php if ($pageNum_Recordset1 > 0) { // Show if n
ot
> first
> page ?>
> <a href="<?php printf("%s?pageNum_Recordset1=%d%s", $currentPage,
> 0,
> $queryString_Recordset1); ?>">First</a>
> <?php } // Show if not first page ?>
> </td>
> <td width="31%"><?php if ($pageNum_Recordset1 > 0) { // Show if n
ot
> first
> page ?>
> <a href="<?php printf("%s?pageNum_Recordset1=%d%s", $currentPage,
> max(0, $pageNum_Recordset1 - 1), $queryString_Recordset1);
> ?>">Previous</a>
> <?php } // Show if not first page ?>
> </td>
> <td width="23%"><?php if ($pageNum_Recordset1 <
> $totalPages_Recordset1) {
> // Show if not last page ?>
> <a href="<?php printf("%s?pageNum_Recordset1=%d%s", $currentPage,
> min($totalPages_Recordset1, $pageNum_Recordset1 + 1),
> $queryString_Recordset1);
> ?>">Next</a>
> <?php } // Show if not last page ?>
> </td>
> <td width="23%"><?php if ($pageNum_Recordset1 <
> $totalPages_Recordset1) {
> // Show if not last page ?>
> <a href="<?php printf("%s?pageNum_Recordset1=%d%s", $currentPage,
> $totalPages_Recordset1, $queryString_Recordset1); ?>">Last</a>
> <?php } // Show if not last page ?>
> </td>
> </tr>
> </table>
>
>
> </body>
> </html>
> <?php
> mysql_free_result($Recordset1);
> ?>
>
>
>
> I will be forever grateful if somebody, ANYBODY, can tell me how to make
> this
> thing sort!
>
|
|
|
| [
Post Follow-Up to this message ]
|
|
|
|
|
 |
 |
Re: Sorting a Dynamic Table - is there a tutorial yet? |
 |
|
 |
|
|
|
  12-30-05 - 03:23 AM
|
(What are the quote tags here?)
Murray said, "Here's the idea. In your SQL SELECT statement you can specify
how to sort the recordset. Make the SORT part depend on a fieldname variabl
e.
Make the column heads link to the same page and pass the fieldname via a UR
L
parameter, e.g., <a href="thispage.php?fieldtosortby"> . Make the page use
that URL variable in the SQL SORT clause, e.g., SELECT * FROM tablename SORT
variable ASC"
Bless your heart Murry; you must have the patience of Job. I appreciate it.
OK. I think I don't understand what a fieldname variable is.
In a table, I have headers and fields, right?
Like the headers are user_id; user_lastvisit; user_regdate; and user_posts
.
I could have named them anything, but this is what Insert > Application
objects > Dynamic data > Dynamic table defaulted to (I think.)
The field names are
{Recordset1.user_id} - written like - <?php echo
$row_Recordset1['user_id']; ?>
{Recordset1.user_lastvisit} - written like - <?php echo
$row_Recordset1['user_lastvisit']; ?>
{Recordset1.user_regdate} - written like - <?php echo
$row_Recordset1['user_regdate']; ?>
{Recordset1.user_posts} - written like - <?php echo
$row_Recordset1['user_posts']; ?>
Am I right so far?
BTW - I thought I was on the brink of discovery when I posted this thread at
the phpBB forums: http://www.phpbb.com/phpBB/viewtopic.php?t=352655 . If I
could just post graphics here... .
And I found this in the Using Dreamweaver help section (of my software):
Creating a URL parameter to pass to the confirmation page (PHP)
"The links on the results page (see Creating links to a confirmation page
(PHP)) not only have to open the confirmation page, they must pass the ID of
the record the user wants to delete. The confirmation page will use this ID
to
find the record in the database and display it.
You must pass the record ID to the confirmation page with a URL parameter.
This section describes how to create a URL parameter to pass the record ID t
o
the confirmation page.
To create the URL parameter:
Select the delete link on the results page.
If Live Data is turned on, select the link in the first row.
In the Link field in the Property inspector, add the following string at the
end of the URL:
?recordID=<?php echo $row_recordsetName['fieldName']; ?>
The question mark tells the server that what follows is one or more URL
parameters. The word recordID is the name of the URL parameter (you can make
up
any name you like). Note the name of the URL parameter because you'll use it
in
the confirmation page later.
The expression after the equal sign is the value of the parameter. In this
case, the value is generated by a PHP expression that returns a record ID fr
om
the recordset. A different ID is generated for each row in the dynamic table
.
In the PHP expression, replace recordsetName with the name of your recordset
,
and replace fieldName with the name of the field in your recordset that
uniquely identifies each record. In most cases, the field will consist of a
record ID number. In the following example, the field consists of unique
location codes:
confirmDelete.php?recordID=<?php echo $row_rsLocations['CODE']; ?>
When the page runs, the values of the recordset's CODE field are inserted in
the corresponding rows in the dynamic table. For example, if the Canberra,
Australia, rental location has the code CBR, then the following URL will be
used in the Canberra row in the dynamic table:
confirmDelete.php?recordID=CBR
Save the page.
After creating a dynamic URL parameter for the delete links, the next step i
s
to display the record on the confirmation page. See Displaying the record on
the confirmation page (PHP)."
Does this sound like what I'm trying to do? LOL! (Please forgive my
ignorance.)
Thanks for your time.
|
|
|
| [
Post Follow-Up to this message ]
|
|
|
|
|
 |
 |
Re: Sorting a Dynamic Table - is there a tutorial yet? |
 |
|
 |
|
|
|
  12-30-05 - 03:24 AM
|
> (What are the quote tags here?)
Huh?
> In a table, I have headers and fields, right?
You have records and fields. Fields are the columns and records are the
rows.
> Like the headers are user_id; user_lastvisit; user_regdate; and
> user_posts.
Those are the fields.
> The field names are
> {Recordset1.user_id} - written like - <?php echo
> $row_Recordset1['user_id']; ?>
Actually that is the datum that is contained in the field called "user_id"
as selected in Recordset1.
> Am I right so far?
Sorta. 8)
But I will need to take this up again tomorrow morning. Duties call! 8)
--
Murray --- ICQ 71997575
Team Macromedia Volunteer for Dreamweaver
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================
"Lady18wheels" <webforumsuser@macromedia.com> wrote in message
news:dp1r4e$inr$1@forums.macromedia.com...
> (What are the quote tags here?)
>
> Murray said, "Here's the idea. In your SQL SELECT statement you can
> specify
> how to sort the recordset. Make the SORT part depend on a fieldname
> variable.
> Make the column heads link to the same page and pass the fieldname via a
> URL
> parameter, e.g., <a href="thispage.php?fieldtosortby"> . Make the page
> use
> that URL variable in the SQL SORT clause, e.g., SELECT * FROM tablename
> SORT
> variable ASC"
>
> Bless your heart Murry; you must have the patience of Job. I appreciate
> it.
>
> OK. I think I don't understand what a fieldname variable is.
>
> In a table, I have headers and fields, right?
> Like the headers are user_id; user_lastvisit; user_regdate; and
> user_posts.
> I could have named them anything, but this is what Insert > Application
> objects > Dynamic data > Dynamic table defaulted to (I think.)
>
> The field names are
> {Recordset1.user_id} - written like - <?php echo
> $row_Recordset1['user_id']; ?>
> {Recordset1.user_lastvisit} - written like - <?php echo
> $row_Recordset1['user_lastvisit']; ?>
> {Recordset1.user_regdate} - written like - <?php echo
> $row_Recordset1['user_regdate']; ?>
> {Recordset1.user_posts} - written like - <?php echo
> $row_Recordset1['user_posts']; ?>
>
> Am I right so far?
>
> BTW - I thought I was on the brink of discovery when I posted this thread
> at
> the phpBB forums: http://www.phpbb.com/phpBB/viewtopic.php?t=352655 . If
> I
> could just post graphics here... .
>
> And I found this in the Using Dreamweaver help section (of my software):
>
> Creating a URL parameter to pass to the confirmation page (PHP)
> "The links on the results page (see Creating links to a confirmation page
> (PHP)) not only have to open the confirmation page, they must pass the ID
> of
> the record the user wants to delete. The confirmation page will use this
> ID to
> find the record in the database and display it.
> You must pass the record ID to the confirmation page with a URL parameter.
> This section describes how to create a URL parameter to pass the record ID
> to
> the confirmation page.
> To create the URL parameter:
> Select the delete link on the results page.
> If Live Data is turned on, select the link in the first row.
> In the Link field in the Property inspector, add the following string at
> the
> end of the URL:
> ?recordID=<?php echo $row_recordsetName['fieldName']; ?>
> The question mark tells the server that what follows is one or more URL
> parameters. The word recordID is the name of the URL parameter (you can
> make up
> any name you like). Note the name of the URL parameter because you'll use
> it in
> the confirmation page later.
> The expression after the equal sign is the value of the parameter. In this
> case, the value is generated by a PHP expression that returns a record ID
> from
> the recordset. A different ID is generated for each row in the dynamic
> table.
> In the PHP expression, replace recordsetName with the name of your
> recordset,
> and replace fieldName with the name of the field in your recordset that
> uniquely identifies each record. In most cases, the field will consist of
> a
> record ID number. In the following example, the field consists of unique
> location codes:
> confirmDelete.php?recordID=<?php echo $row_rsLocations['CODE']; ?>
> When the page runs, the values of the recordset's CODE field are inserted
> in
> the corresponding rows in the dynamic table. For example, if the Canberra,
> Australia, rental location has the code CBR, then the following URL will
> be
> used in the Canberra row in the dynamic table:
> confirmDelete.php?recordID=CBR
> Save the page.
> After creating a dynamic URL parameter for the delete links, the next step
> is
> to display the record on the confirmation page. See Displaying the record
> on
> the confirmation page (PHP)."
>
> Does this sound like what I'm trying to do? LOL! (Please forgive my
> ignorance.)
> Thanks for your time.
>
>
>
>
>
|
|
|
| [
Post Follow-Up to this message ]
|
|
|
|
|
 |
|
|
 |
| All times are GMT. The time now is 11:23 PM. |
 |
|
|
|
|
|  |
|