Computing.Net > Forums > Web Development > PHP mysql_fetch_array question

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

PHP mysql_fetch_array question

Reply to Message Icon

Name: talekim
Date: March 23, 2009 at 19:50:52 Pacific
OS: Windows XP Home
CPU/Ram: 2.797 GHz / 3053 MB
Subcategory: PHP
Comment:

I'm in the process of making a file system database and so far its working out really good. The only problem is when I use the list command that I created I can't format the data HTML like table data and stuff that you can do with mysql_fetch_array. You use mysql_fetch_array with a while statement to list what you selected from the database and you can format the html that you want to use.

What I'm basically is asking is that how do you recreate the mysql_fetch_array?


For example I have a dfs/users/phantom/password.txt
dfs= folder/database
users=folder/table
phantom=folder/value
and password.txt= text/data

// Value Function //
function dfs_value($table,$name,$value,$newname=false,$data,$event){
include("connect.php");
if($event=="Create"){

}elseif($event=="Edit"){

}elseif($event=="Delete"){

}elseif($event=="Move"){

}elseif($event=="Merge"){

}elseif($event=="Download"){

}elseif($event=="Select"){

echo"Opening File:$databaseselect/$table/$name/$value.dfs";
echo"
";
$fileopen=fopen("$databaseselect/$table/$name/$value.dfs",'r') or die("Could not open file");
echo fread($fileopen,filesize("$databaseselect/$table/$name/$value.dfs"));
fclose($fileopen);


}elseif($event=="List"){
$opendirectory="$databaseselect/$table/";
while($contents=readdir($opendirectory)){
if(preg_replace("/(.*)\.(.*)/",null,$contents)){
$fileopen=fopen("$databaseselect/$table/$contents/$value.dfs",'r') or die("Could not open file");
echo fread($fileopen,filesize("$databaseselect/$table/$contents/$value.dfs")) ."
";
fclose($fileopen);

}

}
return $opendirectory;
}else{

echo"You have not used a valid command. Please fix this.";
}

}


and to use that function you would use something like:

echo dfs_value("users","1","password","","","List");

the list option will list all values that you selected which would be password.txt under each value.


I tried creating a function like dfs_fetch_array() but I still can't get it to work with the while statement like you can with the mysql_fetch_array().

I want to do this so I can for example put the list into a table and stuff but in order to do that I would have to go into the function it self and use the tablr html tag. I do not want to do that.

I just want it to work the same way the mysql_fetch_array does or smiler to it.

Thanks
also dfs=Data For Sites



Sponsored Link
Ads by Google

Response Number 1
Name: Michael J (by mjdamato)
Date: March 24, 2009 at 11:20:01 Pacific
Reply:

If I am understanding you correctly you want to read records iteratively from a flat-file. If that is the case AND if you have each record on it's own line then just use file() which will read a file as an array with each line as an element in the array. You can then run a foreach() similar to doing a while loop with mysql_fetch_array()

Michael J


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Web Development Forum Home


Sponsored links

Ads by Google


Results for: PHP mysql_fetch_array question

how to make user correctly answer r www.computing.net/answers/webdevel/how-to-make-user-correctly-answer-r/3457.html

Simple PHP Question www.computing.net/answers/webdevel/simple-php-question/2630.html

easy php question www.computing.net/answers/webdevel/easy-php-question/549.html