Hey all, I'm pretty new to php so please keep that in mind when you
razz me. ;)
Anyway, I'm trying to make it so that 3 columns of links will show up
on a page so
link1 link2 link3
link4 link5 link6
link7 link8 link9
etc.
I've got this code for it, but I get an error message if the number of
links in the database isn't an integer divided by three. So if it's not
3,6,9,12, etc. I get
Warning: mysql_result(): Unable to jump to row 4 on MySQL result index
3 in mydirectory/loop.php on line 14
I'd like it to stop if there is a number not divisible by 3, but I'm
guessing it just keeps going.
here's the code.
for ($i = 0; $i < mysql_num_rows( $result);)
{
echo '<table align="center" cellpadding="0" cellspacing="0"
width="90%"<tr> ';
for ($a = 0; $a < 3; $a++)
{
$articlename = mysql_result($r esult, $i, "articlenam e");
$articletitle = mysql_result($r esult, $i, "articletitle") ;
$i++;
echo '<td width="33%" align="center" valign="top"<p> <a
href="/articles/' . $articlename . '/articles.php">' . $articletitle
..'</a></p</td>';
}
echo '</tr></table><br>';
}
Thanks for your time. 2 1412
Try it this way:
<?php
$total = mysql_num_rows( $result);
$width = 3;
$rows = ceil($total / $width);
$counter = 0;
echo '<table border=1>';
for ($y = 1; $y <= $rows; $y += 1)
{
echo '<tr>';
for ($x = 1; $x <= $width; $x += 1)
{
$counter += 1;
if ($counter <= $total)
{
$articlename = mysql_result($r esult, $counter - 1, $articlename");
$articletitle = mysql_result($r esult, $counter - 1, "articletitle") ;
echo '<td>Link!</td>';
}
else
{
echo '<td> </td>';
}
}
echo '</tr>';
}
echo '</table>';
?>
I tested the logic part but not the db stuff. Good luck ro********@gmai l.com wrote:
Hey all, I'm pretty new to php so please keep that in mind when you
razz me. ;)
Anyway, I'm trying to make it so that 3 columns of links will show up
on a page so
link1 link2 link3
link4 link5 link6
link7 link8 link9
etc.
I've got this code for it, but I get an error message if the number of
links in the database isn't an integer divided by three. So if it's not
3,6,9,12, etc. I get
Warning: mysql_result(): Unable to jump to row 4 on MySQL result index
3 in mydirectory/loop.php on line 14
I'd like it to stop if there is a number not divisible by 3, but I'm
guessing it just keeps going.
here's the code.
for ($i = 0; $i < mysql_num_rows( $result);)
{
echo '<table align="center" cellpadding="0" cellspacing="0"
width="90%"<tr> ';
for ($a = 0; $a < 3; $a++)
{
$articlename = mysql_result($r esult, $i, "articlenam e");
$articletitle = mysql_result($r esult, $i, "articletitle") ;
$i++;
echo '<td width="33%" align="center" valign="top"<p> <a
href="/articles/' . $articlename . '/articles.php">' . $articletitle
.'</a></p</td>';
}
echo '</tr></table><br>';
}
Thanks for your time.
There is a small bug with the quoting. You'll spot it right away:
Should be: $articlename = mysql_result($r esult, $counter - 1, "articlenam e"); This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Mountain Bikn' Guy |
last post by:
Take some standard code such as shown below. It simply loops to add up a
series of terms and it produces the correct result.
// sum numbers with a loop
public int DoSumLooping(int iterations)
{
int result = 0;
for(int i = 1;i <=iterations;i++)
{
result += i;
|
by: Montrose... |
last post by:
After working in c# for a year, the only conclusion I can come to is
that I wish I knew c.
All I need is Linux, the gnu c compiler and I can do anything.
Web services are just open sockets hooked up to interfaces.
The Gtk is more than enough gui.
|
by: Gremlin |
last post by:
If you are not familiar with the halting problem, I will not go into
it in detail but it states that it is impossible to write a program
that can tell if a loop is infinite or not. This is a fallacy built
on the assumption of mythical infinite all powerfull machines. In
reality we deal with finite machines that are capable of two states in
a loop, they either terminate, or repeat themselves. In the mythical
halting problem scenario...
|
by: Mr BigSmoke |
last post by:
Hi everybody... I have an app that has to controll some ascii files
every 10/30 seconds... I was planning to have an GUI using wxpython.
The problems is that i wasn't able to manage my application loop and
the wxApp loop, so my interface is always freezing...
My app do something like this:
- creates a new wx and wxframe instance
- loads some configuration info
- starts looping every 30 seconds (while True: sleep(30); do something,...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |