Forum Moderators: coopster
The table has 10 columns, including the primary key column Drop_1, and 6 rows. The Drop_1 column is indexed at 600, 800, 1000, 1200, 1400, and 1600. The table is representative of a series which will have varying numbers of rows and columns.
In phpMyAdmin, I see the 2d array I would like to see eventually on my web page, when I select the SQL tab and enter
SELECT * FROM `65chain` WHERE Drop_1 is not null
Great. I am now creating my script.
So far I have:
<?php
$username = "#*$!#*$!#*$!";
$password = "yyyyyyyyy";
$hostname = "zzzzzzzzz";
$dbh = mysql_connect($hostname, $username, $password)
or die("Unable to connect to MySQL");
// select database
mysql_select_db("aaaaaaa") or die ("Unable to select database!");
// execute query
$query = "SELECT * FROM 65chain";
$result = mysql_query($query) or die ("Error in query: $query. " .
mysql_error());
// iterate through rows
while ($row = mysql_fetch_row($result))
{
echo "$row";
}
// close database connection
mysql_close($dbh);
?>
I have obviously done something stupid in my ignorance - the result on the web page screen is not the 2d array I wish to see, but ArrayArrayArrayArrayArrayArray
I'd be grateful for a steer on how to display my 2d array.
The table consists of this particlar array - except that the ..... are used here to space the "X" and the "-" symbols corectly.
Drop_1 600 800 1000 1200 1400 1600 1800 2000 2200 2400 2600
600.......X.....X.....X....X......X......X.....X....X......X......X......X
800.......X.....X.....X....X......X......X.....X....X......X......X......-
1000......X.....X.....X....X......X......X.....X....X......X......X......-
1200......X.....X.....X....X......X......X.....X....X......-......-......-
1400......X.....X.....X....X......X......X.....X....X......-......-......-
1600......X.....X.....X....X......X......X.....X....X......-......-......-
What I am trying by stages to do is to display the "X" and the "-" in a table. The columns will be lablled to show blind (shade) width, the rows will be labelled to show vertical drop.
As a first stage, I was trying to learn how to show the full array, the next thing was to learn how to insert each "X" or "-" into a <td>, so that the spatial relationship was correct.
So, once again your forebearance with an ignoramus, please - I'd be grateful for a few more steers!
while ($row = mysql_fetch_row($result)) gives me a browser display of: 600:X:X:X:X:X:X:X:X:X:X: 800:X:X:X:X:X:X:X:X:X:-: 1000:X:X:X:X:X:X:X:X:X:-: 1200:X:X:X:X:X:X:X:-:-:-: 1400:X:X:X:X:X:X:X:-:-:-:1600:X:X:X:X:X:X:X:-:-:-: Frustrating. The data is all there in the browser, but not stacked as I would wish - i.e.: At the moment I have not discovered the code to do that. Any suggestions? [1][edited by: jatar_k at 4:17 pm (utc) on June 13, 2005]
{
echo "$row[0]",":";
echo "$row",":";
echo "$row[3]" ,":";
echo "$row[4]" ,":";
echo "$row[5]" ,":";
echo "$row[6]" ,":";
echo "$row[7]",":";
echo "$row[8]",":";
echo "$row[9]" ,":";
echo "$row[10]",":";
echo "$row[11]" ,":";
echo "$row[12]" ;
}
600:X:X:X:X:X:X:X:X:X:X:
800:X:X:X:X:X:X:X:X:X:-: --- and so on.
[edit reason] fixed sidescroll [/edit]