Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > PHP How-To
Password Reminder
Register
Register | FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old February 5th, 2018, 02: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 0 Times in 0 Posts
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
Reply With Quote
Reply


Thread Tools
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 05:35 AM
JOIN an array Jen VB How-To 2 December 2nd, 2004 08:58 AM
Passing php array values to javascript array gkrishna Pro PHP 0 November 6th, 2004 02:20 AM
getting data fields from array suni_kutty Crystal Reports 1 November 5th, 2004 05:49 AM



All times are GMT -4. The time now is 05:27 PM.


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.