Jump to content

Archived

This topic is now archived and is closed to further replies.

perezf

loading items from database into specific spots

Recommended Posts

Hey everyone i just need help loading specific items from a database into certain sections of my table
the item-title
img
and the
description

I need to transfer it from this code into

[code]
print "<div class=\"item\">\n".
        "\t<div class=\"boxcontent\">\n".
        "\t\t<p>\n".
        "\t\t<span class=\"item-title\"><a href=\"".$link_href."\">".htmlspecialchars(stripslashes($table_data['title']))."</a></span>\n".
        "\t\t<a href=\"".$link_href."\"><img src=\"".$img_src."\" class=\"item-thumb\" /></a>\n".
        "\t\t<span class=\"item-info\">".stripslashes($table_data['description'])."</span>\n".
        "\t\t<p class=\"item-clear\"></p>\n".
        "\t\t</p>\n".
        "\t</div>\n".
        "</div>\n";
[/code]

This table

[code]
<table width="95%"  border="0" cellspacing="0" cellpadding="0">
                      <tr>
                        <td><table width="100%"  border="0" cellspacing="0" cellpadding="0">
                            <tr>
                              <td width="2"><img src="images/bar_l.jpg" width="2" height="24" alt=""></td>
                              <td background="images/bar_bg.jpg"><span class="style2>Item title goes here</span></td>
                              <td width="2"><img src="images/bar_r.jpg" width="2" height="24" alt=""></td>
                            </tr>
                        </table></td>
                      </tr>
                      <tr>
                        <td><table width="100%"  border="0" cellspacing="0" cellpadding="0">
                            <tr>
                              <td><table width="100%"  border="0" cellspacing="0" cellpadding="0">
                                  <tr>
                                    <td width="1" bgcolor="#1B6A00"></td>
                                    <td align="center" bgcolor="#FFFFFF> Image and description go here</td>
                                    <td width="1" bgcolor="#1B6A00"></td>
                                 </tr>
                              </table></td>
                            </tr>
                            <tr>
                              <td height="1" bgcolor="#1B6A00"></td>
                            </tr>
                        </table>

[/code]

Share this post


Link to post
Share on other sites
[code]<table width="95%"  border="0" cellspacing="0" cellpadding="0">
     <tr>
          <td><table width="100%"  border="0" cellspacing="0" cellpadding="0">
                  <tr>
                         <td width="2"><img src="images/bar_l.jpg" width="2" height="24" alt=""></td>
                         <td background="images/bar_bg.jpg"><span class="style2><a href="<?php echo $link_href; ?>"><?php echo htmlspecialchars(stripslashes($table_data['title'])); ?></a></td>
                          <td width="2"><img src="images/bar_r.jpg" width="2" height="24" alt=""></td>
                  </tr>
                  </table>
          </td>
     </tr>
     <tr>
            <td><table width="100%"  border="0" cellspacing="0" cellpadding="0">
                    <tr>
                          <td><table width="100%"  border="0" cellspacing="0" cellpadding="0">
                                  <tr>
                                      <td width="1" bgcolor="#1B6A00"></td>
                                      <td align="center" bgcolor="#FFFFFF><a href="<?php echo $link_href; ?>"><img src="<?php echo $img_src; ?>" class="item-thumb" /></a>
                                     <?php echo stripslashes($table_data['description']); ?>
</td>
                                      <td width="1" bgcolor="#1B6A00"></td>
                                  </tr>
                                  </table>
                          </td>
                    </tr>
                    <tr>
                           <td height="1" bgcolor="#1B6A00"></td>
                    </tr>
                    </table>              
            </td>
     </tr>
</table>[/code]

All you have to do is copy the variables into the new layout.

[!--coloro:#990000--][span style=\"color:#990000\"][!--/coloro--]Jeremy[!--colorc--][/span][!--/colorc--]

Share this post


Link to post
Share on other sites
Its not working
Heres the code i am using

[code]print '<table width=\"95%\"  border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
     <tr>
          <td><table width=\"100%\"  border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
                  <tr>
                         <td width=\"2\"><img src=\"images/bar_l.jpg\" width=\"2\" height=\"24\" alt=\"\"></td>
                         <td background=\"images/bar_bg.jpg\"><span class=\"style2><a href=\"<?php echo $link_href; ?>\"><?php echo

htmlspecialchars(stripslashes($table_data['title'])); ?></a></td>
                          <td width=\"2\"><img src=\"images/bar_r.jpg\" width=\"2\" height=\"24\" alt=\"\"></td>
                  </tr>
                  </table>
          </td>
     </tr>
     <tr>
            <td><table width=\"100%\"  border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
                    <tr>
                          <td><table width=\"100%\"  border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
                                  <tr>
                                      <td width=\"1\" bgcolor=\"#1B6A00\"></td>
                                      <td align=\"center\" bgcolor=\"#FFFFFF><a href=\"<?php echo $link_href; ?>\"><img src=\"<?php echo $img_src; ?>\"

class=\"item-thumb\" /></a>
                                     <?php echo stripslashes($table_data['description']); ?>
</td>
                                      <td width=\"1\" bgcolor=\"#1B6A00\"></td>
                                  </tr>
                                  </table>
                          </td>
                    </tr>
                    <tr>
                           <td height=\"1\" bgcolor=\"#1B6A00\"></td>
                    </tr>
                    </table>              
            </td>
     </tr>
</table>';[/code]

Share this post


Link to post
Share on other sites
You don't need to print everything out. I wrote it to where it would echo the variables in the correct spots.

You should be able to use it they EXACT way I wrote it, unless the variables are not the same.

[!--coloro:#990000--][span style=\"color:#990000\"][!--/coloro--]Jeremy[!--colorc--][/span][!--/colorc--]

Share this post


Link to post
Share on other sites
i still get an error

Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /hsphere/local/home/way2fr3s/2fr3sh.com/new project/videos.php on line 12

Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /hsphere/local/home/way2fr3s/2fr3sh.com/new project/videos.php on line 18

heres the whole code
[code]
<?php
$mysql_host = '********';
$mysql_user = '********';
$mysql_pass = '********';
$mysql_db   = '********';
$dbTable    = 'videos';
$records_per_page = 7;

mysql_connect ($mysql_host, $mysql_user, $mysql_pass);
mysql_select_db ($mysql_db);

$count_query = \"SELECT count(*) from \".$dbTable;
$rh = mysql_query($count_query);
list ($record_count) = mysql_fetch_array($rh);

$max_pages = (floor($record_count / $records_per_page) + 1);

if (isset($_GET['pg'])) {
    if ($_GET['pg'] > 1) {
        if ($_GET['pg'] > $max_pages) {
            $current_page = $max_pages;
        } else {
            $current_page = $_GET['pg'];
        }
    } else {
        $current_page = 1;
    }
} else {
    $current_page = 1;}

$limit_start = ($current_page - 1) * $records_per_page;

$data_query = \"SELECT * FROM \".$dbTable.\" ORDER BY `id` DESC LIMIT \" . $limit_start . \", \" . $records_per_page;
$rh = mysql_query ($data_query);

while ($table_data = mysql_fetch_array($rh))
{
    $server = 'http://fishbash.com/';
    $link_href = 'http://www.2fr3sh.com/index.php?page=PlayVideos&id='.stripslashes($table_data['id']);


    $img_src = $server.$dbTable.'/thumbs/'.stripslashes($table_data['id']).'.gif';


?>
<table width="95%"  border="0" cellspacing="0" cellpadding="0">
     <tr>
          <td><table width="100%"  border="0" cellspacing="0" cellpadding="0">
                  <tr>
                         <td width="2"><img src="images/bar_l.jpg" width="2" height="24" alt=""></td>
                         <td background="images/bar_bg.jpg"><span class="style2><a href="<?php echo $link_href; ?>"><?php echo

htmlspecialchars(stripslashes($table_data['title'])); ?></a></td>
                          <td width="2"><img src="images/bar_r.jpg" width="2" height="24" alt=""></td>
                  </tr>
                  </table>
          </td>
     </tr>
     <tr>
            <td><table width="100%"  border="0" cellspacing="0" cellpadding="0">
                    <tr>
                          <td><table width="100%"  border="0" cellspacing="0" cellpadding="0">
                                  <tr>
                                      <td width="1" bgcolor="#1B6A00"></td>
                                      <td align="center" bgcolor="#FFFFFF><a href="<?php echo $link_href; ?>"><img src="<?php echo $img_src; ?>"

class="item-thumb" /></a>
                                     <?php echo stripslashes($table_data['description']); ?>
</td>
                                      <td width="1" bgcolor="#1B6A00"></td>
                                  </tr>
                                  </table>
                          </td>
                    </tr>
                    <tr>
                           <td height="1" bgcolor="#1B6A00"></td>
                    </tr>
                    </table>              
            </td>
     </tr>
</table>[/code]

Share this post


Link to post
Share on other sites
It is because you are escaping all of quotation marks. Unless it is inside a string that is being printed, they do not need to be escaped.

[!--coloro:#990000--][span style=\"color:#990000\"][!--/coloro--]Jeremy[!--colorc--][/span][!--/colorc--]

Share this post


Link to post
Share on other sites
[!--quoteo(post=379552:date=Jun 3 2006, 01:15 AM:name=jeremywesselman)--][div class=\'quotetop\']QUOTE(jeremywesselman @ Jun 3 2006, 01:15 AM) [snapback]379552[/snapback][/div][div class=\'quotemain\'][!--quotec--]
It is because you are escaping all of quotation marks. Unless it is inside a string that is being printed, they do not need to be escaped.

[!--coloro:#990000--][span style=\"color:#990000\"][!--/coloro--]Jeremy[!--colorc--][/span][!--/colorc--]
[/quote]



Yes that same code is being printed over and over for each separate video
thats what i was trying to figure out
the code works but when i try to change to layout it doesn i always get error and
i was wondering if anyone could help me do this?

Share this post


Link to post
Share on other sites
You need to go through your code and delete all the \ before the ". That is why it is not working correctly. Unless the " is inside a set of "", you need to remove the \.

[!--coloro:#990000--][span style=\"color:#990000\"][!--/coloro--]Jeremy[!--colorc--][/span][!--/colorc--]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.