PHP - Extracting Database Data As An Array For Use In Php Class For Threaded Comments
I need to set up a threaded comments system in a PHP project and I got this script shown below from http://www.jongales....#comment-436261
class Threaded_comments { public $parents = array(); public $children = array(); /** * @param array $comments */ function __construct($comments) { foreach ($comments as $comment) { if ($comment['parent_id'] === NULL) { $this->parents[$comment['id']][] = $comment; } else { $this->children[$comment['parent_id']][] = $comment; } } } /** * @param array $comment * @param int $depth */ private function format_comment($comment, $depth) { for ($depth; $depth > 0; $depth--) { echo "\t"; } echo $comment['text']; echo "\n"; } /** * @param array $comment * @param int $depth */ private function print_parent($comment, $depth = 0) { foreach ($comment as $c) { $this->format_comment($c, $depth); if (isset($this->children[$c['id']])) { $this->print_parent($this->children[$c['id']], $depth + 1); } } } public function print_comments() { foreach ($this->parents as $c) { $this->print_parent($c); } } }Here’s the example usage with the data provided as an array: $comments = array( array('id'=>1, 'parent_id'=>NULL, 'text'=>'Parent'), array('id'=>2, 'parent_id'=>1, 'text'=>'Child'), array('id'=>3, 'parent_id'=>2, 'text'=>'Child Third level'), array('id'=>4, 'parent_id'=>NULL, 'text'=>'Second Parent'), array('id'=>5, 'parent_id'=>4, 'text'=>'Second Child') ); $threaded_comments = new Threaded_comments($comments); $threaded_comments->print_comments();I have a sample select query that pulls data from a database and stores the result in the $comments array as shown below. The $comments array is then passed as an argument to the $threaded_comments object: $sql = 'SELECT * FROM test_comments'; // submit the query and capture the result $result = $conn->query($sql); $comments = array(); while ($row = $result->fetch_assoc()) { $comments[] = $row; }The challenge is that nothing is printed to the screen when I run the script. Inspection of the comments array with the var_dump function is shown below: array (size=4) 0 => array (size=3) 'id' => string '1' (length=1) 'parent_id' => string '0' (length=1) 'text' => string 'comment' (length=7) 1 => array (size=3) 'id' => string '2' (length=1) 'parent_id' => string '0' (length=1) 'text' => string 'comment' (length=7) 2 => array (size=3) 'id' => string '3' (length=1) 'parent_id' => string '1' (length=1) 'text' => string 'comment ' (length=8) 3 => array (size=3) 'id' => string '4' (length=1) 'parent_id' => string '3' (length=1) 'text' => string 'comment ' (length=8)I was wondering if the array format from my select query is the issue? Could anyone provide a clue as to how to fix this? Thanks. Edited by terungwa, 11 January 2015 - 05:07 PM. Similar TutorialsHi guys, This is my problem: I have a csv file let's say have these values: blue,1,2,3,4 red,8,5,6,7 I need to add thes values into a 2d array to be able to use like this: colors[1][2]=2 colors[2][4]=7 Where my first number is the row and the second number is the value within that row. This is what I got so far <?PHP $i=0; $j=0; $file_handle = fopen("color-list.csv", "r"); while (!feof($file_handle) ) { $colors = fgetcsv($file_handle, 10000); for ($j=0; $j<=4; $j++) { $row[$i][$j]=$colors[$j]; print row[$i][$j]; } $i++; ?> For some reason this doesn't work. Maybe I am declaring the arrays wrong. Thank you! Hi - I have an array where one of the values delivers a string. Here is the output from a print_r($pickupdates): Code: [Select] Array ( [0] => Array ( [location] => Clearwater [TheDates] => 1311746700,1321746641,1331668779 ) [1] => Array ( [location] => Canmore [TheDates] => 1311746700,1321746641,1331746641 ) [2] => Array ( [location] => Collingwood [TheDates] => 1311746700,1321746641,1331746641 ) [3] => Array ( [location] => Varsity [TheDates] => 1321746641,1330746700,1331746700 ) The challenge is to get the location and TheDates into a nice HTML table which would look like this: Code: [Select] LOCATION DATE 1 DATE 2 DATE 3 Clearwater April 1 May 1 June 1 Varsity April 2 May 2 June 2 Collingwood April 3 May 3 June 3 Canmore April 4 May 4 June 4 Ok - Now I am stuck, I need to be able to uniquely identify each date that is associated with the location such that I can run a foreach() on then so I can populate the table properly. I tried using list() and explode. List does not separate the dates and explode needs a string not an array. I'm really stuck - a very big Heartfelt thanks to anyone who can steer me in the right direction. MANY THANKS ! Hey all, I wrote a crawler and have already written the string to extract links. i get a multidimensional array. this is #13 for example Array[0][13] => <a class="menuitem" href="/home-news.html" title="Home / News">Home / News</a> Array[1][13] => /home-news.html ok so far so good. Now I want to extract the name Home / News and write that into a database and the link as well. can i use the preg_match_all() to search an array? or how can i extract it? Thanks so much! monkover Hi all, I hope someone can help me out here as I think I am close but am not sure where to go from here. The problem is: I have a cms where a user can see a list of photos in the gallery. I provide them the ability to select what photos they want to appear on a particular webpage. The problem I have is that the user wants to be able to put the photos in whatever order they choose. So, I have a form (see attached), the html code is: <table width="566px" cellspacing="0" border="0"> <tr> <td width="33%"> <div class="serviceCell"> <input type='checkbox' checked='checked' name='photos[][0]' value='119' /> Bathroom Sin... <img src="./images/help.gif" title="Enter an integer to signify the order in which this image will appear on the webpage." alt="Enter an integer to signify the order in which this image will appear on the webpage."/> <input type="text" size="2" name="photos[][1]" value="0"/> </div> </td> <td width="33%"> <div class="serviceCell"> <input type='checkbox' checked='checked' name='photos[][0]' value='113' /> Courtyard 1 <img src="./images/help.gif" title="Enter an integer to signify the order in which this image will appear on the webpage." alt="Enter an integer to signify the order in which this image will appear on the webpage."/> <input type="text" size="2" name="photos[][1]" value="0"/> </div> </td> <td width="33%"> <div class="serviceCell"> <input type='checkbox' name='photos[][0]' value='114' /> Courtyard 2 <img src="./images/help.gif" title="Enter an integer to signify the order in which this image will appear on the webpage." alt="Enter an integer to signify the order in which this image will appear on the webpage."/> <input type="text" size="2" name="photos[][1]" value=""/> </div> </td> </tr>... Now, lets assume that the user ticked the box next to 'Courtyard 2' and entered an integer '1' in the input box to signify that this image should be displayed 1st on the chosen webpage. These 2 values go into the multidimensional array (photoid, ranking) and are submitted in the form to php in the photos[][] array. But here is where I have the problem. I am trying to extract the values from the array and then do an insert to a table in mysql. My syntax must be wrong somewhere so I am asking anyone to please offer any advice: if (isset($_REQUEST['submitted'])){ $photos = $_REQUEST['photos']; ... if(!empty($photos)){ foreach($photos as $photoID){ $sql = "INSERT IGNORE INTO menuItemPhotos SET photoid='$photoID[0]', menuItemid='$id', ranking='$photoID[1]'"; $ok = @mysql_query($sql); // execute the query } // End of foreach($photos as $photoID){ } // End of if(!empty($photos)){ Thanks Conor [attachment deleted by admin] Hey guys, So im building a Content Management System for my A2 project in Computing, and i have a dataBase class. Now, i can return one thing, or do things like inserts however im having a problem returning a list of things such as: dataBase.class.php Code: [Select] public static function getNYCPost($table, $limit) { dataBase::_dbConnect(); if($limit == 0) { //debug: echo 'in as 0'; $data = mysql_query("SELECT id, linklabel FROM ".$table." WHERE showing='1' AND id >= 2"); } if($limit == 1) { //debug: echo 'in'; $data = mysql_query("SELECT id, linklabel FROM ". $table ." WHERE showing='1' AND id >= 2 ORDER BY id DESC LIMIT 5"); return $data; } } When i try to do this in the main code: index.php Code: [Select] <?php $list = dataBase::getNYCPost($pages,1); // echo $list; while ($row = mysql_fetch_array($list)) { $pageId = $row["id"]; $linklabel = $row["linklabel"]; $menuDisplay .= '<a href="index.php?pid=' . $pid . '">' . $linklabel . '</a><br />'; } echo $menuDisplay; ?> $list doesnt return anything, the previous method i used in the class was to make a list and an array and put the contents of the query in an array like: Code: [Select] list($list[] = $row); or something i cant quite remember i saw a youtube video tutorial and it worked for them, but it wasnt for me. If anyone knows how i can return various rows from a database it would be appreciated Thanks. Folks, I need to Extract the Content of "[content] => " Class from the output of the below Script: <?php $keywords = file_get_contents('http://ajax.googleapis.com/ajax/services/search/web?rsz=large&v=1.0&q="paintball"'); $keywords = json_decode($keywords); print_r($keywords); ?> Output is like: Quote stdClass Object ( [responseData] => stdClass Object ( [results] => Array ( => stdClass Object ( [GsearchResultClass] => GwebSearch [unescapedUrl] => http://www.paintball.com/ [url] => http://www.paintball.com/ [visibleUrl] => www.paintball.com [cacheUrl] => http://www.google.com/search?q=cache:Zcnr-K8jU4YJ:www.paintball.com [title] => PaintBall.com [titleNoFormatting] => PaintBall.com [content] => Information and meeting place for new and experienced players. Features industry news, equipment reviews, information for new players, links to online ... ) [1] => stdClass Object ( [GsearchResultClass] => GwebSearch [unescapedUrl] => http://www.zephyrpaintball.com/ [url] => http://www.zephyrpaintball.com/ [visibleUrl] => www.zephyrpaintball.com [cacheUrl] => http://www.google.com/search?q=cache:EkBfV3VsT9UJ:www.zephyrpaintball.com [title] => Cheap Paintball Guns - Cheap Paintball Gear - Cheap Paintball Supplies [titleNoFormatting] => Cheap Paintball Guns - Cheap Paintball Gear - Cheap Paintball Supplies [content] => Cheap Paintball Gear - Zephyr Paintball offers a wide variety of cheap paintball guns as well as cheap paintball supplies that can get you into the painball ... ) [2] => stdClass Object ( [GsearchResultClass] => GwebSearch [unescapedUrl] => http://www.addictinggames.com/paintballthegame.html [url] => http://www.addictinggames.com/paintballthegame.html [visibleUrl] => www.addictinggames.com [cacheUrl] => http://www.google.com/search?q=cache:TM1GFy3lDIQJ:www.addictinggames.com [title] => Paintball - The Game - Free Puzzle and Board Game from AddictingGames! [titleNoFormatting] => Paintball - The Game - Free Puzzle and Board Game from AddictingGames! [content] => Paintball - The Game, a Free Puzzle and Board Game from AddictingGames: Use your skills to paint a path for the ball to get to the magical square. ) [3] => stdClass Object ( [GsearchResultClass] => GwebSearch [unescapedUrl] => http://www.paintball-online.com/ [url] => http://www.paintball-online.com/ [visibleUrl] => www.paintball-online.com [cacheUrl] => http://www.google.com/search?q=cache:rm9AvRxLLX4J:www.paintball-online.com [title] => Paintball Guns & Markers at Paintball-Online.com [titleNoFormatting] => Paintball Guns & Markers at Paintball-Online.com [content] => The Internet's largest paintball store featuring over 4000 paintball guns, markers and other gear. Free shipping and 10% off for all VIP members. ) [4] => stdClass Object ( [GsearchResultClass] => GwebSearch [unescapedUrl] => http://en.wikipedia.org/wiki/Paintball [url] => http://en.wikipedia.org/wiki/Paintball [visibleUrl] => en.wikipedia.org [cacheUrl] => http://www.google.com/search?q=cache:h3rpb57aWfcJ:en.wikipedia.org [title] => Paintball - Wikipedia, the free encyclopedia [titleNoFormatting] => Paintball - Wikipedia, the free encyclopedia [content] => Paintball is a sport in which players compete, in teams or individually, to eliminate opponents by hitting them with capsules containing food coloring and ... ) [5] => stdClass Object ( [GsearchResultClass] => GwebSearch [unescapedUrl] => http://www.ansgear.com/ [url] => http://www.ansgear.com/ [visibleUrl] => www.ansgear.com [cacheUrl] => http://www.google.com/search?q=cache:uiYno-g6MOkJ:www.ansgear.com [title] => Paintball - Cheap Paintball Guns, Gear and Paintball Equipment [titleNoFormatting] => Paintball - Cheap Paintball Guns, Gear and Paintball Equipment [content] => Ansgear has Paintball guns and Paintball equipment for everyone. Get your Paintball equipment for cheap. All Paintball gear on sale! ) [6] => stdClass Object ( [GsearchResultClass] => GwebSearch [unescapedUrl] => http://www.pbreview.com/ [url] => http://www.pbreview.com/ [visibleUrl] => www.pbreview.com [cacheUrl] => http://www.google.com/search?q=cache:OzXP0G1QzFMJ:www.pbreview.com [title] => Paintball Reviews of Guns, Equipment, Games & More | pbreview.com [titleNoFormatting] => Paintball Reviews of Guns, Equipment, Games & More | pbreview.com [content] => All things paintball on pbreview.com. Paintball gun & equipment reviews, paintball videos, a paintball field locator for paintball games & tournaments. ) [7] => stdClass Object ( [GsearchResultClass] => GwebSearch [unescapedUrl] => Desired Output: Quote [content] => Cheap Paintball Gear - Zephyr Paintball offers a wide variety of cheap paintball guns as well as cheap paintball supplies that can get you into the painball ... [content] => Paintball - The Game, a Free Puzzle and Board Game from AddictingGames: Use your skills to paint a path for the ball to get to the magical square. ) .......................... Till the End of the Page... How can it be achieved? Cheers Natasha T I am setting up a PHP & MySql shopping cart. When a user adds products they are stored as sessions. The cart displays the products in an array: foreach($_SESSION as $product => $quantity) So the product is the product_id, and the quantity is the quantity of that product which has been added. When getting the information from the database to display it, it reads like this 1-----2 (product_id = 1, quantity = 2) 2-----1 (product_id = 2, quantity = 1) 3-----3 (product_id = 3, quantity = 3) 11---12 (product_id = 11, quantity = 12) 4-----1 (product_id = 4, quantity = 1) I'm basically trying to insert the product_id and quantity into a table called cart. I've been stuck for days and can still only manage to insert 1 row of values Searching around I saw that some people inserted arrays using implode or explode functions first, but I'm not sure how that would work in this case Any ideas? Hi, I'm trying to save data from an array to database but something is wrong. This is from i send data, as you see im using arrays [] because the user have the posibility to clone the row <div class="box-body"> <div class="form-group"> <label class="col-sm-2">Student</label> <div class="col-sm-10"> <table id="table" border="1" bordercolor="#00acc1"> <thead> <tr> <th><p>Name</p></th> <th><p>Mode</p></th> <th><p>Sport</p></th> <th> </th> </tr> </thead> <tbody> <tr> <td><select style="width:325px" name="Name[]" class="form-control"> <option value="">Select</option> <?php $search = "SELECT * FROM prof"; $data = $connect->prepare($search); $data->execute(); while($re=$data -> fetch(PDO::FETCH_ASSOC)){ echo "<option value = '".$re['id']."'>"; echo $re['n_prof'].' '.$re['ap_prof'];} ?> </select> </td> <td> <select class="form-control" name="mode[]" style="width:150px" /> <option value="">Select</option> <option value="Administrator">Administrator</option> <option value="Scholar">Scholar</option> <option value="External student">External student</option> <option value="Thesis">Thesis</option> <option value="Voluntary">Voluntary</option> </select> </td> <td> <select class="form-control" name="Sport[]" style="width:150px" /> <option value="">Select</option> <option value="Football">Football</option> <option value="Baseball">Baseball</option> <option value="Swimming">Swimming</option> <option value="Horse riding">Horse riding</option> <option value="basketball">basketball</option> </select> </td> <td class="Delete">Delete</td> </tr> </tbody> </table> <input type="button" id="add" value="+ add student" class="btn btn-primary"/> </div> </div> </div> my db.table is like this id | name | mode | sport | idstudent_fk And Im using an algorithm to read the array and every time can save every row, but im usind PDO and im having problems try{ here i insert data in a table here i got the last id from that table then ... if($_POST['name']!="" and $_POST['mode']!="" and $_POST['sport']!=""){ if(is_array($_POST['name'])){ while(list($key, $name) = each($_POST['name']) and list($val,$mode) = each($_POST['mode']) and list($id, $sport) = each($_POST['sport'])){ $sql = "INSERT INTO sports(id_studentfk, mode_stu, sport, id_projfk) values(:value, :mode, :sport, :lastid)"; $statement = $connect ->prepare($sql); $statement -> bindParam(':name', $name, PDO::PARAM_INT); $statement -> bindParam(':mode', $mode, PDO::PARAM_STR); $statement -> bindParam(':sport', $sport, PDO::PARAM_STR); $statement -> bindParam(':lastid', $lastid, PDO::PARAM_INT); $pdoExec = $statement -> execute(); } }//end if array }//end if post } catch (PDOException $e) { print 'ERROR: '. $e->getMessage(); print '<br/>Data Not Inserted'; } the idea is creating a loop to read the array and every time can insert data. Im using PDO this time is not working, im geeting this error
ERROR: SQLSTATE[HY093]: Invalid parameter number: parameter was not defined I hope someone can help me to solve this
Hi pals, I got a complex Array from the Query. it's Structure is like Quote Array ( => Array ( [server_name] => anes.admod.net [id] => 1 [server_id] => 1 [description] => nice Anes Server [status] => 0 [max_down_count] => 9 [check_interval] => 15 [fail_recheck] => 6 [log_retain] => 1 [warning] => 12 [critical] => 15 [timeout] => 8 [audible] => Y [email] => Y [im] => Y [sms] => Y [rss] => N [rssid] => [vcare] => Y [created] => 2010-12-06 10:26:26 [last_update] => 2010-12-13 16:41:48 [name] => POP3 [port] => 110 [okay] => OK [warn] => WARNING [crit] => CRITICAL [down] => Connection refused [advanced] => N [typestatus] => 1 ) [1] => Array ( [server_name] => neseema.admod.net [id] => 2 [server_id] => 2 [description] => another server [status] => 1 [max_down_count] => 11 [check_interval] => 15 [fail_recheck] => 12 [log_retain] => 2 [warning] => 12 [critical] => 16 [timeout] => 6 [audible] => Y [email] => Y [im] => Y [sms] => N [rss] => N [rssid] => [vcare] => N [created] => 2010-12-07 10:27:42 [last_update] => 2010-12-13 16:41:48 [name] => Cpanel [port] => 2082 [okay] => OK [warn] => WARNING [crit] => CRITICAL [down] => Connection refused [advanced] => N [typestatus] => 1 ) [2] => Array ( [server_name] => anes.admod.net [id] => 3 [server_id] => 1 [description] => nice Anes Server another Service [status] => 1 [max_down_count] => 14 [check_interval] => 15 [fail_recheck] => 3 [log_retain] => 3 [warning] => 12 [critical] => 16 [timeout] => 18 [audible] => Y [email] => [im] => [sms] => [rss] => N [rssid] => [vcare] => N [created] => 2010-12-07 12:58:01 [last_update] => 2010-12-13 16:41:48 [name] => SMTP [port] => 25 [okay] => OK [warn] => WARNING [crit] => CRITICAL [down] => Connection refused [advanced] => N [typestatus] => 1 ) ) In this Result I have 2 Rows in result to show, I mean I need to merge the data of First (0th) and Third(2nd) element because it display the data of same item. So How it can done, I am working in that whole day but not get a solution fully.... I saw a near solution like : <?php $input = array( 0 => array ( 'id' => 160, 'payment_period' => 'Monthly', 'plan_payment_type_id' => 171, 'payment_type_id' => 4), 1 => Array ( 'id' => 160, 'payment_period' => 'Monthly', 'plan_payment_type_id' => 172, 'payment_type_id' => 5), 2 => Array ( 'id' => 161, 'payment_period' => 'Weekly', 'plan_payment_type_id' => 173, 'payment_type_id' => 9), ); echo "<pre>"; print_r($input); echo "</pre>"; echo "****************************************************************************"; $output = array(); $id_array = array(); $i = 0; foreach($input as $key=>$val) { if(array_key_exists($val['id'],$id_array)) { $pos = $id_array[$val['id']]; $output[$pos]['payment_types'][] = array('plan_payment_type_id'=> $val['plan_payment_type_id'],'payment_type_id' => $val['payment_type_id']); } else { $output[$i] = array('id' => $val['id'],'payment_period' => $val['payment_period'],'payment_types' => array(array('plan_payment_type_id'=> $val['plan_payment_type_id'],'payment_type_id' => $val['payment_type_id']))); $id_array[$val['id']] = $i; $i++; } } echo "<pre>"; print_r($output); echo "</pre>"; ?> But I cannot handle it nicely, please give any sample or helping code idea for same , waiting your immediate Reply Thankfully Anes P.A Hello =) I'm trying to create a javascript array which should be filled with data from a mysql database. so what i wannt to do is to loop out a new array element for each row in my database. I should also say that i'm working in a php file. I tried (and failed) to do it like this: Code: [Select] <?php include('databbaseconnect.php'); ?> <script type="text/javascript"> var StoreDetails = [ ['Please select an option','','','','',''], <?php mysql_select_db("alltomboule_se", $db); $result = mysql_query("SELECT * FROM spelare"); while($row = mysql_fetch_array($result)) { echo "['".$row['namn'].$row['enamn']."','".$row['namn'].",'".$row['enamn']."','".$row['klubb']."','".$row['licensnr']."','".$row['id']."'],"; } ?> ['','','','','',''] // Note: no comma for last row ]; I wannt the array to look like this: Code: [Select] var StoreDetails = [ ['Please select an option','','','','',''], ['Oscar Andersson','Oscar','Andersson','BON','16643','2'], ['Olle Johansson','Olle','Johansson','BFT','14443','3'], ['Ingvar Andersson','Ingvar','Andersson','BON','14333','4'], ['Kalle Kula','Kalle','Kula','BON','34576','5'], ['','','','','',''] ]; I am trying to array data to database against same id.
Here is code.
form.php
<form name="users" method="post" action="order_submit.php" enctype="multipart/form-data" onSubmit="return validate();" id="inv_form"> <div class="formSep"> <select name="company" onChange="showSubcat(this);"> <option value="">Company</option> <?php $s1 = mysql_query("select * from leads where lead_customer='Lead' ") or die (mysql_error()); while($s2 = mysql_fetch_array($s1)) { ?> <option value="<?php echo $s2['id']; ?>"><?php echo $s2['company']; ?></option> <?php } ?> </select> </div> <div class="formSep"> <table class="table invE_table"> <thead> <tr> <th></th> <th>Item</th> <th>Unit</th> <th>Unit Cost ($)</th> <th>Qty</th> <th>Tax (%)</th> <th>Total ($)</th> </tr> </thead> <tbody> <tr class="inv_row"> <td class="inv_clone_row"><i class="icon-plus inv_clone_btn"></i></td> <td><input type="text" class="span12" name="invE_item[]" /></td> <td><input type="text" class="span12" name="invE_description[]" /></td> <td><input type="text" class="span12 jQinv_item_unit" name="invE_unit_cost[]" /></td> <td><input type="text" class="span12 jQinv_item_qty" name="invE_qty[]" /></td> <td><input type="text" class="span12 jQinv_item_tax" name="invE_tax[]" /></td> <td><input type="text" readonly class="span12 jQinv_item_total" name="invE_total[]" /></td> </tr> <tr class="last_row"> <td colspan="5"> </td> <td colspan="2"> <p class="clearfix">Subtotal: <span class="invE_subtotal">$<span>0.00</span></span></p> <p>Tax: <span class="invE_tax">$<span>0.00</span></span></p> <p>Discount: <span class="invE_discount">$<span>0.00</span></span></p> <p><strong>Balance: <span class="invE_balance">$<span>0.00</span></span></strong></p> </td> </tr> </tbody> </table> </div>Here invE_item[], invE_description[], invE_unit_cost[].... are the array , i mean dynamically one can add as many as items and its details. In my order_submit.php page <?php error_reporting(0); include("connect.php"); include("admin_auth.php"); if(isset($_POST['save'])) { $company = $_POST['company']; $contact_person = $_POST['contact_person']; $billing = $_POST['billing_address']; $shipping = $_POST['shipping_address']; $reference = $_POST['reference']; $t_c = $_POST['t_c']; $payment = $_POST['payment']; $ship_in = $_POST['ship_inst']; $validity = $_POST['validity']; $currency = $_POST['currency']; $order_for = $_POST['order_for']; $assigned_to = $_POST['assigned_to']; $item = $_POST['invE_item']; $unit = $_POST['invE_description']; $price = $_POST['invE_unit_cost']; $qty= $_POST['invE_qty']; $tax = $_POST['invE_tax']; $total = $_POST['invE_total']; $sql = mysql_query("insert into orders (order_id, company_id, contact_person, billing_address, shipping_address, reference, t_c, payment, shipping_inst, validity, order_for, currency, assigned_to, last_modified, order_quote) values ('', ".$company.", '".$contact_person."', '".$billing."', '".$shipping."', '".$reference."', '".$t_c."', '".$payment."', '".$ship_in."', ".$validity.", '".$order_for."', '".$currency."', '".$assigned_to."', NOW(), 'Order')"); $last_id = mysql_insert_id(); $msql = "insert into order_line_items (id, order_id, company_id, item, unit, unit_cost, quantity, tax, total) values ('', ".$last_id.", ".$company.", '".$item."', '".$unit."', ".$price.", ".$qty.", ".$tax.", ".$total.")"; $l1 = mysql_query($msql) or die (mysql_error()); }I want to insert each item in different row with $last_id , as in the attached image . Please somebody help me in this Attached Files db.PNG 11.01KB 4 downloads I usually only do design work, but a client wanted a log in system to his website, so I decided to do it. I set everything up correctly, and users can sign up, login, and log out. However, he wants to be informed when a user logs into his site. So say (user x) wants logs in, my client wants to receive an email with all of (user x)'s account information. How do I pull a row from mysql based on the login information provided? My database is has 7 columns: user, pass, name, address, state, phone, email $example "Q: Example? A:" Let's assume that I'd like to display $example but exclude "Q:" and "A:", how would I do that? I'm *attempting* to write a script that will take a paste of data from a user and when it's submitted it will drop certain parts of the data into databases and be available for recall later. I have the MySQL sorta out I think but I can't test until I get this part done. Basically people will paste a copied paste (CTRL A, CTRL C and go to my form and just hit CTRL V). It will contain a bunch of data I want to drop in the database but in different areas, like the following example the items in bold are the items I want to grab. First Name: Lincoln Last Name: Coe Address: 1234 Easy St, Perfectville, PV 00000 Telephone: 0000000000 I have an RSS feed, with alot of data of lottery numbers. the feed itself is : http://www.alllotto.com/rss/NY/latest.rss The item i am interested in is: Quote <item> <title>Take 5</title> <description>2011-08-27: 4, 10, 16, 17, 31</description> <guid isPermaLink="false">USA-New-York-Take-5-2011-08-27</guid> </item> How could I output those to varibles? thanks Joe Hi there I need to extract data from some XML. I have found a few sites that explain that part to me, however there is a section of the data which I need to extract and am not sure how to go about it. Below is an extract of the XML, the section I am trying to extract is highlighted in red (it is essentially a text message being sent I am trying to get the contents of the sms/text message): <usa_smpp_host>THTTP</usa_smpp_host> <short_message>id:660352946 sub:001 dlvrd:001 submit date:1102081032 done date:1102081035 stat:DELIVRD err:000 text:Test SMS message</short_message> <dest_addr_npi>1</dest_addr_npi> Any assistance would be appreciated. Have played around quite a bit but have not managed to figure it out yet. thanks I have designed a database for my institute. Here I have attached my design for better understanding.
I am expecting your reviews who are professional for the database design.
Thank You.
Attached Files
Database Design for Institute Registration.jpg 61.29KB
0 downloads so I'm working on this system which requires me to inject anime show names into a DB for an index. I get them in this form: [Kira-Fansub]_HIGHSCHOOL_OF_THE_DEAD_-_04_(BD_1920x1080_x264_AAC) [F0E73009].mkv I need to get it in this form: Highschool Of The Dead sometimes the words are space seperated. the main part is to extract the text in between the ] and ( and with that i mean [stuff]extract this(other stuff) and sometimes it looks like this: [stuff]extract[stuff] I have NO CLUE how to do this preg_match_all doesn't get me any further.. maybe in stages? I have 2 sites. 1 site is a store the other is a blog. The homepage of the store shows random product images. Each image links to it's product page. I'm using the code below to get data from the store homepage into a variable: Code: [Select] <?php $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "http://www.somesite.com"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $output = curl_exec($ch); curl_close($ch); ?> I can echo $output and see the page displayed on my page. So that part is working. On the blog, I want to display random products and link them back to the store. How can I extract just the images & their page links from the $output variable? Hello all, I have a problem I'm not sure how to tackle. I have data in a database that looks looks like this: Field1 | Field2 AA | AA Row 1 Data AA | AA Row 2 Data AA | AA Row 3 Data AB | AB Row 4 Data AB | AB Row 5 Data AB | AB Row 6 Data AC | AB Row 7 Data AC | AB Row 8 Data AC | AB Row 9 Data AC | AB Row 10 Data I would like to grab and output JUST the first AA, AB, AC and the the row data in field two? So the loop would catch the first AA then when field1 data has changed it will output the first AB and so on... So the output would look like: Row1: AA : AA Row 1 Data Row2: AB : AA Row 4 Data Row3: AC : AA Row 7 Data Is there a way to accomplish this? Any help would be great! Thanks! |