RE: [PHP] Display Formatted Query Results

From: Date: Sun, 15 Apr 2001 03:13:15 +0000
Subject: RE: [PHP] Display Formatted Query Results
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-48615@lists.php.net to get a copy of this message
Teemu, thanks for the input. I tried this with somewhat modified code (added all the fields) and perhaps you saw what I did on my last post to the list. I have actually been able to get the same results as this. I'm a little confused about how to get the info in the 'for' section to format to look the way I need it and to 'wrap' with only two sets of results to a row. Using the way you show has the disadvantage of leaving blank rows if data is not available for that row plus, I don't see how to rearrange the results to look right. I mean, how do you put city, state, zip on the same line or how do you get "$city Round Table Discussion" in there? Are Thanks!! Here is yours after I made my attempt: while( $row = mysql_fetch_array( $result )){ $data[] = array( location => $row[1], address => $row[2], address2 => $row[3], city => $row[4], state => $row[5], zip => $row[6], day => $row[7], date => $row[8], time => $row[9], phone => $row[10] ); } for ( $i = 0; $i < count( $data ); $i++ ){ print("<br><br>Set $i:<br>"); print( $data[$i][location]."<br>"); print( $data[$i][address]."<br>"); print( $data[$i][address2]."<br>"); print( $data[$i][city]." "."Round Table Discussion"."<br>"); print( $data[$i][city]."<br>"); print( $data[$i][state]."<br>"); print( $data[$i][zip]."<br>"); print( $data[$i][day]."<br>"); print( $data[$i][date]."<br>"); print( $data[$i][time]."<br>"); print( $data[$i][phone]."<br>"); } try something like this... $db = "database_name"; $q = "select * from md_tbl"; $rs = mysql_query( $db, $q ); while( $row = mysql_fetch_array( $rs )){ $data[] = array( LOCATION => $row[1], ADDR => $row[2], ADDR2 => $row[3] ); } for ( $i = 0; $i < count( $data ); $i++ ){ print("Set $i:<br>"); print( $data[$i][LOCATION]."<br>"); print( $data[$i][ADDR]."<br>"); print( $data[$i][ADDR2]."<br>"); } sorry 'bout typos , it's getting late here ;-) Hope this helps. cheers Teemu Pentinsaari At 19:52 14.4.2001 -0500, you wrote: >Hi All, > >My apologies if this is too wordy. > >This is driving me nuts. I have very little experience or knowledge of PHP >and MySQL but have been put in a position that requires me to build several >applications that require me to figure them out. I am making progress, >though. Here is my first delimit: > >I have a form page that looks like this: >http://www.webtinker.com/fran_info.htm This form has several >things going >on. 1st, the first pull down list needs to reflect the same info as the two >location descriptions. 2nd, the two locations "Round Table Discussion" will >grow to an unknown number of entries over time so the two may become 6 or 8 >or... My first big (for me) hurdle is to figure out how to get these to >show up at the top of this form in order of the date with the closest one >first. They need to be in the same format as they appear but with >additional rows showing as more entries are made. The ones showing can't be >past due, or, don't show past dates. > >What I have figured out so far is how to populate the pull down, how to make >the admin form to fill in the needed info into the MySQL table and I have >had limited success in displaying the meeting info at the top of the form. >I just can't figure out how to make them wrap into groups of info, say with >5 entries of different meetings. Do I need a separate query for each row of >info using the limit statement in the query or is there a way to do this >using <gulp> arrays? I have just about every book available and just can't >find a good example of this type of formatted query results. How do I >approach this? > >Here is the table I am using: > >CREATE TABLE rnd_tbl ( > id tinyint(10) DEFAULT '0' NOT NULL auto_increment, > location varchar(100) NOT NULL, > address varchar(45) NOT NULL, > address2 varchar(45) NOT NULL, > city varchar(50) NOT NULL, > state char(2) NOT NULL, > zip varchar(14) NOT NULL, > day char(3) NOT NULL, > date varchar(25) NOT NULL, > time varchar(25) NOT NULL, > phone varchar(15) NOT NULL, > PRIMARY KEY (id) >); > >Many Thanks!! >Short Circuit > > >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net >For additional commands, e-mail: php-general-help@lists.php.net >To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#48615) next »