User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 391,163 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,340 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 550 | Replies: 2 | Solved
Reply
Join Date: Aug 2007
Posts: 13
Reputation: phobia1 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
phobia1 phobia1 is offline Offline
Newbie Poster

loopy doopy

  #1  
Sep 15th, 2007
Hi Guys
What I am trying to do is allow a 3 x 3 grid of images and then have bottom navigation.
You can see the existing layout at http://areabulgaria.net/properties.php

Here is the code to where I am so far, since I'm no real programmer, its giving me a headache. Could anyone help me to achieve the result please.
Regards
FJW

Function output_array2(){

//data is available to here from normal listing, i.e one record under the other


$query = "SELECT * FROM Garant";


$result = mysql_query($query);

if (!$result) {
echo "Could not successfully run query ($sql) from DB: " . mysql_error();
exit;
}

if (mysql_num_rows($result) == 0) {
echo "No rows found, nothing to print so am exiting";
exit;
}

if($count = mysql_num_rows($result) > 0) {

$result2 = mysql_query($query);
$row = mysql_fetch_array($result2);
$numrows = $row['count'];

echo "<a href=\"" . $PHP_SELF . "?start=" . ($start - 9) . "\">Previous</a>\n";

if($numrows > ($start + 9))
{

echo "<a href=\"" . $PHP_SELF . "?start=" . ($start + 9) . "\">Next</a>\n";
}

$max=3; $count=mysql_num_rows($result); //set the number of images across here

echo "<table border =1><tr>";
for($i=0;$i<$max;$i++)
{
// echo "<td>Column $i+1</td>";
}
echo "</tr>\n";
{
$headings = $pics = $locations = '<tr>';
for($j=0;$j<$max;$j++)
{
if($images = mysql_fetch_assoc($result))
{


$pics .="<TD bgcolor=\"#FFFFFF\" width=\"125\" ><A HREF=\"details.php?detail=".$images["id"]." \"><IMG SRC=\"resources/".$images["smallpic"]."\"></A></TD>";

$locations .= '<td align="center" bgcolor=#DDEEFF><B>' .$images['Price']. ' Euro - - REF - ' .$images['id'].'</B></td>';
} else {
$headings .= '<td>&nbsp;</td>';
$pics .= '<td>&nbsp;</td>';
$locations .= '<td>&nbsp;</td>';
}
}
$headings .= "</tr>\n";
$pics .= "</tr>\n";
$locations .= "</tr>";
echo $headings;
echo $pics;
echo $locations;
}
echo '</table>';
}
}
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Aug 2007
Posts: 13
Reputation: phobia1 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
phobia1 phobia1 is offline Offline
Newbie Poster

Help Re: loopy doopy

  #2  
Sep 15th, 2007
Hi guys an gals
Well I have almost managed it, you can check out at http://areabulgaria.net/properties2.php.
Now I have a problem of large space under the images. Can anyone help me to get rid of it
to leave just 9 pictures and the bottom navigation on one page.

Function output_array2(){
// If current page number, use it
// if not, set one!

if(!isset($_GET['page'])){
$page = 1;
} else {
$page = $_GET['page'];
}

// Define the number of results per page
$max_results = 10;

// Figure out the limit for the query based
// on the current page number.
$from = (($page * $max_results) - $max_results);

// Perform MySQL query on only the current page number's results

$sql = mysql_query("SELECT * FROM Garant LIMIT $from, $max_results");
$result = mysql_query($sql);

while($row = mysql_fetch_array($sql))
{
// Build your formatted results here.
$count = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM Garant"),0);
if($count > 0) {
$max=3; //set the number of images across here

echo "<table>";

for($i=0;$i<$count;$i+=$max) /* loop through and build the table */
{
$headings = $pics = $locations = '<tr>';
for($j=0;$j<$max;$j++)
{
if($row = mysql_fetch_assoc($sql))
{


$pics .="<TD bgcolor=\"#FFFFFF\" width=\"125\" ><A HREF=\"details.php?detail=".$row["id"]." \"><IMG SRC=\"resources/".$row["smallpic"]."\"></A></TD>";
$locations .= '<td align="center" bgcolor=#DDEEFF><B>' .$row['Price']. ' Euro - ref - ' .$row['id'].'</td>';
} else {
// $headings .= '<td>&nbsp;</td>';
$pics .= '<td>&nbsp;</td>';
$locations .= '<td>&nbsp;</td>';
}
}
$headings .= "</tr>\n";
$pics .= "</tr>\n";
$locations .= "</tr>";
echo $headings;
echo $pics;
echo $locations;
}
echo '</table>';
}
}

// Figure out the total number of results in DB:
$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM Garant"),0);

// Figure out the total number of pages. Always round up using ceil()
$total_pages = ceil($total_results / $max_results);

// Build Page Number Hyperlinks
echo "<center>Select a Page<br />";

// Build Previous Link
if($page > 1){
$prev = ($page - 1);
echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$prev\"><<Previous</a> ";
}

for($i = 1; $i <= $total_pages; $i++){
if(($page) == $i){
echo "$i ";
} else {
echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$i\">$i</a> ";
}
}

// Build Next Link
if($page < $total_pages){
$next = ($page + 1);
echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$next\">Next>></a>";
}
echo "</center>";
}
Reply With Quote  
Join Date: Aug 2007
Posts: 13
Reputation: phobia1 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
phobia1 phobia1 is offline Offline
Newbie Poster

Re: loopy doopy

  #3  
Sep 15th, 2007
Solved. Thanks to all those who had posted similar answers to this problem.
Without you guys I would be nowhere.
Sincere thanks
FJW
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb PHP Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 7:27 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC