Linking question

Tips, tricks and general usage

Linking question

Postby boyloco » Tue May 05, 2009 12:12 am

First, great job on the script. It's EXACTLY what i needed. This directory is an extension of my site but i want to be able to show the 'Recent Listings' information in the main site sidebar. The site isn't built using smarty, but rather a combination of html/css/php. I could update this manually on a daily basis but if there is an easy way to link to the information produced automatically from the recent.tpl file i'd of course wanna take that route. What would I need for this to be possible?
boyloco
New User
 
Posts: 13
Joined: Fri Apr 17, 2009 7:11 pm
Location: Phoenix, AZ

Postby WagonTrader » Wed May 06, 2009 1:10 pm

It can be scripted, the approach would depend on whether your main index file is a .php file (which means it is being processed by php) or some other markup (which means we would have to include an iframe to display the data)? Smarty doesn't matter, it is only the display template and we can script the display outside of smarty.

Dave
User avatar
WagonTrader
Developer
 
Posts: 1946
Joined: Thu Aug 31, 2006 11:02 pm
Location: Oregon

Linking Question

Postby boyloco » Wed May 06, 2009 1:46 pm

The index is a .php file but I would like to know how to set up using iframe as well.
boyloco
New User
 
Posts: 13
Joined: Fri Apr 17, 2009 7:11 pm
Location: Phoenix, AZ

Postby WagonTrader » Sun May 10, 2009 12:11 pm

Here is some sample code, copy it and create new file, call it something like pdsrecent.php. Just make sure it has a .php extension.

Code: Select all
<?PHP
//connect to the mysql server
//remove if a connection is already established
$dbc = mysql_connect ('localhost', 'user', 'password');

//select the PDS database
//remove if the database with the PDS files is already selected
$dbs = mysql_select_db('PDS database name');

//get the recent listings
$rz = mysql_query("SELECT * FROM pds_list WHERE state='apr' ORDER BY d_submit DESC, id DESC LIMIT 0,10;");
for($xz=0;$xz<mysql_num_rows($rz);$xz++){
   $recent[$xz] = mysql_fetch_assoc($rz);
}

//select the default database
//remove if your external script does not need a different database
$dbs = mysql_select_db('default database name');

//we now will generate the markup for display
?>
<table>
<?PHP
for($xz=0;$xz<count($recent);$xz++){
?>
   <tr>
      <td><a href="http://www.yoursite.com/folder/show.php?id=<?=$recent[$xz]['id']?>"><?=$recent[$xz]['firm']?></a></td>
   </tr>
<?PHP
}
?>
</table>


You will need to manually set up you database connection/selection and fix the url to your sites PDS installation in the anchor. The scripting is barebones, so you can redefine variables in the code section and display whatever you want in the markup (it currently only displays a linked firm name.

To display your designated markup on the main sites index.php file, you can place this file in the sites document root and include it in the sites main index.php file...

Code: Select all
include('pdsrecent.php');


If you want to use it as an iframe, you would include it in your markup as....

Code: Select all
<iframe src="http://www.yoursite.com/pdsrecent.php"></iframe>


You will need to define the frame attributes like width, height, controls etc..

Written on the fly and untested, so let me know if you run into problems.

Dave
Last edited by WagonTrader on Mon May 11, 2009 9:36 pm, edited 1 time in total.
User avatar
WagonTrader
Developer
 
Posts: 1946
Joined: Thu Aug 31, 2006 11:02 pm
Location: Oregon

Postby boyloco » Mon May 11, 2009 7:09 pm

Thanks. I followed your instructions and created the .php file and setup the db and anchor info but all i get is a blank screen. View source is showing the table with empty links repeated several times. http://www.krazyboyentertainment.com/pdsrecent.php What am I missing?
boyloco
New User
 
Posts: 13
Joined: Fri Apr 17, 2009 7:11 pm
Location: Phoenix, AZ

Postby WagonTrader » Mon May 11, 2009 9:38 pm

I built the array wrong... fixed in the code above. This line...

Code: Select all
$recent = mysql_fetch_assoc($rz);


should have been

Code: Select all
$recent[$xz] = mysql_fetch_assoc($rz);


Dave
User avatar
WagonTrader
Developer
 
Posts: 1946
Joined: Thu Aug 31, 2006 11:02 pm
Location: Oregon

Postby boyloco » Tue May 12, 2009 6:42 pm

Wow, worked perfect! You are truly an amazing man! Where can i submit a small but appreciative donation? See you on the next thread!

:lol:
boyloco
New User
 
Posts: 13
Joined: Fri Apr 17, 2009 7:11 pm
Location: Phoenix, AZ

Postby WagonTrader » Wed May 13, 2009 12:28 pm

You can support script development for $20.00, not sure if that is considered small but appreciative, but you also get permission to remove the branding (powered by) link with the donation.

The link to the products page it is on is...

http://www.phpdirectorysource.com/produ ... incat_id=3

Dave
User avatar
WagonTrader
Developer
 
Posts: 1946
Joined: Thu Aug 31, 2006 11:02 pm
Location: Oregon

Re: Linking question

Postby boyloco » Wed Mar 03, 2010 5:49 pm

I added some new variables and the code does exactly what i needed. However, if a new member chooses multiple listings , their listing will appear several times, with each category chosen posting seperately. Also, I can't seem to figure out how to get the parent category to show as well. It's only showing the sub category title. Here is the code i'm using.
Code: Select all
<?PHP
//connect to the mysql server
//remove if a connection is already established
$dbc = mysql_connect ('my_db_info');

//select the PDS database
//remove if the database with the PDS files is already selected
$dbs = mysql_select_db('my_db_info');

//get the recent listings
$rz = mysql_query("SELECT * FROM (pds_list left join pds_listcat on pds_list.id = pds_listcat.list_id)
                     LEFT JOIN pds_category
                     ON pds_listcat.cat_id = pds_category.id
                     WHERE pds_list.state='apr'
                     ORDER BY pds_list.d_submit
                     DESC LIMIT 0,10;")or die(mysql_error());


for($xz=0;$xz<mysql_num_rows($rz);$xz++){
   $recent[$xz] = mysql_fetch_assoc($rz);
}

//we now will generate the markup for display
?>

<?PHP
for($xz=0;$xz<count($recent);$xz++){
?>
<dl>
<dt>
<a href="http://www.krazyboyentertainment.com/directory/show.php?lid=<?=$recent[$xz]['list_id']?>"><?=$recent[$xz]['firm']?></a></dt>

<dd><?php if ($recent[$xz]['list_id']=="") echo "<a href=\"/directory/index.php\">Add Your Listing Now</a>"; else echo "Listed In:&nbsp;";
?><a href="http://www.krazyboyentertainment.com/directory/<?=$recent[$xz]['title']?>-<?=$recent[$xz]['id']?>-0.html"><i><?=$recent[$xz]['title']?><?=$recent[$xz]['id']?></i></a>
</dd>
<dd><i><?=$recent[$xz]['xtra_5']?>&nbsp;<?=$recent[$xz]['xtra_6']?></i></dd><br /><br /></dl>
<?PHP
}
?>
boyloco
New User
 
Posts: 13
Joined: Fri Apr 17, 2009 7:11 pm
Location: Phoenix, AZ


Return to General Discussion

Who is online

Users browsing this forum: jekwumoore and 1 guest