Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    PHP


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





Get Data From The Db And Store It In An Array


I want to have an input field in my Admin CP when you are creating a Forum where you can input a list of numbers (member ids) seperated by commars, like this:

Quote1,6,4,8,2
These will be the ids of people who can moderate the Forum and will be stored in the db along with all the other stuff like forum name/description etc.

That's easy enough.

Now my problem is I need to get that from the db and store it in an array... basically so I can do something like:

<?php
if(in_array($_SESSION['mem_id'], $forum_moderator_array)) {
    echo('Congratulations, you are a forum moderator.');
}
?>

How can I go about doing this?




View Complete Forum Thread with Replies

Related Forum Messages:
Mysql_fetch_array Way To Pull Out All The Data, Store It In An Array
I have a webpage which runs repetitive queries agaist a database in order to extract one item at a time and then put the items in an HTML table. The reason for this is formatting, plus the page hits 4 databases.

Instead of running multiple queries pulling one item at a time...is there a way to pull out all the data, store it in an array, and then pull individual items from the array with php as I want to insert them in the table? So, example is Code:

View Replies !
Store While Statment Data In Array Using Session And Retrieve?
I wish to store retreve value from my sql using session array and retrieve this value.
here is my while statement, which is displaying records from my database. I want to store all this value in an array using session and than retrieve this value on click of the table row. Code:

View Replies !
Use Sessions To Store Data And Use That Session To Get Query Data.
We have some Java programmers in our software dev, and they are
pressuring us to use Sessions to store data and use that Session to get
query data. They say that it is ok since it is like Entities in Java. I
am baffled as a .NET programmer, we tend to avoid using sessions and
instead use DataSet, is there any equivalent of dataset in PHP?

View Replies !
Store Data
I need to store the data of a golf course and a round. so what I am wondering from all our database guys is what is the best way to normalise this data?I need to store the info on 4-5 sets of tees and then a users information.

my thoughts were to have a course table. then have a red,blue, black, white, gold tee table that is linked with the course id field however then I would have hole 1 - hole 18 fields in those databases is that really the only way? I mean I guess I could store the info in one field with commas and then explode the data after that, would that be too much of a performance issue?

View Replies !
Store Data In Session?
how to store id in a session?? i'm trying to develop a shopping cart, whereby user need not login when they add products into cart. if i add one product into the cart, then everything is fine. if there's one product in the cart and i click continue shopping and add one more product, the first product will not be there, it will be replaced by the second product. how am i suppose to solve tat?

View Replies !
Where Does The Session Data Store?
In php.ini file, if I comment the session.save_path line, then actually I can still use session, but where do it store? I am using Window filesystem.

; Argument passed to save_handler. In the case of files, this is the path
; where data files are stored. Note: Windows users have to change this
; variable in order to use PHP's session functions.
;session.save_path = /tmp

View Replies !
Want To Store Some Data In Sessions
I want to store some data in Sessions, but i have this error

Warning: Unknown(): Your script possibly relies on a session side-effect
which existed until PHP 4.2.3. Please be advised that the session extension
does not consider global variables as a source of data, unless
register_globals is enabled. You can disable this functionality and this
warning by setting session.bug_compat_42 or session.bug_compat_warn to off,
respectively. in Unknown on line 0

Warning: Unknown(): open(/tmpsess_622d49ff6fbad164ba2ad7cd05fdd544, O_RDWR)
failed: No such file or directory (2) in Unknown on line 0

Warning: Unknown(): Failed to write session data (files). Please verify that
the current setting of session.save_path is correct (/tmp) in Unknown on
line 0

My version of php is version 4.3.4

Is there something that I have to change in my php.ini file?

View Replies !
How Much Data Can I Store In A Session?
Is there a limit to the amount of data that can be stored in a session before nasty side effects (such as a drop in performance or excessive resource usage on the server) will occur?

I'm working on a DHTML menu that's being rebuilt from MySQL table data on each page reload. Lots of loops and iterations, which slows down the page load, creates a nontrivial CPU load on the server, and is inelegant in general. I'm considering rebuilding the menu once and then caching it for, say, 5 minutes. I'm considering storing the entire menu code in the session, which currently comes to 32k of menu code but may (and probably will) be twice that much, or more, in the future.

So... is it stupid to dump 32-64k of HTML code into $_SESSION, or can I get away with it? What are the consequences? Code:

View Replies !
Good Way To Store Data For Each Day
I need a good way to store data for each day, but it needs to be accessed easily.

data 1 - 125478
data 2 - 123549

Those numbers would change each day, and i need to store that value for each day.  It would be kinda like a stats archive.

I would need to refer back as far as one year from the first date.

Is there an easy way to do this?

View Replies !
Using Session To Store Data
For instance, when a user clicks on a whosonline list maybe they like to to be displayed Z-A by default

Normally you would save this data in a database.. which I will

However, I dont want to have to query the database everytime I need to find out if they want something displayed to there Z-A preference

So, upon login I was thinking of querying the database and then storing everything I need in SESSIONS

Is this the norm or are there better ways to do this. If it is the norm, can you think of any reason why this would be a bad idea..

View Replies !
Store Values In An Array
$a=10;
$a=15;

while ($a <= $b)
{
$a++;
}

The output is 10,11,12,13,14,15

How to store the values of $a(10,11,12,13,14,15) in an sigle array.

View Replies !
Store Classes In An Array?
Is it possible to store classes in an array? I am fairly new to PHP,
and haven't found anything either way yet.
I have a program that where you can have multiple notes attached to a
ticket, which are stored in a database. I would like to just pull all
the notes from the database, storing each one in a seperate class,
which itself is stored in an array (well, another class, but it's a
classList, it's mainly an array).
I'm getting an error when I run the page:
"Cannot use a scalar value as an array", and "Call to a member function
on a non-object". The second is related to the first, as I'm calling a
function on the array value.
If it is possible, I probably coded something wrong. If that's the
case, I'll post some code.

View Replies !
Store A Array As A Variable
is there any way that i can store a array as a variable because i dont want to creat a database for thousands of variables. heres what i thought of so far

<?PHP
$arrayval = "1,3,2,7,4,6,8,15,12,78,96,1203,1029,39509,12999";
$array = array($arrayval);
echo $array[1],$array[3],$array[2],$array[5],$array[6],$array[4],$array[7],$array[9],$array[5],$array[10],$array[13];
echo "<hr>";
echo $arrayval;
echo "<hr>";
$sum = $array[1]+$array[3]+$array[2]+$array[5]+$array[6]+$array[4]+$array[7]+$array[9]+$array[5]+$array[10]+$array[13];
echo $sum;
?>

View Replies !
Store Array In Session
i store my shopping carts items in an array in a session like this Code:

View Replies !
What's The Best Way To Store An Array In The Database
I am trying to build a simple tree menu where the main items can be either a link or open up a subList of items which themselves can belinks or open into more submenus and so on.
An example is:

$ar = array(
'new_user' => 'newuser.php',
'tst1' => array(
'subtst' => 'subtstlink.php',
'subtst2' => 'sublink2.php'
),
'heyhey' => 'heyhey.php',
);

I am wondering what is the best way to store that in a mysql database (Both the item name and the link to it). Is there any php function that will allow me to make such an array into some sort of variable (String?) which can then be read easilly and made back into the array for manipulation and creation of the tree menu?

View Replies !
How To Store Array In Cookies?
I try to store array in cookie this way:

for($i=0;$i<5;$i++)
{
    $field[]='test'.$i;
}
$_COOKIE['field2']=$field;

Is it possible do it that way? I don't want to store each value of array list store separately. I'd like to store them at once. If I was storing values just to another "normal" variable (not cookie), I would do it this way: Code:

View Replies !
How Do You Store An Sql Result In A Php Array?
How do you store an sql result in a php array? The array will hold, the following fields; itemid, itemname and itemdesc. I would then require, depending on the user selection to query the array by itmeid, and return the itemname.

View Replies !
Can I Store An Array In MySQL?
I would like to store an array in a MySQL table. The values will be numeric and ranging from 1-999. I'm not sure if this is possible, and if it is then I'm not sure on the correct field type to use.

View Replies !
Store Variable In An Array
so i have a query that returns a bunch of rows.... i display the contents of the query into a table... one of the variables that the query returns is $title....

after each row is returned im wanting to store the $title variable into an array, so i can then access that array later... here is my code for storing $title into the array Code:

View Replies !
Save Form Data - How To Temporarily Store The Form Data Of Page 1
i have separated a form into 3 separate php pages as step 1, step 2 and step 3. i would like to know how to temporarily store the form data of page 1 when the user is moving onto page 3 after completing form 2 on page 2?? then retreive and send the data of all 3 forms together in one email to the webmaster when the user clicks submit on page 3 after completing the 3rd form as well as the previous 2.

View Replies !
Does Somebody Know A Free PHP Webserver To Store Data On?
Does somebody know a free PHP webserver to store data on?

View Replies !
Display A New Html, After The Data Is Store?
I want to know how to call a HTML file in php.
I know how to create it, but how can i call and display the newly
created HTML, which contained the data that a user just entered?
What command should i use?

View Replies !
Obtain Data From Another Website And Store It?
Basically theres a website that displays the results of football matches and every few days. I want to somehow grab those results and put them in a mysql db and then show them on a part of my website. The layout of the results is always the same.

I know some basic php but I don't have any clue as to how I would go about doing this. Has anyone done this before or something similar?

View Replies !
Store Currency Data Into An Sql Database
Might be mainly a bit of an sql question but here it is anyway. i want to store currency data into an sql database like $233.56 but if theres just $233.00 it only stores $233. Is there a way i can make it store the .00 aswell? Ive tried the function 'round(blabla, 2);' but if there isnt any .00 pulled from the db it just puts $233.

View Replies !
Store Encrypted Data Into A Cookie
I am trying to store encrypted data into a cookie. I have tested to make sure there is actually data being encrypted. setcookie code:

setcookie( $this->cookiename, $frozen, $this->expiration, $this->path, $this->domain, $this->secure);

I use setcookie to create the cookie with the values but when I test with session_get_cookie_params() all I get back is:

Array
(
[lifetime] => 0
[path] => /
[domain] =>
[secure] =>
)

I should be getting back the information that is stored in $frozen, right?

View Replies !
Simple Web Form Which Can Store Data
I need a simple form on my site where users can enter basic info like their name, address, email address etc. The data has to be stored. Do I need a database for this? Please can anyone tell me whether there is an easily customizable script or something which does this..or some stepbystep tutorials?

View Replies !
Store XML Data To Database Using SimpleXML
PHP and MySQL and trying to learn, but can somebody help me to store XML data into a database (MySQL) using PHP (and the example XML file at "http://php.net/simplexml"?)

View Replies !
Store An Array In A Text Document
I want to store an array in a text document. what I've been doing so far looks like this:

fputs( $myFile, $myArray );

but all it does is write the word "Array", instead of the actual array. I'm new to php and I've done my best to search the manual and numerous web resources (including this forum) for an answer, so please don't flame.

View Replies !
Store Mysql Results Into An Array
i just started using php. i've used it before as a maintainer. fun stuff. well now i'm the writer. i want to abstract all the DB commands away from myself and all other developers. so i'm writing a function to query the php database from all users of the database and store them into an array as a return value so that i can seperate my database code from my html creation code.

1. is there a way to put all my database functions into a php file and include that file into all my other php pages? similiarly to a #include in C++ or a import package name in Java?

2. my code to run down the fetched results and store them into an array doesn't seem to be working the way i want it to. if i print out the results from the mysql returned fetch the data is fine. however the array seems to print out "Array[elementnumber]" instead of the value. Code:

View Replies !
How To Store Checkbox Values To An Array?
I need to allow the user to select multiple mysql records via an html form checkbox.  On submission of the form I would like to store these values in an array for either multiple record deletion or creating a list of records. Code:

View Replies !
Four Fields That Are Dates, Store As An Array
I have a form that has over 100 fields. I have four fields that are dates that I would like to store as an array. When I submit the form I place the dates in the array like so:

$planworkdate = array("mon" => $planworkdate0,"tue" =>$planworkdate1,"wed" =>$planworkdate2,"thu" =>$planworkdate3);

and insert into mysql database. When I try to retrieve the data I get the word Array for the result. What am I doing wrong?

$query = "SELECT planworkdate from general";
$resultall = mysql_query($query);
$planworkdate=mysql_result($resultall,$x,"planworkdate");

print $planworkdate; ...

View Replies !
Take All The Results From A Query And Store Them In An Array
trying to get my head around arrays, and I want to take all the results from a query and store them in an array so that I can use them  for later use: Code:

View Replies !
Store Form Fields To An Array
i have a form which consists of several fields for name, address, number etc. i use a php form to process this and output it onto a html form. the thing is, i'd like to store the information in an array. so for each user, the array will have their details. and this can be printed on the screen. can you tell me how this is possible. i have seen examples of arrays, but the values are assigned to the variables already.

View Replies !
Redirect Page After Store The Data Into The Database?
How can I redirect this page after I store the data into the database?  Here is the entire script: Code:

View Replies !
Store Image Path/data Mysql
I've got this horribly nasty code that just won't work. It's a profile creator for a "featured band" type of situation. It's supposed to take the image, store it in a directory as well as pass the image path to mysql along with the details from the form.

It uploads the image to the right directory and the textfields are entered fine, but I don't know why it's not storing the image path to mySQL. Can someone clarify things for me?? Code:

View Replies !
Store The Entire Table In A Two Dimensional Array
I am reading info from a tab-delimited text file and I was wondering if anyone knew how to get this concept to work. I am trying to store the entire table in a two dimensional array, but the way I'm doing it right now won't work.

for($i=0; $i<$numrows; $i++)
{$columnsvalue[i] = explode(" ",$newfile[i]);}

does anyone else know how to better work with multi-dimensional arrays?

View Replies !
Variables To Store (Name,Species,Sex) Inside An Array
In PHP, is there anyway of using variables to store each piece of information (Name,Species,Sex) inside an array. Then, when it comes to fetching the information, the array position (e.g. 0) is called along with the information type (Name etc). A bit like the following: record(1).name The information is coming from the record array, at position 1 displaying names.

View Replies !
Read Data From A Table In Pdf File And Store It To Database
I have to populate MySQL database where data will come from a PDF file. This PDF file has a well formatted table and I have to make a similar replica of the table data into MYSQL Database. Is that possible at all?

View Replies !
Array Problem - Extract And Store In Seprate Variables .
I have an array from a program of the type $list_box_contents[$row][$col]['text'];
 There are 3 columns  and an indefinite no. of rows.

Each array element contains a few bits of information. I want to to extract this and store in seprate variables .

$list_box_contents[$row][2]['text']; has 2 bits of information, a price and a small text box with some text. How can extract the price data from this .

View Replies !
Store The Selected Checkbox Values In A Variable Or An Array?
how to store the selected checkbox values in a variable or an array?

View Replies !
Array Problem... - Store This List In $_SESSION['liste'];
the user selects 6 numbers in a list I have to store this list in $_SESSION['liste']; (I cant do it differently) the list is stored like that: 34-21-44-32-12-11 (cant do it differently either)

what I need to do is to explode the array, get rid of the - , sort the values in ascending order and send them to my table as a string. so in the end I should have: 111221323444

I tried using a variation of laserlight's script (given in a previous post) without success... hope that someone will have time to give me a hand again in telling me what I could change in saberlights script to make it work.

View Replies !
Explode - Open File Store The Numbers In An Array
I have a .txt file looking like this

3
4
56
23
59
10

i want PHP to open that file and store the numbers in an array something like this

$q = "3,4,56,59,10"

Now i want to read $q and see if it contains 56 and 10 (it does) Code:

View Replies !
MySQL Table To Store Username/password And Other Data For Members
I have a PERL program that uses a .db file to store username/password and other data for members. I am also going to have a PHP/MySQL based board system (phpbb) installed on the server. What I would REALLY like to do is to have users be able to register for one and be automatically registered for the other. The problem is. I don't know much about how all this works! I know just enough to get by with changing code around, etc. and also enough to screw things up now and then.;)

I could pull just the username/password data from the .db file (using a PHP script/file) and then put the data into the MySQL table used by the boards. But I'm not sure how to go about doing it, as far as the code and everything.

View Replies !
Store Date In A Date Field In My MYSQL Data Table
I have a form with a feild that when clicked on pops up a calendar which I can select a date I wnat to insert into the field. The date inserted displays "03 Apr, 2007". I want to store that date in a date field in my MYSQL data table, a field named "f_date" set to date type.

When I save the record the data field "f_date" displays "0000-00-00" which I take it the date input is not getting inserted to the table. My insert field code is PHP Code:

<input name="f_date"  type="text" class="bodytext" id="f_date" onclick='scwShow(this,this);' value="" size="15" />

View Replies !
Array Data Matches But Array Created In Loop Doesn't Work
I have the exact same data in two arrays, but only the array created
like so will work:

View Replies !
Trying To Calculate An Average Array From An 2d Data Array
I'm trying to calculate an average array from an 2d data array.
my problem is that my function does not generate an average array but just
one value. but i do not understand why it does not work.

code:
-----
function calculateAverageRating($rating_matrix)
{
$average_rating = array();
foreach($rating_matrix as $cus_id => $ratings)
{
$counter = 0;
$sum = 0;
foreach($ratings as $pro_id => $item_rate)
{
$counter++;
$sum += $item_rate;
}
echo $cus_id."->".($sum/$counter)."<br>";
$average_rating[$cus_id] = ($sum / $counter);
}
echo "<hr>";
echo "<table> <tr>";
foreach($average_rating as $key => $value);
{
echo "<td>$key::$value</td>";
}
echo "</tr></table>";
return $average_rating;
}

wanted:

input -> output

1 1 1 1
2 2 2 2
4 4 4 4

but my functions just does:

input -> output

1 1 1
2 2 2
4 4 4 4

View Replies !
How To Add Data To An Array
I have a question about how to add to an array. below is a test program for an associative array in which the value is also an array. I can work out how to fill the array when it is declared (as shown) but I have not been able to understand how to add another set of data later on. PHP Code:

View Replies !
Get Data Into An Array
how can i take this data and create an array? i have no idea where to
start.

"STEAM_0_1_9791900"
{
"Freq""3"
"Count""3"
"1""something"
"Namefreq""3"
"2""something else"
"3""anything"
}

View Replies !
Sql Data Into Array
Is it possible to enter figures from a mysql database into an array, which can be used on php functions? For example, I need to get figures from a database into a form such as:
Code:

$Values=array(120,190,130,155,150);

so that I can use the array in functions such as: Code:

for ($i=0; $i<count($Values); $i++){
if ($Values[$i]>$max){$max=$Values[$i];}
}

What kind of things should I be looking at?

View Replies !
Data Into Array
I'm using a pear class to build a chart, the chart gets build by an array of data.. example array :


$DS[0][0] =& Image_Graph::factory('dataset', array(array('A' => 1, 'B' => -2, 'C' => 1, 'D' => 3, 'E' => -1)));


That works great no problem, I'm not trying to populate that array from a mysql result ..

I have some mysql stuff, query etc and then ..

while ($row = mysql_fetch_array($result)) {

}

Now im stuggilin to populate the array with each row, obviously it goes in the middle of that while loop. The best way to do it?

View Replies !
Array Has Data
What I have is a select box with multiple selections turned on. If a user doesn't select anything how can I find out if the data is empty so I can stop the error caused by the foreach statement. like if(array is empty){ do this} else { foreach statement}

View Replies !
Getting Array Data Into A Variable
I've spent most of today trying to solve this problem, but sadly no
luck.
I have an shopping basket based on an array which stores the name,
product id, quantity and price for products, i want to take the
Information in the array and output the Quantity and Product ID
information into variables so that i can pass them into a Select
Statement and submit the order to the database.

The Current Code to Show the cart is listed below: -

function show_cart() {
if (isset($_SESSION["item_count"]) && $_SESSION["item_count"] > 0) {
echo "<table class="basket"border="0">";
echo
"<tr><td>Item</td><td>Price</td><td>Amount</td><td>Subtotal</td></td></tr>";

$total = 0;
for($i=0; $i<$_SESSION["item_count"]; $i++) {

echo "<td><a
href=insertselfpagehere.php?deleteitem=1&ProdID=".$_SESSION["items"][$i][0].">";

$item=$_SESSION["items"][$i][0];
echo $_SESSION["items"][$i][1]."</a></td>";
echo "<td>".$_SESSION["items"][$i][2]."</td>";
echo "<td>*".$_SESSION["items"][$i][3]."</td>";
$subtotal = $_SESSION["items"][$i][2] * $_SESSION["items"][$i][3];
echo "<td align="right">$subtotal</td>";
echo "</tr>";
$total += $subtotal;
}
echo "<tr><td><b>total</b></td><td align="right"
colspan="3">$total</td></tr></table>";
}

else {
echo "No items";
}
}

View Replies !

Copyright © 2005-08 www.BigResource.com, All rights reserved