Formatting a Dynamic PHP Datafeed

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
adammurray
Forum Newbie
Posts: 3
Joined: Fri Oct 03, 2008 5:52 pm

Formatting a Dynamic PHP Datafeed

Post by adammurray »

Hey guys,

I'm new to programming with php & I am trying to format this datafeed into a 3 column table. The example script given here - http://www.netshopsaffiliates.com/phpexample.php - is one product per row. I'm also taking off the product description too, but I already know how to do this.

Here is more information on their script if it helps at all - http://www.netshopsaffiliates.com/unive ... altime.php

Thanks in advanced.

-Adam
adammurray
Forum Newbie
Posts: 3
Joined: Fri Oct 03, 2008 5:52 pm

Re: Formatting a Dynamic PHP Datafeed

Post by adammurray »

Here is the code for anyone who doesn't feel like clicking over to the site I posted.. lol...

Code: Select all

$login = "netshops";
$password = "feedme";
$table = "hammocks";
$aid = "CD0000";
$database = "netshopsaffiliates_com_-_datafeeds";
$connection = mysql_connect("207.234.208.224","$login","$password")
or die ("Unable to connect.");
mysql_select_db($database)
or die ("Unable to open database.");
$sql = "select * from $table where category like '%hammock stands%'";
$result = mysql_query($sql);
while ($row = mysql_fetch_array($result))
{
extract($row);
echo "<table width='100%' border='0' cellspacing='0' cellpadding='3'> \n";
echo "<tr>\n";
echo "<td valign='top'>\n<a href='$link$aid'> <img src='$image' border=0> </a> \n <br> <b> Price: </b> $$price\n </td> \n";
echo "<td valign='top'>\n<a href='$link$aid'> \n<b> $product </b> </a> \n<br> $description\n <br> <b> Item: </b> <i> $sku </i> \n <b> Category: </b> <i> $category </i> <br> </td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "<hr size='1'>\n";
}
mysql_close($connection);
?>
Last edited by adammurray on Mon Oct 06, 2008 10:28 am, edited 1 time in total.
adammurray
Forum Newbie
Posts: 3
Joined: Fri Oct 03, 2008 5:52 pm

Re: Formatting a Dynamic PHP Datafeed

Post by adammurray »

As a follow up... I was able to manipulate the code to an extent, but the way I did it causes the last couple of products to repeat itself a few times.. If anyone could help, I would really appreciate it. Thanks...

Code: Select all

<?php
$login = "netshops";
$password = "feedme";
$table = "hammocks";
$aid = "CD0000";
$database = "netshopsaffiliates_com_-_datafeeds";
$connection = mysql_connect("207.234.208.224","$login","$password")
or die ("Unable to connect.");
mysql_select_db($database)
or die ("Unable to open database.");
$sql = "select * from $table where product like '%rope hammock%'";
$result = mysql_query($sql);
 
echo "<table width='95%' border='0' cellspacing='0' cellpadding='10'> \n";
 
while ($row = mysql_fetch_array($result))
    {
        extract($row);
        echo "<tr>\n";
        
        echo "<td align='center' width='33%' valign='top'> <br> <a href='$link$aid'> <img src='$image' border=0> </a> <br>
        <a href='$link$aid'> $product </a> <br> <b> Price: </b> $$price </td>";
                    
        $row = mysql_fetch_array($result);
        extract($row);
        echo "<td align='center' width='34%' valign='top'> <br> <a href='$link$aid'> <img src='$image' border=0> </a> <br>
        <a href='$link$aid'> $product </a> <br> <b> Price: </b> $$price </td>";
                        
        $row = mysql_fetch_array($result);
        extract($row);
        echo "<td align='center' width='33%' valign='top'> <br> <a href='$link$aid'> <img src='$image' border=0> </a> <br>
        <a href='$link$aid'> $product </a> <br> <b> Price: </b> $$price </td>";
                            
        echo "</tr>\n";
    }
 
echo "</table>\n";
echo "<hr size='1'>\n";
 
mysql_close($connection);
?>
If you want to view what I mean, here is my test page - http://www.comfyhammocks.com/articles/test.php
Post Reply