Go Back   CodingForums.com > :: Server side development > MySQL

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Old 01-20-2005, 11:31 PM   PM User | #1
pirolilla
New Coder

 
Join Date: Jan 2004
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
pirolilla is an unknown quantity at this point
Break rows in table

I am a neewbie. Recently time which I have begun to program in PHP with MySQL, and I need to solve a problem.

I have a table that relates all the registries of a table in a database MySQL which begin by a letter, ordered of ascending form.

Table HTML must consist of limitless rows and 4 columns

I have all the code, unless not like inserting tags </tr><tr> each 4 rows. Please, somebody can help me?

I stick the code fragment so that it is understood well...

PHP Code:
<?
$dbhost
="localhost";
$dbusuario="***";
$dbpassword="***";
$db="genea";
$conexion mysql_connect($dbhost$dbusuario$dbpassword);
mysql_select_db($db$conexion);
?>
PHP Code:
<? 

$query
="SELECT * FROM nombres WHERE nombre LIKE '$letra%' ORDER BY nombre ASC"
$result=mysql_query($query$conexion); 
$num=mysql_numrows($result); 

echo
"<table border='0' width='100%' cellspacing='5' cellpadding='10'>"

while(
$row=mysql_fetch_row($result)) 
    { 
    echo
"<td class='row2' width='25%' align='left'><span class='topictitle'><a class='topictitle' href='http://www.---.com/nombres.php?nombre=$row[1]'><b>$row[1]</b></a></span></td>"
    } 

echo
"</table>"

mysql_close($conexion); 
?>
In order to open to each page of each initial letter the connection it would be this:

http://www.---.com/letras.php?letra=A

I summarize. I need the data appear in a table that has 4 columns. I always need that each 4 results this code is inserted:

</tr><tr>

in case that there is more than 4 results.

Now in my script has a <td></td> for each entry in the database. But i wish that each 4 entries has </tr><tr>, so that the table only has four columns.

Thanks (i speak english only a litte. Excuse me)
pirolilla is offline   Reply With Quote
Old 01-21-2005, 12:06 AM   PM User | #2
raf
Master Coder


 
Join Date: Jul 2002
Posts: 6,589
Thanks: 0
Thanked 0 Times in 0 Posts
raf is on a distinguished road
this is not a mysql issue. it's a PHP question. this thread contains code and links to create a table with 3 columns out of your recordset. Just change the 3 to 4 for your case

http://www.codingforums.com/showthread.php?t=50422
__________________
Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html
raf is offline   Reply With Quote
Old 01-21-2005, 12:35 AM   PM User | #3
pirolilla
New Coder

 
Join Date: Jan 2004
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
pirolilla is an unknown quantity at this point
Thank you very much. It is exactly i need.

pirolilla is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:24 AM.

Home - Contact Us - Archives - Link to CF - Resources - Top 

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.