hi
i got all data in single array. How i can store the data in multidimensional array?
below my code: -
require_once('../../includes/common.php');
-
-
$m = array();
-
$result = mysql_query("SELECT * from sgc where year = '2008'") or die(mysql_error());
-
-
while($row = mysql_fetch_array($result))
-
{
-
// echo $row['nric']."<br>";
-
$res =mysql_query("select COURSE_TITLE_LONG, CRSE_GRADE_OFF, UNT_EARNED, nric from ite where nric = '".$row['nric']."' AND STRM = '2008'")or die(mysql_error());
-
$norows=mysql_num_rows($res);
-
echo $norows."<br>";
-
-
while($rows = mysql_fetch_array($res))
-
{
-
for($i=0;$i<$norows;$i++){
-
$data = array("course" => "'".$rows['COURSE_TITLE_LONG']."'" , "Grade" => "'".$rows['CRSE_GRADE_OFF']. "'" , "Unit" => "'".$rows['UNT_EARNED']."'");
-
}
-
$ser = serialize($data);
-
print $ser;
-
echo "<br>";
-
}
-
}
-
-
i got this output, kindly help to make multidimensional array -
a:3:{s:6:"course";s:24:"'Personal Effectiveness'";s:5:"Grade";s:3:"'S'";s:4:"Unit";s:3:"'3'";}
-
a:3:{s:6:"course";s:16:"'Basic Numeracy'";s:5:"Grade";s:3:"'U'";s:4:"Unit";s:3:"'2'";}
-
a:3:{s:6:"course";s:23:"'Piping & Valve System'";s:5:"Grade";s:3:"'D'";s:4:"Unit";s:3:"'6'";}
-
a:3:{s:6:"course";s:24:"'Mechanical Fabrication'";s:5:"Grade";s:3:"'F'";s:4:"Unit";s:3:"'6'";}
-
2 2355
You normally serialize the data to insert into a database but you can use the serialized data to transmit over a network.
What do want the multidimensional array structure to look like?
PHP's multidimensional arrays are easy...
$array[0][0]
...
$array[10][10]
$array[0]['name']
$array[0]['address']
$array[0]['phone']
...
$array[10]['name']
$array[10]['address']
$array[10]['phone'] -
$ser_index = 0;
-
-
while($row = mysql_fetch_array($result))
-
{
-
// echo $row['nric']."<br>";
-
$res =mysql_query("select COURSE_TITLE_LONG, CRSE_GRADE_OFF, UNT_EARNED, nric from ite where nric = '".$row['nric']."' AND STRM = '2008'")or die(mysql_error());
-
$norows=mysql_num_rows($res);
-
echo $norows."<br>";
-
-
while($rows = mysql_fetch_array($res))
-
{
-
for($i=0;$i<$norows;$i++){
-
$data = array("course" => "'".$rows['COURSE_TITLE_LONG']."'" , "Grade" => "'".$rows['CRSE_GRADE_OFF']. "'" , "Unit" => "'".$rows['UNT_EARNED']."'");
-
}
-
$ser[$ser_index++] = serialize($data);
-
}
-
}
-
print_r($ser);
-
Hi,
I retrieve data in the DB. I create a array and make it serialize. Below code was retrieve data each line in one array. but i want all lines in one array or array of array.
for ex:
array(array(course,grade,unit),array(course,grade, unit),.......)
if get in array use count()-> retrieve the data easy. -
while($rows = mysql_fetch_array($res))
-
{
-
for($i=0;$i<$norows;$i++){
-
$data = array("course" => "'".$rows['COURSE_TITLE_LONG']."'" , "Grade" => "'".$rows['CRSE_GRADE_OFF']. "'" , "Unit" => "'".$rows['UNT_EARNED']."'");
-
}
-
$ser = serialize($data);
-
print $ser;
-
echo "<br>";
-
}
-
If i store the data line by line array(course,grade,unit) in the database, can't retrieve all the data at a time. kindly help.... i am trying to solve this problem more than three days..... still can't please help... (because i am new for php) retrieve code -
require_once('../../includes/common.php');
-
$m = array();
-
-
$r = '';
-
$result = mysql_query("SELECT meta_ite from sgc where nric = 'S9405127D'") or die(mysql_error());
-
$count = mysql_numrows($result);
-
-
while($row = mysql_fetch_array($result))
-
{
-
$data = $row['meta_ite'];
-
print_r (count($data));
-
$val = unserialize($data);
-
foreach($val as $key => $va){
-
print $va;
-
}
-
-
}
-
-
output: Sign in to post your reply or Sign up for a free account.
Similar topics |
by: ubccis |
last post by:
Hi.
Does for each for on multidimensional arrays? For example, if one
element of $in is $course_list and I want to echo all everything in
course_list
|
by: Terry |
last post by:
Hi,
can someone plz tell me how multidimensional arrays (like a 2-D array)
are stored in memory? Are they like single dimensional arrays? Stored
sequentially in one "row", so to say?
Thanks
...
|
by: Charles Banas |
last post by:
i've got an interesting peice of code i'm maintaining, and i'd like to
get some opinions and comments on it, hopefully so i can gain some
sort of insight as to why this works.
at the top of the...
|
by: whisper |
last post by:
Hi: there is an issue that confuses me and the FAQ did not clarify it
for me.
(Sorry I am just learning!)
Let say I define a multidimensional array in my main routine as
follows:
int...
|
by: matthewburton |
last post by:
Hi everyone,
I'm trying to write a program that will search a body of text and
replace certain words (say, A, B, and C) with different words that I
think are more appropriate (A1, B1 and C1). I...
| |
by: utab |
last post by:
Hi there,
Is there a way to convert a double value to a string. I know that there
is fcvt() but I think this function is not a part of the standard
library. I want sth from the standard if...
|
by: barmy_mad |
last post by:
Hi
I new to C# and trying to store/extract a collection of
multidimensional arrays. For example;
string a_DATA = new string
object o_CON = new object
for(int i=0;i<10;i++){
for(int...
|
by: asdf |
last post by:
I was told not to use the low-level language such as arrays which
inherited from C, I want to know what can I use to substitute the
C-style multidimensional arrays? Is there multidimensional vector?
|
by: oopsatwork |
last post by:
Ok...so, I have been outside of the C world for a _very_ long
time...but not so long as to remember how to do multidimensional
arrays. So, let me state that I know how to malloc pointers to...
|
by: filippo nanni |
last post by:
Hello everybody, my question is this:
I have two multidimensional arrays and I have to create a third one (for later use) from comparing these two. Here is my example code:
//BEGIN CODE
var...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |