July 10th, 2000, 08:49 AM
I am fairly new to PHP and becoming a bit frustrated with arrays.
Is their any good stuff on the net anywhere about arrays?
Can someone tell me if you can open a resultset within MySQL and bang it straight into an array without navigating through the resultset and adding the rows into the array?
Any help please!!!!!
July 10th, 2000, 10:31 PM
I'm not entirely sure I follow your question, but I'll give it a shot anyway.
As for resources, there are tons of em' and the best ones are matter of opinion, I'd recommend php.net and hotwired.lycos.com/webmonkey/
check their section on PHP.
as for the last one.. there are several ways to get your info from mysql, and in the bulk of the methods the information is "always" in an array..
$sql="SELECT * FROM whatever";
$result = mysql_query($sql);
$myrow = mysql_fetch_array($result);
naturally this is only an example, if you were truly pulling data from the mysql_fetch_array() you'd be running that from a while or for loop.
but you can also run mysql_fetch_row(), assuming that you're only pulling back one row of data, in which you'd reference the values from an associative array..
$myrow = mysql_fetch_row($result);
$myitem1 = $myrow["item1"];
$myitem2 = $myrow["item2"];
I don't know if that answers the question, but I hope it helps.
Low Cost Hosting and Web Development.
July 12th, 2000, 09:21 AM
I think you pretty much have to step through the result set one row at a time, and assign that row to an array. you can make a loop to put the whole result into an array, then use that array later on to print your page. or you can make a loop to get a row, print out the data for that row, then loop to the next row. here's how i usually output data from mysql.
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
$query=mysql_db_query($database,"select id,fname,lname from contactinfo",$link_id);
while (list ($id,$firstname,$lastname) = mysql_fetch_row($query))
echo "ID: $id, First Name: $firstname, Last Name: $lastname<br>n";
that might not help, but it's my $0.02...