Click here to Skip to main content
15,886,110 members
Home / Discussions / Linux, Apache, MySQL, PHP
   

Linux, Apache, MySQL, PHP

 
GeneralRe: SQL to multidimenisonal array Pin
MacRaider420-Dec-10 8:43
MacRaider420-Dec-10 8:43 
GeneralRe: SQL to multidimenisonal array [modified] Pin
MacRaider420-Dec-10 9:29
MacRaider420-Dec-10 9:29 
GeneralRe: SQL to multidimenisonal array Pin
Luc Pattyn20-Dec-10 10:25
sitebuilderLuc Pattyn20-Dec-10 10:25 
GeneralRe: SQL to multidimenisonal array Pin
MacRaider420-Dec-10 14:46
MacRaider420-Dec-10 14:46 
AnswerRe: SQL to multidimenisonal array Pin
Luc Pattyn20-Dec-10 14:59
sitebuilderLuc Pattyn20-Dec-10 14:59 
GeneralRe: SQL to multidimenisonal array Pin
MacRaider421-Dec-10 2:06
MacRaider421-Dec-10 2:06 
GeneralRe: SQL to multidimenisonal array Pin
MacRaider421-Dec-10 7:35
MacRaider421-Dec-10 7:35 
GeneralRe: SQL to multidimenisonal array Pin
Luc Pattyn21-Dec-10 8:02
sitebuilderLuc Pattyn21-Dec-10 8:02 
This is part of a function that returns an array with all the table names in a MySQL database:
$query="SHOW TABLES";
$Results=mysql_query($query);
if (!$Results) die("DB Error in GetTableNames ($query)".mysql_error());
$res=array();
while($row=mysql_fetch_array($Results)) $res[]=$row[0];

the result is a simple array, not an associative array! It behaves like a list as things were added one after another without using an index. Nevertheless, you can retrieve them by index.

this untested example would use an associative array:
$query="SELECT field0,field1 FROM table";
$Results=mysql_query($query);
$res=array();
while($row=mysql_fetch_array($Results)) $res[$row[0]]=$row[1];

this uses field0 as the index (even when not numeric) and field1 as the data to be stored.

If you aren't getting such information from where ever it is you learn PHP, I suggest you switch to another book or course!

Smile | :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

GeneralRe: SQL to multidimenisonal array Pin
MacRaider421-Dec-10 10:01
MacRaider421-Dec-10 10:01 
GeneralRe: SQL to multidimenisonal array Pin
Luc Pattyn21-Dec-10 10:09
sitebuilderLuc Pattyn21-Dec-10 10:09 
GeneralRe: SQL to multidimenisonal array Pin
MacRaider421-Dec-10 14:12
MacRaider421-Dec-10 14:12 
AnswerRe: SQL to multidimenisonal array Pin
schwarzenneger21-Dec-10 18:48
schwarzenneger21-Dec-10 18:48 
GeneralRe: SQL to multidimenisonal array Pin
MacRaider422-Dec-10 1:40
MacRaider422-Dec-10 1:40 
GeneralRe: SQL to multidimenisonal array Pin
cjoki22-Dec-10 5:24
cjoki22-Dec-10 5:24 
AnswerRe: SQL to multidimenisonal array Pin
cjoki22-Dec-10 5:21
cjoki22-Dec-10 5:21 
GeneralRe: SQL to multidimenisonal array Pin
MacRaider422-Dec-10 6:02
MacRaider422-Dec-10 6:02 
GeneralRe: SQL to multidimenisonal array Pin
cjoki22-Dec-10 6:47
cjoki22-Dec-10 6:47 
GeneralRe: SQL to multidimenisonal array Pin
MacRaider422-Dec-10 8:06
MacRaider422-Dec-10 8:06 
Questionwireless internet not running on vmware Pin
AmbiguousName20-Dec-10 6:32
AmbiguousName20-Dec-10 6:32 
AnswerRe: wireless internet not running on vmware Pin
LloydA11120-Dec-10 6:44
LloydA11120-Dec-10 6:44 
Questionhow to measure TCP congestion windows using python ?? Pin
peaceziz19-Dec-10 0:02
peaceziz19-Dec-10 0:02 
Questionpopulate combo box / dropdown list from mysql Pin
komanche18-Dec-10 22:46
komanche18-Dec-10 22:46 
AnswerRe: populate combo box / dropdown list from mysql Pin
Luc Pattyn19-Dec-10 2:34
sitebuilderLuc Pattyn19-Dec-10 2:34 
AnswerRe: populate combo box / dropdown list from mysql Pin
Lucian.cornea21-Dec-10 14:52
Lucian.cornea21-Dec-10 14:52 
Questionphp Pin
bitayeganeh18-Dec-10 1:40
bitayeganeh18-Dec-10 1:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.