PHP - Hierarchy Breakdown From Html List?
Im new to PHP and have had success with much help from the community and am greatly thankful for all input.
I have a pretty good understanding of what needs to be done, but actually implementing and accomplishing is difficult for me. Im trying to break down hierarchy from an existing HTML list. First Id like to point out that I am working with an HTML file that I must use, and cannot change, as the source. I am rewriting onto another file, removing HTML, and so forth. I have already accomplished this. But what I would really like to keep the hierarchy structure by breaking it down first, so I can also use that later. Example HTML list Code: [Select] <ul><li>modem, UP</li> <ul><li>wifiRouter, UP</li> <ul><li>PC1, DOWN</li> <ul></ul> <!-- Open-close of UL identifies end --> </ul> <!-- Up one level --> <ul><li>wiredRouter, UP</li> <ul><li>server, UP</li> <ul><li>dnsServer, UP</li> <ul></ul> <!-- Open-close of UL identifies end --> <ul><li>webServer, UP</li> <ul></ul> <!-- Open-close of UL identifies end --> </ul> <!-- Up one level --> <ul><li>PC2, UP</li> <ul></ul> <!-- Open-close of UL identifies end --> </ul> <!-- Up one level --> </ul> <!-- Up one level --> <ul><li>modemBackup, DOWN</li> <ul></ul> <!-- Open-close of UL identifies end --> </ul> Desired Output: Code: [Select] 1, 0, 0, 0, modem, UP 1, 1, 0, 0, wifiRouter, UP 1, 1, 1, 0, PC1, DOWN 1, 2, 0, 0, wiredModem, UP 1, 2, 1, 0, server, UP 1, 2, 1, 1, dnsServer, UP 1, 2, 1, 2, webServer, UP 1, 2, 2, 0, PC2, UP 2, 0, 0, 0, modemBackup, DOWN If im logically looking at this right (1) Count <ul> entry and continue counting for each group (2) Stop group count at end argument <ul></ul> (3) The immediate next end argument </ul>, following (2), says to continue counting the previous group +1 (4) Repeat steps 1-3 until end Any advise? Similar TutorialsHello, I'm not able to figure how to fix these warnings / errors I'm getting. The file that I'm creating comes out correctly so it's as if I need some type of conditional to end the function calls or something? I'm really stumped with this one... Code: [Select] Undefined index: 1 Invalid argument supplied for foreach() Undefined index: 4 Invalid argument supplied for foreach() Undefined index: 7 Invalid argument supplied for foreach() Undefined index: 21 Invalid argument supplied for foreach() Undefined index: 2 Invalid argument supplied for foreach() Undefined index: 11 Invalid argument supplied for foreach() Undefined index: 6 Invalid argument supplied for foreach() Undefined index: 22 Invalid argument supplied for foreach() Undefined index: 24 Invalid argument supplied for foreach() Here is a var_dump of $menu Code: [Select] array(2) { ["items"]=> array(12) { [1]=> object(stdClass)#17 (10) { ["id"]=> string(1) "1" ["name"]=> string(4) "HOME" ["parent"]=> string(1) "0" ["type"]=> string(9) "slideshow" ["order"]=> string(1) "1" ["visible"]=> string(4) "true" ["image"]=> NULL ["color"]=> NULL ["link"]=> NULL ["target"]=> NULL } [5]=> object(stdClass)#18 (10) { ["id"]=> string(1) "5" ["name"]=> string(4) "INFO" ["parent"]=> string(1) "0" ["type"]=> string(6) "parent" ["order"]=> string(1) "2" ["visible"]=> string(4) "true" ["image"]=> NULL ["color"]=> NULL ["link"]=> NULL ["target"]=> NULL } [3]=> object(stdClass)#19 (10) { ["id"]=> string(1) "3" ["name"]=> string(9) "GALLERIES" ["parent"]=> string(1) "0" ["type"]=> string(6) "parent" ["order"]=> string(1) "3" ["visible"]=> string(4) "true" ["image"]=> NULL ["color"]=> NULL ["link"]=> NULL ["target"]=> NULL } [18]=> object(stdClass)#20 (10) { ["id"]=> string(2) "18" ["name"]=> string(16) "GALLERY SECTIONS" ["parent"]=> string(1) "0" ["type"]=> string(14) "gallery_portal" ["order"]=> string(1) "4" ["visible"]=> string(4) "true" ["image"]=> string(11) "DSC0250.jpg" ["color"]=> string(6) "848a5a" ["link"]=> NULL ["target"]=> NULL } [22]=> object(stdClass)#21 (10) { ["id"]=> string(2) "22" ["name"]=> string(7) "CONTACT" ["parent"]=> string(1) "0" ["type"]=> string(5) "forms" ["order"]=> string(1) "5" ["visible"]=> string(4) "true" ["image"]=> NULL ["color"]=> NULL ["link"]=> NULL ["target"]=> NULL } [24]=> object(stdClass)#22 (10) { ["id"]=> string(2) "24" ["name"]=> string(12) "MAILING LIST" ["parent"]=> string(1) "0" ["type"]=> string(5) "forms" ["order"]=> string(1) "6" ["visible"]=> string(5) "false" ["image"]=> NULL ["color"]=> NULL ["link"]=> NULL ["target"]=> NULL } [2]=> object(stdClass)#23 (10) { ["id"]=> string(1) "2" ["name"]=> string(7) "WEDDING" ["parent"]=> string(1) "3" ["type"]=> string(7) "gallery" ["order"]=> string(1) "1" ["visible"]=> string(4) "true" ["image"]=> NULL ["color"]=> NULL ["link"]=> NULL ["target"]=> NULL } [4]=> object(stdClass)#24 (10) { ["id"]=> string(1) "4" ["name"]=> string(8) "ABOUT US" ["parent"]=> string(1) "5" ["type"]=> string(9) "text_page" ["order"]=> string(1) "1" ["visible"]=> string(4) "true" ["image"]=> NULL ["color"]=> NULL ["link"]=> NULL ["target"]=> NULL } [7]=> object(stdClass)#25 (10) { ["id"]=> string(1) "7" ["name"]=> string(8) "CALENDAR" ["parent"]=> string(1) "5" ["type"]=> string(8) "calendar" ["order"]=> string(1) "2" ["visible"]=> string(4) "true" ["image"]=> NULL ["color"]=> NULL ["link"]=> NULL ["target"]=> NULL } [21]=> object(stdClass)#26 (10) { ["id"]=> string(2) "21" ["name"]=> string(14) "PORTFOLIOSITEZ" ["parent"]=> string(1) "5" ["type"]=> string(8) "external" ["order"]=> string(1) "3" ["visible"]=> string(4) "true" ["image"]=> NULL ["color"]=> NULL ["link"]=> string(25) "http://portfoliositez.com" ["target"]=> string(6) "_blank" } [11]=> object(stdClass)#27 (10) { ["id"]=> string(2) "11" ["name"]=> string(9) "LANDSCAPE" ["parent"]=> string(2) "18" ["type"]=> string(7) "gallery" ["order"]=> string(1) "1" ["visible"]=> string(4) "true" ["image"]=> NULL ["color"]=> NULL ["link"]=> NULL ["target"]=> NULL } [6]=> object(stdClass)#28 (10) { ["id"]=> string(1) "6" ["name"]=> string(9) "PORTRAITS" ["parent"]=> string(2) "18" ["type"]=> string(7) "gallery" ["order"]=> string(1) "2" ["visible"]=> string(4) "true" ["image"]=> NULL ["color"]=> NULL ["link"]=> NULL ["target"]=> NULL } } ["parents"]=> array(4) { [0]=> array(6) { [0]=> string(1) "1" [1]=> string(1) "5" [2]=> string(1) "3" [3]=> string(2) "18" [4]=> string(2) "22" [5]=> string(2) "24" } [3]=> array(1) { [0]=> string(1) "2" } [5]=> array(3) { [0]=> string(1) "4" [1]=> string(1) "7" [2]=> string(2) "21" } [18]=> array(2) { [0]=> string(2) "11" [1]=> string(1) "6" } } } And here is the code Code: [Select] public function sitemap() { $query = $this->db->order_by('parent', 'asc')->order_by('order', 'asc')->get('menu'); foreach($query->result() as $row) { $menu['items'][$row->id] = $row; $menu['parents'][$row->parent][] = $row->id; } function build_map($parent, $menu, &$data) { foreach($menu['parents'][$parent] as $itemId) { if(!isset($menu['parents'][$itemId])) { if(($menu['items'][$itemId]->parent == 0) && ($menu['items'][$itemId]->visible != 'false')) { $name = str_replace(' ','-', $menu['items'][$itemId]->name); $data .= "\t<url><loc>" . base_url() . "#!/". $name ."</loc></url>\n"; } elseif($menu['items'][$itemId]->visible != 'false' && $menu['items'][$itemId]->type !='external' && $menu['items'][$itemId]->type != 'parent') { $name = str_replace(' ','-', $menu['items'][$itemId]->name); $name2 = str_replace(' ','-', $menu['items'][$menu['items'][$itemId]->parent]->name); $data .= "\t<url><loc>" . base_url() . "#!/". $name2 ."/" . $name ."</loc></url>\n"; } } if(isset($menu['parents'][$itemId]) && $menu['items'][$itemId]->visible != 'false' && $menu['items'][$itemId]->type != 'parent' && $menu['items'][$itemId]->type !='external') { $name = str_replace(' ','-', $menu['items'][$itemId]->name); $data .= "\t<url><loc>" . base_url() . "#!/". $name ."</loc></url>\n"; } build_map($itemId, $menu, $data); } } $data = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n\t<url><loc>".base_url()."</loc></url>\n"; build_map(0, $menu, $data); $data .= "</urlset>"; write_file('sitemap.xml', $data); } Hi I have built a series of forms with PHP and have been using SESSIONS to carry values from one to another. In one, the value of a variable is determined by adding the values of several other variables together: Code: [Select] $totalFixed = $fixedCost1 + $fixedCost2 + $fixedCost3 + $fixedCost4 + $fixedCost5;This equation is working fine on that page. I then place the value of $totalFixed in a SESSION variable: Code: [Select] $_SESSION['totalFix']=$totalFixed;I then assign this SESSION variable's value to a new variable on another page in the series: Code: [Select] $dataValue[4] = $_SESSION['totalFix'];The number displays fine on this page as well. However, when the value is above 1,000 and I try to subtract another number from it, it ignores everything to the right of the comma. For example, if $dataValue[4] is 10,132 and $dataValue[5] is 25 and I subtract $dataValue[4] from $dataValue[5], the result is -15. Does anyone know the reason for this? Many thanks, Andy Getting the difference in seconds between two timestamps is easy. Taking the seconds and doing a breakdown of time frames is also easy. Code: [Select] <?php echo '<p>There are a total of ' . round($seconds) . ' seconds between Timestamp 1 and Timestamp 2.</p>'; echo '<p>There are a total of ' . round($seconds / 60) . ' minutes between Timestamp 1 and Timestamp 2.</p>'; echo '<p>There are a total of ' . round(($seconds / 60) / 1440) . ' days between Timestamp 1 and Timestamp 2.</p>'; echo '<p>There are a total of ' . round((($seconds / 60) / 1440) / 7) . ' weeks between Timestamp 1 and Timestamp 2.</p>'; echo '<p>There are a total of ' . round((((($seconds / 60) / 1440) / 7) / 30)) . ' months between Timestamp 1 and Timestamp 2.</p>'; echo '<p>The total breakdown of time from Timestamp 1 to Timestamp 2 is .</p>'; ?> What I am trying to figure out, is get a collective amount as well.... X years X months X weeks X days X minutes and X seconds. Does anyone have any good algorithm for handling that, or have any feedback on where to start to handle this type of math. having a problem importing a file having multiple hierarchy levels!! its a csv file the contents look something like this! just need a jump start! thanks the file looks likes this row 1 row2 row3 name1 subj1 abcd efgh subje2 test1 test2 the file has to first import name1 then subj1 then abcd,then efgh then move back to subj2 and so on! Thanks Hi guys, I'm trying to build an array to replicate the hierarchy in a menu: <ul> <li><a href="file1.html">text1</a></li> <ul> <li><a href="file2.html">text2</a></li> <li><a href="file3.html">text3</a></li> <li><a href="file4.html">text4</a></li> <li><a href="file5.html">text5</a></li> </ul> </ul> An i would like the output to be:
"text1" Here is my loop to go through the html hierarchy: foreach ($html2->find('ul') as $ul) { foreach ($ul->find('li') as $li) { foreach($li->find('a') as $a) { // need to filter out empty and index.html, tried if(!$->href = 'index.html) {do stuff} but didn't work $links2[] = $a->href ; $taxo2[] = $a->plaintext ; } } } This finds all the links but not the hierarchy, any ideas how to approach this? And also how to filter out blanks and references to index.html? I'm using a CRUD system which won't automatically update the lft and rght values of my hierarchical tables when I enter a new row. I don't know what the best way to solve this is, all I can think of is adding a stored procedure to the table so that whenever a new row gets added, the procedure will make sure the lft and rght values get shifted. Is this even possible with stored procedures?
Hi im using ftp_rawlist () to list files in my web hosting folder /public_html/ it works fine, but is there anyway to only show/list .php & html files? Hi, I have a chunk of text I am pulling from a mysql db like below. Air conditioning in rooms 24 Hour Reception Smoking rooms available How can I write this into - <ul> <li>Air conditioning in rooms</li> <li>24 Hour Reception</li> <li>Smoking rooms available</li> </ul> Many thanks. Hi all, I have a html form list box that needs to show all the types of products that are for sale and have a number in the list box saying how many of that type are for sale. eg. If the mysql database looks like this productType | productDetails chair | outdoor large chair table | 2m x 1m chair | indoor chair chair | childs chair I would want the form list box to show the values inside as: chair (3) table (1) could someone give me the heads up on how to do this Thanks i have made a simple header page for a project.
now i want to create a dropdown menu for a single menu item in the menu bar.
how i will do that ..??
for ex-under COURSES MENU, THE SUBMENU ARE : DEGREE,DIPLOMA,HIGHSCHOOL.
hi i have generated a product list from a mysql table called product_list, once i enter a new product in to the table the product will be shown in the generated list and the list will grow and the table grows. and i want to allow user the edit/delete/save the products from the generated table, i have no idea how to do it and what is the algorithmic idea to do it so. here is the php and the html code. <!--Body container for creating a new product in to the list--> <div class="body_orderviewform"> <form name="form1" method="post" action="upload_file.php" enctype="multipart/form-data"> <p> <label for="user_id">User ID:</label> <input type="text" name="user_id" id="user_id"> <label for="customer_name">Customer Name:</label> <input type="text" name="customer_name" id="customer_name"> <label for="customer_family">Customer_family</label> <input type="text" name="customer_family" id="customer_family"> <label for="freelancer_name">Purchaser:</label> <input name="freelancer_name" type="text" id="freelancer_name"> <? if (isset($_COOKIE['picAdd'])) echo $_COOKIE['picAdd'];?> </p> <!------------------------------------------------------------------------------------------------------- for generating the list --> <div class="div.neworder_list" > <div class="div.neworder_listheader" align="center"> <table width="637" border="1" > <tr> <td width="193"><label for="link">link:</label> <label for="link_new"></label> <input type="text" name="link_new" id="link_new"></td> <td width="202"><label for="unitprice">Unit Price:</label> <label for="Unit_price_new"></label> <input type="text" name="Unit_price_new" id="Unit_price_new"></td> <td width="220"><label for="qty">Quantity:</label> <label for="quantity_new"></label> <input type="text" name="quantity_new" id="quantity_new"></td> </tr> <tr> <td><label for="express">Express Fee:</label> <label for="express_new"></label> <input type="text" name="express_new" id="express_new"></td> <td><label for="commission_new">Commission:</label> <input type="text" name="commission_new" id="commission_new"></td> <td><label for="customer_description">Description</label> <label for="description_new"></label> <textarea name="description_new" id="description_new" cols="45" rows="5"></textarea></td> </tr> <tr> <td> </td> <td colspan="2">Picture Upload: <input type="hidden" name="<?php echo ini_get("session.upload_progress.name");?>" value="123" /> <input name="file" type="file" autofocus="autofocus"/> <br /> </tr> <tr> <td colspan="3"><input type="reset" name="reset" id="reset" value="Reset"> <input type="submit" name="submit" id="submit" value="Submit The Product"></td> </tr> </table> </form> </div> <div class="neworder_listview"> <p> <form action="" method="post" name="list"> <input type="submit" name="del" id="del" value="Save"> <input type="submit" name="save" id="save" value="Del"> </p> <table width="1022" border="1" align="center"> <tr> <th width="24" scope="col"> </th> <th width="24" scope="col">Row#</th> <th width="137" scope="col">Manager</th> <th width="137" scope="col">Purchaser Desc</th> <th width="40" scope="col"><p>Link</p> <p>/Ссылки</p></th> <th width="53" scope="col">ФОТО</th> <th width="50" scope="col">Unit Price/Цена за еденицу товара</th> <th width="46" scope="col">Quantity/ Кол-во</th> <th width="138" scope="col">Total Unit Price/ Общая цена</th> <th width="89" scope="col">Express/Доставка по Китаю</th> <th width="119" scope="col">Description/Описание</th> <th width="89" scope="col">ADDITIONAL LINKS/ЗAMЕНЫ</th> </tr> <?php $username = "my username"; $password = "my pass"; $database = "userinfo"; $link = mysql_connect("localhost", "$username", "$password"); if(!$link) {echo("Failed to establish connection to mysql server"); exit();} $status = mysql_select_db($database); $query = "SELECT * FROM order_list"; $result = mysql_query($query); $num = mysql_num_rows($result); $i=0; while ($i < $num) { $field1_name=mysql_result($result,$i,"admin_st"); $field2_name=mysql_result($result,$i,"freelancer_st"); $field3_name=mysql_result($result,$i,"link"); $field4_name=mysql_result($result,$i,"picture"); $field5_name=mysql_result($result,$i,"unitprice"); $field6_name=mysql_result($result,$i,"qty"); $field7_name=mysql_result($result,$i,"express"); $field8_name=mysql_result($result,$i,"customer_st"); $i++; } ?> <?php $i=0; $row=1; while ($i < $num) { $f1=mysql_result($result,$i,"admin_st"); $f2=mysql_result($result,$i,"freelancer_st"); $f3=mysql_result($result,$i,"link"); $f4=mysql_result($result,$i,"pic_address"); $f5=mysql_result($result,$i,"unitprice"); $f6=mysql_result($result,$i,"qty"); $f7=mysql_result($result,$i,"express"); $f8=mysql_result($result,$i,"customer_st"); $totao_unit_price = $f5*$f6; ?> <tr> <td><input type="checkbox" name="del_chbox" id="del_chbox"> <td><p><font face="Arial"><input name="row_txtbox" type="text" id="row_txtbox" size="2" value="<?php echo $row; ?>"></font></td> <td><p><font face="Arial"> <textarea name="manager_txtbox" cols="10" id="manager_txtbox"><?php echo $f1; ?></textarea></font></td> <td><p><font face="Arial"> <textarea name="purchase_txtbox" cols="10" id="purchase_txtbox"><?php echo $f2; ?></textarea> </font></td> <td><font face="Arial"><a href="<?php $f3 ?>" target="_blank"><?php echo $f3; ?></a></font></td> <td><font face="Arial"><img src="<?php echo $f4;?>" width="100" align="middle"100></font></td> <td><font face="Arial"><input name="unitprice_txtbox" type="text" id="unitprice_txtbox" size="2" value="<?php echo $f5; ?>"></font></td> <td><font face="Arial"> <input name="qty_txtbox" type="text" id="qty_txtbox" size="2" value="<?php echo $f6; ?>"></font></td> <td><p><font face="Arial"><?php echo $totao_unit_price; ?></font></td> <td><p><font face="Arial"><input name="express2" type="text" id="express3" size="2" value="<?php echo $f7; ?>"></font></td> <td><p><font face="Arial"> <textarea name="custdesc_txtbox" cols="20" id="custdesc_txtbox"><?php echo $f8; ?></textarea></font></td> <td><input name="express2" type="text" id="express3" size="2" value="<?php echo "new link" ?>"></td> </tr> <p> <?php $i++; $row++; } ?> </table> </p> <p> </p> </form> Hi, In my mysql database i have a text input option, in the registration form and edit my details form i have a multiple select dropdown list, which user selects options to populate the text input box, which ultimately populates the text field in the mysql database. All works perfectly. The dropdownlist consists of 3 parts <optgroups> first is current selection (what is the usesr current selection)works fine, The second <optgroup> is existing words, what words we(the site) have given as options, and the third <optgroup> is the words that others have used. This is where im having a small problem. Because its a text field when i call the data from the database, it calls the entire text box as a single option in my select list.. I want to break the words in the text field (at the comma) and have them listed each one as an option in the select list. Example what i need: Words in text box:(my input allows the "comma") word1, word2, word3, word4, word5, word6, How i want them called/displayed: <option value=\"word1\">word1</option> <option value=\"word2\">word2</option> <option value=\"word3\">word3</option> <option value=\"word4\">word4</option> <option value=\"word5\">word5</option> <option value=\"word6\">word6</option> here's my code: $query = "SELECT allwords FROM #__functions_experience WHERE profile_id = '".(int)$profileId."' LIMIT 1"; $original_functionsexperience =doSelectSql($query,1); $query = "SELECT allwords FROM #__functions_experience WHERE profile_id = '".(int)$profileId."' LIMIT 1"; $functionsexperiencelist=doSelectSql($query); $funcexpList ="<select multiple=\"multiple\" onchange=\"setFunctionsexperience(this.options)\">"; foreach ($functionsexperiencelist as $functionsexperienceal) { $selected=""; if ($functionsexperienceals->allwords == $original_functionsexperience) $selected=' selected="selected"'; $allwords=$functionsexperienceal->allwords; $funcexpList .= "<optgroup label=\"Current selection\"> <option value=\"".$allwords."\" ".$selected." >".$allwords."</option> </optgroup> <optgroup label=\"Existing Words\"> <option value=\"existing1,\">existing1</option> <option value=\"existing2,\">existing2</option> <option value=\"existing3,\">existing3</option> <option value=\"existing4,\">existing4</option> <option value=\"existing5,\">existing5</option> <option value=\"existing6,\">existing6</option> </optgroup> <optgroup label=\"Others added\"> //heres problem <option value=\"".$allwordsgeneral."\">".$allwordsgeneral."</option> </optgroup>"; } $funcexpList.="</select>"; $output['FUNCEXPLIST']=$funcexpList; The result im getting for optgroup others added: word1, word2, word3, word4, word5, how can i get it like this: <option value=\"word1\">word1</option> <option value=\"word2\">word2</option> <option value=\"word3\">word3</option> <option value=\"word4\">word4</option> <option value=\"word5\">word5</option> <option value=\"word6\">word6</option> Hi , I have one question .. Can I split showing of content of dynamic list in 2 parts , when I echo list in code .. Code: [Select] <?php // Run a select query to get my letest 8 items // Connect to the MySQL database include "../connect_to_mysql.php"; $dynamicList = ""; $sql = mysql_query("SELECT * FROM products ORDER BY date_added DESC LIMIT 8"); $productCount = mysql_num_rows($sql); // count the output amount if ($productCount > 0) { while($row = mysql_fetch_array($sql)){ $id = $row["id"]; $product_name = $row["product_name"]; $price = $row["price"]; $date_added = strftime("%b %d, %Y", strtotime($row["date_added"])); $dynamicList .= '<table width="100%" border="2" cellspacing="2" cellpadding="2"> <tr> <td width="17%" valign="top"><a href="product.php?id=' . $id . '"><img style="border:#666 1px solid;" src="inventory_images/' . $id . '.jpg" alt="' . $product_name . '" width="77" height="102" border="2" /></a></td> <td width="83%" valign="top">' . $product_name . '<br /> $' . $price . '<br /> <a href="product.php?id=' . $id . '">View Product Details</a></td> </tr> </table>'; } } else { $dynamicList = "We have no products listed in our store yet"; } mysql_close(); ?> Code: [Select] <p><?php echo $dynamicList; ?><br /> </p> It works ok, and putting my files, everything works, but when I put 8 pictures with price and other details, it just show one image with details and another image below with details, and the third image below and so on .. Can I split dynamic list to show 4 images with details on the left side and 4 on the right side? Thank you in advance for help , if is possible Hi, I use the following code to create a select menu from an array of options stored in LISTS.php: include 'LISTS.php'; print('<select id="from" name="from">'); foreach ($langList as $lang) {printf('<option %s>%s</option>', ($from1 == $lang ? 'selected="selected"' : ''), $lang); } echo '</select>'; where LISTS.php includes the following: $langList = array(' ','English', 'French', 'German', 'Dutch', 'Spanish'); This works great, but now I want to do something similar with a checkbox list, where each checkbox has an associated 'onchange' javascript function and I'm getting pretty stuck. My checkbox list is of the following form: Code: [Select] <html> <ul style="height: 95px; overflow: auto; width: 200px; border: 1px solid #480091; list-style-type: none; margin: 0; padding: 0;"> <li id="li1b"><label for="chk1b"><input name="chk1b" id="chk1b" type="checkbox" onchange="function1('chk1b','li1b')">Option1</label></li> <li id="li2b"><label for="chk2b"><input name="chk2b" id="chk2b" type="checkbox" onchange="function1('chk2b','li2b')">Option2</label></li> //etc. </ul> </html> What I want to do is have 'Option1', 'Option2', etc. stored in an array in LISTS.php and have a PHP script that populates the checkbox list accordingly, in a similar manner to my select menu above. I can't work out how to get the ID of the next <li> and the next <input> in the list to go up by one each time, e.g. 'li1b' then 'li2b', 'li3b', etc. Could someone pls help me out? Thanks! Is there a way to take data that is listed like a,b,c,d,e and turn that into an unordered list? Basically, I'm going to have a list of schools that will be listed with comma separators. I'll print that data out in two places, one will be printed as it's in the database. The other I would like to echo as an unordered list. How hard would something like this be? I have a database with all my users. I need an empty list and when a user clicks a button "Add me to the list" they are added to the first position in the list Slots 1. Tom 2. 3. 4. 5. Later, Jerry wants to be added to the list. So this happens Slots 1. Jerry 2. Tom 3. 4. 5. More people join the list 1. Bob 2. John 3. Jerry 4. Tom 5. Tom gets upset clicks the same button to join the list again, and he's bumped back up to first place. Slots 1. Tom 2. Bob 3. John 4. Jerry 5. Is this possible? And is so, how would I go about getting started on such a thing? I've been using PHP for about a year and a half. Is it possible to get bittorrent peer list (IP list) via php, udp protocol ? txh! Hello there, this is a really noob question, but I've no idea on how to make it work without making everything messy and crappy. I have one SQL table called categories, and another called subcategories. Inside the subcategories table there's a field named 'parent' that will link it to the correspondent category, so it should look something like this in html: Code: [Select] <ul> <li>Category <ul> <li>Subcategory</li> </ul> </li> </ul> Would you please give this poor guy a hand? =) I have a form that users input user name, password, and email... all writes to csv fine. My problem is I need to concatenate a a string with a variable and some html code will preserving the html when written to the csv.. I need the csv to be this username,password,email,user,category,text with http://sub.domain..com/splash/,something,something here's what i have Code: [Select] <?php if($_POST['formSubmit'] == "Submit") $varUserName = $_POST['username']; $varPW = $_POST['PW']; $varEmail = $_POST['email']; { $fs = fopen("testcsv.csv","a"); fputcsv($fs, array($varUserName,$varPW,$varEmail,"user","title",",category","some text '<a href="http://$varUserName.url.com/splash/>site.com</a>',)); fclose($fs); exit; } ?> and of course I'm getting Parse error: syntax error, unexpected T_STRING, expecting ')' on line 9 Hey guys, I'm a total newbie here, and just about as a new to php. My issue: I have a very large .html file that contain multiple articles (I actually have a few of these, but we'll start with one for practicality). The article titles are all wrapped in <h2> tags, there are 10 articles in one file. The articles are very simple, just a title wrapped with <h2> and then a few paragraphs wrapped in <p> tags. What I want to know how to do: I want to know if there's a way to open that file, and have each article saved as it's own .html or .txt document (the title & following paragraphs of each article). Ultimately taking my 1 large file, and creating the subsequent 10 smaller files from the articles inside of it. I am having trouble explaining this in text so I'll try to illustrate: I have "Articles.html" - which contains (article1,article2,article3.. ..article10) I want to split "Articles.html" and create "Article1.html", "Article2.html", "Article3.html", etc. Is that possible? Or am I looking at something far more complex than I can imagine at this point - perhaps something I'd be better off doing by hand? Ultimately I intend to stick all these articles into a database, but that's the 2nd part of what I want to do (and I think will be the easier of the tasks). Let me know if you need any additional information in the event my description above is unclear... I simply am having issues figuring out how to separate out the text into individual articles. |