Serialised Array Query - newbie

  • Thread starter Thread starter Anonymous
  • Start date Start date
A

Anonymous

Guest
Hi, I am a newbie to pho MySQL scripting and have been banging my head against the wall with serialised queries.

I'm trying to select the rows in a MySQL table into an array and then serialise the output.

This is so I can feed the results dynamically into a tableS

I can get the rows to return to screen, however every time I try to serialise the output I'm getting no output.

I would eternally appreciate any pointers to how to achieve this

Thanks

Steve
 
What do you mean by "serialise the output"?

And it would help if you showed your script using the [</>] button on the 'Post a reply' box
 
Apologies, i should have posted the code.

What the aim is to have thep PHP script results dynamically passed to a table plugin i using wordpress, the plugin however doesnt allow the parameterised variables to be set, however it doe support serialized php.

Code:
<?php
/* available system variables */
$current_user = wp_get_current_user();
$groveid = "$current_user->user_login";
$orgid = "$current_user->display_name";
$mysqli = mysqli_connect('****, '****', '****', '*****', 3306);

$query = "SELECT id, tagid,location,category, sublocation, allocated,description,serialno,leased,purchasedate from inventory where disposed = 'no' and orgid = '$orgid'";

if ($result = $mysqli->query($query)) {

    /* fetch associative array */
    while ($row = $result->fetch_assoc()) {
    echo $row["tagid"];
    echo $row["location"];
    echo $row["sublocation"];
	echo $row["allocated"];
	echo $row["description"];
	echo $row["serialno"];
	echo $row["leased"];
	echo $row["purchasedate"];
    }

    /* free result set */
    $result->close();
}
echo serialize($row);
/* close connection */
$mysqli->close();
?>


Thanks
Steve
 
Can't you put
Code:
serialize($row);
into your while loop?

Or just serialize the whole query?
 
Thankyou for the advice, I will test that approach, to serialise the whole query do I serialise the $result instead of the row.

I'm not totally sure which would be the best / optimal approach.
 
Back
Top