•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 456,468 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 2,780 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: 644 | Replies: 2 | Solved
![]() |
| |
•
•
Join Date: Aug 2007
Posts: 13
Reputation:
Rep Power: 2
Solved Threads: 0
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> </td>';
$pics .= '<td> </td>';
$locations .= '<td> </td>';
}
}
$headings .= "</tr>\n";
$pics .= "</tr>\n";
$locations .= "</tr>";
echo $headings;
echo $pics;
echo $locations;
}
echo '</table>';
}
}
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> </td>';
$pics .= '<td> </td>';
$locations .= '<td> </td>';
}
}
$headings .= "</tr>\n";
$pics .= "</tr>\n";
$locations .= "</tr>";
echo $headings;
echo $pics;
echo $locations;
}
echo '</table>';
}
}
•
•
Join Date: Aug 2007
Posts: 13
Reputation:
Rep Power: 2
Solved Threads: 0
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> </td>';
$pics .= '<td> </td>';
$locations .= '<td> </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>";
}
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> </td>';
$pics .= '<td> </td>';
$locations .= '<td> </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>";
}
![]() |
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- Word Association Game (Posting Games)
- explorer.exe uses 99% CPU (Viruses, Spyware and other Nasties)
- Help with a problem with C++ program (C++)
- IE 6 Can't open new windows from link clicked (Web Browsers)
- do while loop - not stopping!! (Java)
- coding if loops (Java)
- invitation for Yahoo IM id's (Geeks' Lounge)
- Flashing ? on startup (OS X)
Other Threads in the PHP Forum
- Previous Thread: To disable Submit button
- Next Thread: How to export data from mysql into fields in excell


Hybrid Mode