Jump to content


Photo

Retreving all data.


  • Please log in to reply
4 replies to this topic

#1 GremlinP1R

GremlinP1R
  • Members
  • PipPipPip
  • Advanced Member
  • 62 posts
  • LocationSouth Africa

Posted 12 October 2006 - 05:46 PM

Hi there.

I have a litle problem, I'm pulling out data from a data base and then modifying it with the script.
I use the While ($row = $results) Comand to pull all data from the database thats needed.
Now about 100 lines down I want to display that data. But cant get it to work as it should. as I can only get it to display the first line and not the rest.
I can remember that you get a comand like this +- $Cald [] = data; and then you can retrive that some how...

Can some one please help.  Thanx

#2 komquat

komquat
  • Members
  • PipPipPip
  • Advanced Member
  • 130 posts
  • LocationHoughton, MI

Posted 12 October 2006 - 05:55 PM

How do you want to display all the data?  In a table, list form?

try:
 
 $display = "<table><tr><th>Headers</th></tr>";
   
while ($row=$result){
    $display .= "<tr><td>variables</td></tr>";
   }
display .="</table>";
Then insert the $display later when needed

#3 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 13 October 2006 - 10:05 AM

I use the While ($row = $results) Comand to pull all data from the database.
Now about 100 lines down I want to display that data.


About 100 lines down what?  Do you mean you have say 300 rows in your database and you want to display rows 100 to 300 and not 1 to 99?

I'm not sure that you mean by that?

Regards
Huggie
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools

#4 GremlinP1R

GremlinP1R
  • Members
  • PipPipPip
  • Advanced Member
  • 62 posts
  • LocationSouth Africa

Posted 17 October 2006 - 07:51 AM

I want all data in the database where the colum meets what is searched for.

Like lets take all in month september as an example.

So I have 300 persons thats in september. Now I pull all out of the data base by a row function that's in september and want to create an id (varible) for all of them after modifying the data with the script (the modifying is working 100%) and then later on I want to display all the varibels...

Help I'm stuck here.... Thanx

#5 akitchin

akitchin
  • Staff Alumni
  • Advanced Member
  • 2,516 posts
  • LocationCalgary, AB, Canada

Posted 17 October 2006 - 08:23 AM

sounds like you need an array:

<?php
$rows_returned = array();
while ($row = mysql_fetch_assoc($resource))
{
  // do your processing

  // add your id to the row variable
  $row['id'] = $id;

  // add this row to the list of returned rows
  $rows_returned[] = $row;
}
?>

to later output your stuff, use a foreach() loop on $rows_returned wherever you want to output it.  look in the manual for documentation on the foreach() loop.

for any more specific problems, we'll need to see some code.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users