Can any one help
I am trying to add the rows from a database into an array.
My problem is i can only seem to add one row at a time, i am
trying to add more that one row in a empty array.
If any one can help.
Here is the code i have written:
<?PHP
@ $conn = mysql_pconnect "$localhost","$database","$password");
if (!$conn)
{
echo"Error: Could not connect to database. Please try again later.";
exit;
}
session_start();
session_register("add");
if (IsSet($add)){
}
$action=$add;{
}
if (IsSet($del)){
}
$action=$del;{
}
if (IsSet($id)){
}
$action=$id;{
}
if (IsSet($view)){
}
$action=$view;{
}
$items =array();
mysql_select_db("$db", $conn) or die ("view_cart()");
$id = "SELECT * FROM test WHERE ID=$id";
$query = mysql_query($id) or die ("<a href=index.php>View Cart");
$result = implode (":", mysql_fetch_row($query));
$cart= explode(":",$result);
$count = count($cart);
$add= array_push($items,$cart);
for($n=1; $n<=count($items)😉{
while($book = array_shift($items)){
print ("Item $n: $book[0] $book[1]<br />\n");
$n++;
}}
?>