PHP School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a PHP Expert!

Join 307,123 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,997 people online right now. Registration is fast and FREE... Join Now!




PHP website portfolio

 

PHP website portfolio

wrighty

6 Nov, 2009 - 07:25 AM
Post #1

New D.I.C Head
*

Joined: 9 Dec, 2008
Posts: 35


My Contributions
bascially i have the following scirpt for a website portfolio but i wanted to make it a bit more dynamic and was also wondering if any one knew how to retrive meta data from given websites my code for the current portfolio is as follows
CODE
<?php
$page = $_GET['page'];
if(!$page || $page == 0 || !is_numeric($page)){
$page = 1;
}
$limit = 5;
class paginate{
function init($limit, $page){
$query1 = mysql_query("SELECT * FROM portfolio");
$total_pages = ceil(mysql_num_rows($query1)/$limit);
$prev = '<a href="?page=' . ($page-1) . '">Prev</a>';
$next = '<a href="?page=' . ($page+1) . '">Next</a>';
if($page <= 1){
$page = 1;
$prev = '';
}
elseif($page >= $total_pages){
$page = $total_pages;
$next = '';
}
if($page > 2){
$prev = '<a href="?page=1">First</a> ' . $prev;
}
if($page < ($total_pages - 1)){
$next = $next . ' <a href="?page=' . $total_pages . '">Last</a>';
}
$start = ($limit*($page-1));
$query2 = mysql_query("SELECT * FROM portfolio LIMIT $start, $limit") or die("Error
In Query " . mysql_error());
$times_done=0;
while($row = mysql_fetch_array($query2)) {
if($times_done=='5'){
$content .= '<br><br>';
$times_done=1;
}
else{
$times_done++;
}
$content .= '<li>'.$row['name'].'<br/>'.'<a href="http://'.$row['address'].'"<img src="'.$row['image'].'"width="400" />'.'</a>'.'</li>';
}
$content .= '<br><hr>' . $prev . ' Page ' . $page . '/' . $total_pages . ' ' . $next;
return $content;
}
}
$class = &new paginate;
echo $class->init($limit, $page);
?>


User is offlineProfile CardPM
+Quote Post


Dannyboy997

RE: PHP Website Portfolio

6 Nov, 2009 - 08:31 AM
Post #2

D.I.C Head
**

Joined: 17 Apr, 2009
Posts: 77



Thanked: 2 times
My Contributions
well to make your code a little bit more dynamic you can change this part:

QUOTE
CODE
$limit = 5;


to:

CODE

$sql = "SELECT id FROM portfolio";

$get = mysql_query($sql);

$limit = mysql_num_rows($get);


so now when you had more rows it will always readapt.

this is better than putting a hard coded limit.

hope this helps.
User is offlineProfile CardPM
+Quote Post

felixtgomezjr

RE: PHP Website Portfolio

9 Nov, 2009 - 01:28 AM
Post #3

New D.I.C Head
Group Icon

Joined: 4 Nov, 2009
Posts: 42



Thanked: 3 times
Dream Kudos: 50
My Contributions
If you want to get meta data from a remote website/page, try to use cURL. It is the best solution I could suggest. To know more about cURL and a sample on how to get data try it here http://www.shoutbux.com/get-live-currency-using-php/

To give you an idea, that tutorial is all about getting a data from Google. I was making a script to get live currency feed. Since most of the data on currency that comes from other websites are not freely given, thus I use Google and get the data from there.

I hope that will help you.
User is online!Profile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/21/09 02:04PM

Live PHP Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month