Dysan Posted November 16, 2007 Share Posted November 16, 2007 How do I insert data into an array, from a form? Link to comment https://forums.phpfreaks.com/topic/77639-array/ Share on other sites More sharing options...
Barand Posted November 16, 2007 Share Posted November 16, 2007 Data from a form is already in $_GET or $_POST array depending on form method. Link to comment https://forums.phpfreaks.com/topic/77639-array/#findComment-392996 Share on other sites More sharing options...
Dysan Posted November 16, 2007 Author Share Posted November 16, 2007 Can you give me an example of how to insert data from a database, into an array? Link to comment https://forums.phpfreaks.com/topic/77639-array/#findComment-393002 Share on other sites More sharing options...
pocobueno1388 Posted November 16, 2007 Share Posted November 16, 2007 It's in an array when you call it from the database. <?php $query = mysql_query("SELECT * FROM table"); //Make $row an array of DB values $row = mysql_fetch_assoc($query); //Now you can echo values out from the array echo $row['val']; ?> Link to comment https://forums.phpfreaks.com/topic/77639-array/#findComment-393006 Share on other sites More sharing options...
Wes1890 Posted November 16, 2007 Share Posted November 16, 2007 example: $sql = mysql_query("SELECT * FROM data WHERE id=1"); $row = mysql_fetch_array($sql); now you can do $row['column_1'], $row['column_2'] etc depending on how many columns you have Link to comment https://forums.phpfreaks.com/topic/77639-array/#findComment-393007 Share on other sites More sharing options...
Dysan Posted November 16, 2007 Author Share Posted November 16, 2007 how do Shopping Karts work, how do they remember whats in your shopping Kart? How do I create a PHP Shopping Kart? Link to comment https://forums.phpfreaks.com/topic/77639-array/#findComment-393040 Share on other sites More sharing options...
pocobueno1388 Posted November 16, 2007 Share Posted November 16, 2007 You need to use sessions to create a shopping cart. If you have all these questions, your obviously not ready to take on programming your own shopping cart. I suggest reading tutorials to learn the basics of PHP. Link to comment https://forums.phpfreaks.com/topic/77639-array/#findComment-393044 Share on other sites More sharing options...
Dysan Posted November 16, 2007 Author Share Posted November 16, 2007 What just sessions? So I don't need to use an array? Can sessions hold multiple values? - e.g. The contents of a shopping cart (Product, Cost etc) Link to comment https://forums.phpfreaks.com/topic/77639-array/#findComment-393053 Share on other sites More sharing options...
pocobueno1388 Posted November 16, 2007 Share Posted November 16, 2007 Yes, a session can be an array. Link to comment https://forums.phpfreaks.com/topic/77639-array/#findComment-393055 Share on other sites More sharing options...
Dysan Posted November 16, 2007 Author Share Posted November 16, 2007 How do I do that? store an array as a session? Can you give me an example of storing values from a form inside an array? Link to comment https://forums.phpfreaks.com/topic/77639-array/#findComment-393058 Share on other sites More sharing options...
Wes1890 Posted November 16, 2007 Share Posted November 16, 2007 ^ well, i would try to help you, but it would only lead to more endless questions.. use Google and search for your questions first.. google is truely amazing Link to comment https://forums.phpfreaks.com/topic/77639-array/#findComment-393059 Share on other sites More sharing options...
Dysan Posted November 16, 2007 Author Share Posted November 16, 2007 Try me! I know a fair bit about sessions, and a little bit about arrays. I just need to see an exmplae, in order to make it self explanatory. Link to comment https://forums.phpfreaks.com/topic/77639-array/#findComment-393062 Share on other sites More sharing options...
revraz Posted November 16, 2007 Share Posted November 16, 2007 Buy a PHP/MySQL book. Link to comment https://forums.phpfreaks.com/topic/77639-array/#findComment-393064 Share on other sites More sharing options...
pocobueno1388 Posted November 16, 2007 Share Posted November 16, 2007 Take a look at these for an example http://www.php-shopping-cart-tutorial.com/shopping-cart.htm http://www.thewatchmakerproject.com/journal/276/building-a-simple-php-shopping-cart Link to comment https://forums.phpfreaks.com/topic/77639-array/#findComment-393065 Share on other sites More sharing options...
Dysan Posted November 16, 2007 Author Share Posted November 16, 2007 So how do I insert data into an array via a form? Link to comment https://forums.phpfreaks.com/topic/77639-array/#findComment-393084 Share on other sites More sharing options...
pocobueno1388 Posted November 16, 2007 Share Posted November 16, 2007 <?php $arr = array(); if (isset($_POST['submit'])){ $arr[] = $_POST['var']; print_r($arr); } ?> <p> <form method="post"> <input type="text" name="var"> <input type="submit" name="submit"> </form> Link to comment https://forums.phpfreaks.com/topic/77639-array/#findComment-393110 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.