GIDForums  

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 27-Feb-2004, 04:06
giobbi giobbi is offline
New Member
 
Join Date: Jan 2004
Posts: 14
giobbi is on a distinguished road

Two column list, newbiequiz again.


I've made a nice database that contains phonenumbers and shows them nicely in a webpage. The only problem is that its a rather loong list and i would like to break it in to two columns, maybe three, how do i do that i php?

here's my code:
PHP Code:

$conn = mysql_connect("localhost", "root", "xxx");

mysql_select_db("receptionen",$conn);

$sql = "select * from emosms";

$result = mysql_query( $sql, $conn ) or die(mysql_error()); 

// initialise $foretag 
$foretag = NULL; 

while( $newArray = mysql_fetch_array($result) ) 
{ 
$namn = $newArray['namn']; 
$emsms = $newArray['emsms']; 
/* we don't really need this line anymore... -> $foretag = $newArray['foretag']; */ 

// on each WHILE loop, check to see if $foretag and $newArray['foretag'] is NOT identical 
if( $foretag != $newArray['foretag'] ) 
{ 
$foretag = $newArray['foretag']; 
echo"<br>\t<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\r\n". 
"\t\t<tr>\r\n". 
// added a style attribute to control the display of the $foretag 
"\t\t\t<td width=\"390\">$foretag</td>\r\n". 
"\t\t</tr>\r\n". 
"\t</table>\r\n"; 
// we add the COMPANY name to the $foretag so if it's in the next loop, the test will fail and none of this 
// will be echo'ed. 

} 

echo"\t<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\r\n". 
"\t\t<tr>\r\n". 
"\t\t\t<td width=\"170\">$namn</td>\r\n". 
// 'mailto:' for a phone number? 
"\t\t\t<td width=\"220\"><a href=\"mailto:$emsms\">$emsms</a></td>\r\n". 
"\t\t</tr>\r\n". 
"\t</table>\r\n"; 
} 


Thanks!
Last edited by dsmith : 28-Feb-2004 at 12:49. Reason: Use php tags for highlighting
  #2  
Old 27-Feb-2004, 04:57
Allowee's Avatar
Allowee Allowee is offline
Regular Member
 
Join Date: May 2003
Location: The Netherlands
Posts: 339
Allowee has a spectacular aura about
if you know enough about PHP you might be able to use this file..
http://cvs.sourceforge.net/viewcvs.p...1.19&view=auto

I know the coding is bad.. but it does display lines like: << < 1 2 3 > >>
__________________
Pastebin
PHP Documentation Site
Allowee's Blog http://allowee.net
 
 

Recent GIDBlogOnce again, no time for hobbies by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Merge sort on a linked list Temujin_12 C++ Forum 1 06-Mar-2008 21:33
[include] list1.h -- Linked list class dsmith C Programming Language 2 04-May-2004 10:42
[You Decide] - Do we allow NEW threads with a list of links to resources? JdS GIDForums™ 24 07-Mar-2004 14:19
Why is your site in the overall list ONLY. JdS GIDTopsites™ 0 22-Aug-2002 08:57

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 02:54.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.