PDA

View Full Version : Spry or PHP help please


PaulF
03-11-2009, 11:04 AM
Hi all,

I need a bit of guidance with DW CS3, I have had a look at the spry widgets to produce a list of events, which when clicked gives more detail in the detail region. I must say I found this quite flaky to work with at best.

So my question is, now I have created a MYSQL table with the data how do I get a similar type of functionality or am I stuck using spry?

Regards

Paul

edbr
03-12-2009, 12:35 AM
yes you could using php/mysql is the simple answerhows your php knowledge?

PaulF
03-12-2009, 11:55 AM
Thanks for your time; I managed to get it to work, using just PHP.

I added a repeating list than recalled the page via a link to update table containing the detail fields. I will post the code if anyone is interested.

Once again thanks.

davidj
03-12-2009, 01:40 PM
post it

get it out for the members!

PaulF
03-12-2009, 06:36 PM
Here is the code, only two things left to do.


Always load the first record into the detail panel
look at how to reposition the page if it scrolls when an item is selected.Paul.

<?php
// Database connect
mysql_select_db($database_DB_Conn, $DB_Conn);
// Create the query
$query_RS_Placement = "SELECT * FROM placement ORDER BY type ASC";
// Runn the query
$RS_Placement = mysql_query($query_RS_Placement, $DB_Conn) or die(mysql_error());
// Look this up I think the current row
$row_RS_Placement = mysql_fetch_assoc($RS_Placement);
// is this the number of rows
$totalRows_RS_Placement = mysql_num_rows($RS_Placement);
?>
<body>
<?php
$colname_DetailRS1 = "-1";
// Was a record id passed in the URL?
if (isset($_GET['recordID'])) {
$colname_DetailRS1 = $_GET['recordID'];
}
else {
// If not show the default record, will change this to show first record...
$colname_DetailRS1 =4; // This is the default entry
}
// Build the query
$query_DetailRS1 = sprintf("SELECT * FROM placement WHERE id = %s ORDER BY type ASC", GetSQLValueString($colname_DetailRS1, "text"));
// Run the query
$DetailRS1 = mysql_query($query_DetailRS1, $DB_Conn) or die(mysql_error());
// Get the first record
$row_DetailRS1 = mysql_fetch_assoc($DetailRS1);
// Get the number of records
$totalRows_DetailRS1 = mysql_num_rows($DetailRS1);
?>
<table width="69%" id="Place_Detail" class="floatright">
<tr>
<th width="30%">Employer / Provider:</th>
<td width = "*"><?php echo $row_DetailRS1['employer']; ?></td>
</tr>
<tr>
<th>Description:</th>
<td><?php echo $row_DetailRS1['description']; ?> </td>
</tr>
<tr>
<th>Contact name:</th>
<td><?php echo $row_DetailRS1['contactname']; ?> </td>
</tr>
<tr>
<th>Contact phone:</th>
<td><?php echo $row_DetailRS1['contactphone']; ?> </td>
</tr>
<tr>
<th>Contact e-mail:</th>
<td><?php echo $row_DetailRS1['contactemail']; ?> </td>
</tr>
</table>


<!-- List of Placement table format is Folat Left -->

<table width="28%" id="Place_List">
<tr>
<th width="30%">Placement<br/>Type</th>
<th>Employer<br/>Provider</th>
</tr>
<?php
do { ?>
<tr>
<td><a href="../vacancies/idx_Vac.php?recordID=<?php echo $row_RS_Placement['id']#list; ?>" name="list"> <?php echo $row_RS_Placement['type']; ?> </a></td>
<td><a href="../vacancies/idx_Vac.php?recordID=<?php echo $row_RS_Placement['id']#list; ?>"> <?php echo $row_RS_Placement['employer']; ?> </a></td>
</tr>
<?php } while ($row_RS_Placement = mysql_fetch_assoc($RS_Placement)); ?>
</table>
<p class="SiteNewsText">
<?php echo $totalRows_RS_Placement ?> Records Total
</p>
</body>

davidj
03-12-2009, 09:20 PM
PaulF

wana learn how to code PHP rather than letting Dreamweaver do it for you

tux
03-17-2009, 10:21 AM
PaulF,

You should take David's advice and learn to code.

It is not that hard to get to grips with, I took David's advice a while ago now and havnt looked back. You will find things so much easier once you take the plunge. You code will become clearer, easier to understand and take up less space.

David's tutorials, teaching and guidance is second to none. You should go for it.

Regards, Paul