Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

XML

Community Beginner ,
Aug 25, 2008 Aug 25, 2008
I'm a newbie, and need some help. I'm using Dreamweaver CS3, PHP and MySql.

I have a table in a database with columns for user_id and event_id which is created dynamically by users with an insert record query. That all works fine. Basically this a database of partnership requests with the event id and user id for every partnership request.

1) I want to build a page that in one area shows the logged in user all the rows in the table where the user_id in the xml dataset is the same as the logged in users id. Basically show the user all his/her partnership requests.

2) Then once he clicks on a row in the table, I want a detail area to populate a table with any other users who have also requested partners for the event selected in step 1.

I think using an xml data set is the way to go, and I figured out how to create the xml from the database using the "Export Recordset as XML" feature in the Developer toolbox.

I think for step 1, I need to filter the dataset to only include the records where the user id in the table matches the user's id. Then for step 2, I'd like to filter the dataset to show all the records where event id = the event id of the selected event AND where the user id != the user's id.

But I don't have a clue how to filter the dataset to show only the required records, either for step 1 or for step 2. The help in http://livedocs.adobe.com/en_US/Spry/1.4/help.html?content=WS91F7A90B-4E4B-48da-A0BA-444F5D23C02D.ht... must assume knowledge I don't have, as I don't have a clue where to put the code they suggest. It doesn't look like what would go in a PhP page.

I think I could do it using multiple pages and session variables, but it would be a million times nicer to do it all on one page and have it update the second table when the user selects rows in the first table.

Any tips/help would be greatly appreciated. Is there a tutorial somewhere that explains in more detail how to work with xml datasets?

Bert Onstott
TOPICS
Server side applications
307
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 26, 2008 Aug 26, 2008
OK, still muddling along. Can anyone answer why this doesn't work:

var dsmyrequests = new Spry.Data.XMLDataSet("export.php", "requests/request",{useCache:false});
// Filter out all rows where the user id isn't equal to the logged in user's id.

var myFilterFunc = function(dataSet, row, rowNumber)
{
if (row["user_id"].search(<?php echo $_SESSION['User_ID']; ?>) != -1)
return row; // Return the row to keep it in the data set.
return null; // Return null to remove the row from the data set.
}
dsmyreuests.filter(myFilterFunc);
dsmyrequests.setColumnType("event_id", "number");
dsmyrequests.setColumnType("user_id", "number");

It doesn't give an error, just doesn't filter anything.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Aug 26, 2008 Aug 26, 2008
LATEST
real quick and dirty way I found to filter out XML stuff is using the spry commands.

Here is the code that I used for a filtered drop down for a project I am working on:


<div align="center">
<select name="bpo_select" id="bpo_select">
<option value="{bpo_name}" spry:repeat="ds1" spry:setrow="ds1" spry:if="'{char_name}'=='<?php echo $_SESSION['kt_char_name']; ?>'">{bpo_name}</option>
</select>
<br />
<br />
</div>

The above example is for a drop down, that only displays data if the column char_name column is equal to the char_name session.

For working with tables, you'll need to nest the <div>s together to get the filter:

<div align="center" spry:region="dsVideoList" spry:repeat="dsVideoList">

<div spry:detailregion ="dsVideoList" spry:setrow="dsVideoList" spry:if="'{char_name}'=='<?php echo $_SESSION['kt_char_name']; ?>'">

So basically, you use the Spry Data Sheet to import the XML. Then to filter it out, you'll use:

spry:if = " ' {spry dynamic source} ' == ' variable ' "

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines