Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP How-To
| Search | Today's Posts | Mark Forums Read
PHP How-To Post your "How do I do this with PHP?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old February 5th, 2018, 03:12 PM
Friend of Wrox
Points: 1,107, Level: 13
Points: 1,107, Level: 13 Points: 1,107, Level: 13 Points: 1,107, Level: 13
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2004
Location: , , .
Posts: 240
Thanks: 0
Thanked 1 Time in 1 Post
Default how to join fields to their array of values?

The first while has all the field/column names and the 2nd while has the values. But how can I join the fields so that they represent to their array of values?

PHP Code:
    $showTables "SHOW COLUMNS FROM ".$dbTable11;
    if(
$output $conn->query($showTables)){
        
$fields = array();
        
//while($result = mysqli_fetch_assoc($output)):
        
while($row $output->fetch(PDO::FETCH_ASSOC)){
            
$fields[] = $row['Field'];
        }
    }
    echo 
'<pre>';
    
print_r($fields);
    echo 
'</pre>';
    
    
    
$sql1 "SELECT * FROM ".$dbTable11." WHERE book='".$getBook."' AND chapter='".$getC1."'";
    
$result1 $conn->query($sql1);
    while(
$row $result1->fetch(PDO::FETCH_ASSOC)) {
        if(
$row['text_data']!=NULL){
            
            
$id[] = $row['id'];
            
$book[] = $row['book'];        
            
$bookTitle[] = $row['book_title'];
            
$recordType[] = $row['recordType'];        
            
$chapter[] = $row['chapter'];
            
$verse[] = $row['verse'];
            
$bookSpoke[] = $row['book_spoke']; 
            
$chapterSpoke[] = $row['chapter_spoke']; 
            
$verseSpoke[] = $row['verse_spoke'];
            
$textData[] = $row['text_data'];        
            
$strongs[] = $row['strongs'];
            
$transliteration[] = $row['transliteration'];
            
$etymology[] = $row['etymology'];
            
$etymStrongs[] = $row['etym_strongs'];
            
$etymDesc[] = lcfirst($row['etym_desc']);
            
//$hebWord[] = hebrevc($row['heb_word']);
            
$hebWord[] = $row['heb_word'];
            
$greek_word[] = $row['greek_word'];
            
$added[] = $row['added'];
            
$also[] = $row['also'];
            
/*            $fields[0] = $row['id'];
            $fields[1] = $row['book'];        
            $fields[2] = $row['book_title'];
            $fields[3] = $row['recordType'];        
            $fields[4] = $row['chapter'];
            $fields[5] = $row['verse'];
            $fields[6] = $row['book_spoke']; 
            $fields[7] = $row['chapter_spoke']; 
            $fields[8] = $row['verse_spoke'];
            $fields[9] = $row['text_data'];        
            $fields[10] = $row['strongs'];
            $fields[11] = $row['transliteration'];
            $fields[12] = $row['etymology'];
            $fields[13] = $row['etym_strongs'];
            $fields[14] = lcfirst($row['etym_desc']);
            //$hebWord[] = hebrevc($row['heb_word']);
            $fields[15] = $row['heb_word'];
            $fields[16] = $row['greek_word'];
            $fields[17] = $row['added'];
            $fields[18] = $row['also'];    */        
        
}
    }

            
$fields[0] => $id;
            
$fields[1] => $book;        
            
$fields[2] => $bookTitle;
            
$fields[3] => $recordType;        
            
$fields[4] => $chapter;
            
$fields[5] => $verse;
            
$fields[6] => $bookSpoke
            
$fields[7] => $chapterSpoke
            
$fields[8] => $verseSpoke;
            
$fields[9] => $textData;        
            
$fields[10] => $strongs;
            
$fields[11] => $transliteration;
            
$fields[12] => $etymology;
            
$fields[13] => $etymStrongs;
            
$fields[14] => etymDesc;
            
$fields[15] => $hebWord;
            
$fields[16] => $greek_word;
            
$fields[17] => $added;
            
$fields[18] => $also
The Following User Says Thank You to gilgalbiblewheel For This Useful Post:


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excluding values from a table join dzitam SQL Language 2 April 30th, 2007 09:10 AM
While join a new table, other fields are vanished ksskumar2000 Crystal Reports 0 March 14th, 2005 06:35 AM
JOIN an array Jen VB How-To 2 December 2nd, 2004 09:58 AM
Passing php array values to javascript array gkrishna Pro PHP 0 November 6th, 2004 03:20 AM
getting data fields from array suni_kutty Crystal Reports 1 November 5th, 2004 06:49 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.