Frank,
I’ll post you my script if you tell me how to style wrappers in Wayfinder. I know you’ve messed around with WF.
See my post here:
http://modxcms.com/forums/index.php/topic,25887.0.html
Anyway, here’s the snippet. If I recall I got the original php from a tutorial for Dreamweaver. There are more notes at the bottom of this post which you’ll need to read.
<?php
require_once(’C:\wamp\www\modx-0961p2\assets\templates\acwa/Connections/dbConnect.php’); ?>
<?php
mysql_select_db($database_dbConnect, $dbConnect);
$query_List_2 =
"SELECT * FROM brood___seed_stock_suppliers";
$List_2 = mysql_query($query_List_2, $dbConnect) or die(mysql_error());
$row_List_2 = mysql_fetch_assoc($List_2);
$totalRows_List_2 = mysql_num_rows($List_2);
?>
<table border="0" align="center">
<tr>
<td>Company Name</td>
<td>Contact Name</td>
<td>Phone</td>
<td>Fax</td>
<td>Mobile</td>
<td>Email</td>
<td>Business Address</td>
<td>Postal Address</td>
<td>Postcode</td>
<td>State</td>
<td>Town City</td>
<td>Website</td>
<td>Country</td>
<td>species</td>
<td>Availability</td>
<td>Species Common Name</td>
<td>Activate</td>
<td>Priority</td>
<td>logo</td>
</tr>
<?php do { ?>
<tr>
<td><?php echo $row_List_2[’Company Name’]; ?></td>
<td><?php echo $row_List_2[’Contact Name’]; ?></td>
<td><?php echo $row_List_2[’Phone’]; ?></td>
<td><?php echo $row_List_2[’Fax’]; ?></td>
<td><?php echo $row_List_2[’Mobile’]; ?></td>
<td><?php echo $row_List_2[’Email’]; ?></td>
<td><?php echo $row_List_2[’Business Address’]; ?></td>
<td><?php echo $row_List_2[’Postal Address’]; ?></td>
<td><?php echo $row_List_2[’Postcode’]; ?></td>
<td><?php echo $row_List_2[’State’]; ?></td>
<td><?php echo $row_List_2[’Town City’]; ?></td>
<td><?php echo $row_List_2[’Website’]; ?></td>
<td><?php echo $row_List_2[’Country’]; ?></td>
<td><?php echo $row_List_2[’species’]; ?></td>
<td><?php echo $row_List_2[’Availability’]; ?></td>
<td><?php echo $row_List_2[’Species Common Name’]; ?></td>
<td><?php echo $row_List_2[’Activate’]; ?></td>
<td><?php echo $row_List_2[’Priority’]; ?></td>
<td><?php echo $row_List_2[’logo’]; ?></td>
</tr>
<?php } while ($row_List_2 = mysql_fetch_assoc($List_2)); ?>
</table>
<?php
mysql_free_result($List_2);
?>
?>
Some notes:
For some reason MODx always puts in an extra ?> Don’t know why, but it doesn’t seem to affect the result.
Line 2 (in red) obviously refers to my local server and another php file required to make it all work. Put yours where you see fit. Also see Open Geeks comments above for a more elegant writing of this line.
The other file is attached. I put it in this folder
/Connections/dbConnect.php cos that’s what was written in the original php and I’m way too inexperienced to want to change too many things.
Line 5 is obviously my database, insert yours here.
The html and table tags could obviously be done better. I’m not even sure if they should be in the snippet, but I’m still playing with MODx (This is day 4) and I’m happy just to have something working.
The names of the table columns you will have to change to match your own dbase columns names of course.
Snippet call is simply
[!hatcheries!]
cos it’s a list of fish hatcheries.
The end result is simple display of what’s in the db.
See the screenshot I posted earlier for how it looks. Sorry can’t post a link as it’s on my desktop server.
Obviously I want to manipulate the final display further to make it more "sexy" but for now this will do.
If anyone wants to take it and run with it, please do but post your results back here.
Hope this helps
Ahh Poop, I can’t upload php files thru this forum. (Duh)
Here’s the other dbConnect.php file
<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_dbConnect = "localhost";
$database_dbConnect = "hatcheries";
$username_dbConnect = "root";
$password_dbConnect = "";
$dbConnect = mysql_pconnect($hostname_dbConnect, $username_dbConnect, $password_dbConnect) or trigger_error(mysql_error(),E_USER_ERROR);
?>
Wow, this is more like a tute than a post.