What I read, and what I work with is the idea that the following only returns one "row" of info at a time, from the $result variable.
<?
$query = "select * from panties";
$result = mysql_query($query);
$number = mysql_num_rows($result);
for($i = 0; $i < $number; $i++)
{
$row = mysql_fetch_row($result);
for($k = 0; $k < count($row); $k++)
{
echo $row[$k];
}
}
?>
how would I (syntax value requested) load each row that is pulled from each $i loop into an array? What I want to do is use an "id" passing scheme inside my script so that I can loop through each rowset resident in the same script. I think I know how to do it (or at least a direction to press) but I can't seem to load the contents of the above into one array for continual use (pointer control is the goal). Am I heading in the wrong direction?
NEWBIE: Loading an array from a mysql_fetch_row output???
Moderator: General Moderators
So you want to extract everything from a table and store it in an array?
This will create a 2D array.
Could you not reduce the number of results by restricting the number of columns, and adding a WHERE clause, if appropriate? I guess you need something to do with "id" in WHERE as you mention that later on.
Code: Select all
<?
$query = "select * from panties";
$result = mysql_query($query);
while ($row = mysql_fetch_row($result))
{
$big_arrayї] = $row;
}
?>Code: Select all
Array
(
ї0] => Array (
ї0] => col_0
ї1] => col_1
)
ї1] => Array (
ї0] => col_0
...etc...Another Newbie...tagging another question onto this answer
Can this array be returned and then used in html? To display the appropriate data on a webpage?
I'm a newbie and having a devil of a time getting my includes to work, I saw a thread on that that I'll try, but once I get the functions to work and return data, I'll need to figure out how that integrates w/ the html.
Currently, I've got a sample of code working that displays my images based on the filename that I pull from a mysql database, but I need to get this stuff into a table with the headers, footers and sidebars in....first step, get that include statement to work.
When I paste my php into the html, nothing happens...so I've obviously done something VERY wrong
.
Mel
I'm a newbie and having a devil of a time getting my includes to work, I saw a thread on that that I'll try, but once I get the functions to work and return data, I'll need to figure out how that integrates w/ the html.
Currently, I've got a sample of code working that displays my images based on the filename that I pull from a mysql database, but I need to get this stuff into a table with the headers, footers and sidebars in....first step, get that include statement to work.
When I paste my php into the html, nothing happens...so I've obviously done something VERY wrong
Mel
Mel,
I'm still new to this myself, but if you post your code, I will try to give you a hand. Sure somone else here can as well. Php integrates nicely with html and with mysql. Getting content displayed is easy, formatting it is the more challenging part -- which is still easy enough if you understand it. My problem is the book I'm currently reading, only covers concepts in general and doesn't cover what I'm trying to do at all. Give us a reply and I'm sure we can help.
I'm still new to this myself, but if you post your code, I will try to give you a hand. Sure somone else here can as well. Php integrates nicely with html and with mysql. Getting content displayed is easy, formatting it is the more challenging part -- which is still easy enough if you understand it. My problem is the book I'm currently reading, only covers concepts in general and doesn't cover what I'm trying to do at all. Give us a reply and I'm sure we can help.