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
  #11  
Old 13-Feb-2004, 06:49
giobbi giobbi is offline
New Member
 
Join Date: Jan 2004
Posts: 14
giobbi is on a distinguished road
Hi again. Maaan have i been struggling with this! Yes, i had some blank posts in the "foretags" field but now they are gone, no blank posts anywere but that didn't help.
I found somewere on the net to put NULL instead of '' and now the headlines shows but in the wrong place!! Were the headline1 should be on Company 1 it shows on Company 2s place, like this:

- Blank -
user on company 1
user on company 1
user on company 1
...

Company 1
user on company 2
user on company 2
user on company 2

Company 2
user on company 3
user on company 3
user on company 3
..

And so on. Anyone have an idea? Here's my script:

PHP Code:

<?php 
// .. other 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'] ) 
{ 
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. 
$foretag = $newArray['foretag']; 
} 

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"; 
} 

// .. other PHP code... 
?>


Another question: how do i make the output on two colums?

Company 1 Company 6
User .............user
user ..............user
user ..............user
...

I want to make a list in two colums in a little popup window...

Thx.
Last edited by dsmith : 13-Feb-2004 at 08:46. Reason: Added php syntax highlighting
  #12  
Old 26-Feb-2004, 22:45
ichijo ichijo is offline
New Member
 
Join Date: Feb 2004
Location: Sydney
Posts: 1
ichijo is on a distinguished road
Have the first part of the 'if' expression read like this:
PHP Code:

if( $foretag != $newArray['foretag'] ) 
{ 
$foretag = $newArray['foretag']; 


ie, move: $foretag = $newArray['foretag'];

from the bottom to the top.

That's how I got it working for me.

Regards,

Ichi
  #13  
Old 27-Feb-2004, 01:34
giobbi giobbi is offline
New Member
 
Join Date: Jan 2004
Posts: 14
giobbi is on a distinguished road
!!! Man did u just save a couple of years of my life! I have pulled my hair on this one since i posted it and was it simple to.

I can't thank you enough but thanks again.
 
 

Recent GIDBlogProgramming ebook direct download available 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
Reliable Hosting $2-$8/month: PHP, MySQL, FrontPage, CGI, SSH, FTP, POP3, Web Mail fcolor Web Hosting Advertisements & Offers 0 04-Nov-2003 07:03
Automate a data change php form mjfmn MySQL / PHP Forum 4 20-Oct-2003 10:37
FREE 25 MB, No Ads, Control Panel, ASP, ColdFusion, PHP, MySQL, Access Hosting rkmails Free Web Hosting 0 08-Sep-2003 06:49
[script] Password Protect web pages/site using PHP and MySQL JdS PHP Code Library 0 23-Jul-2003 11:02
Windows: From only £20p/y,Linux: from $10p/m. ASP, ASP.NET, PHP, Free MySQL, +More EyotaHosts Web Hosting Advertisements & Offers 0 28-Jun-2003 14:54

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

All times are GMT -6. The time now is 22:33.


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