PHP - Help With View/edit/del Options.
Hi,
Similar TutorialsOld issue of mine that I'm coming back to. My question is I'm trying to figure out how to work with the select box of options and apply button so that if delete is chosen and the user clicks on apply it performs the deletedivision inside the process page I know it deals with jquery's ajax however this part of it does not that I'm trying to get fixed because as of right now I have if (isset($_POST['deletedivision'])) and I know that's not right and I know I can't apply a name to the option tag because name isn't one of option's allowable attributes. mods/divisions.php Code: [Select] <form action="" method="post"> <label for="actionSelect">With selected items: </label> <select class="select" name="actionSelect" id="actionSelect"> <option id="1">Edit</option> <option id="2">Delete</option> </select> <button class="button small-button"><strong>Apply</strong></button> </form> <?php while ( $row = mysqli_fetch_array ( $result, MYSQL_ASSOC ) ) { echo ' <tr> <td><input type=checkbox class=checkbox name=checkbox[] id=checkbox[] value="' . $row['id'] . '" /></td> <td>' . $row['divisionname'] . '</td> <td>' . $row['name'] . '</td> <td class=last>' . $row['datecreated'] . '</td> </tr>'; } ?> processes/divisions.php if (isset($_POST['deletedivision'])) { $checkbox = $_POST['checkbox']; $countCheck = count($_POST['checkbox']); for($i=0;$i<$countCheck;$i++) { $del_id = $checkbox[$i]; $query = "DELETE from `divisions` where id = $del_id"; mysqli_query($dbc,$query); } } Hi,
I haven't worked with PHP in years and was asked to debug something. Maybe you can help me out since I'm stuck. This error popped up when we upgraded from PHP 5.3 to 5.4.
It is setting LDAP options.
Here is the code:
ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3); ldap_set_option($ldapconn, LDAP_OPT_REFERRALS, 0) or die ("Could not set option referrals"); Both of these statement are throwing the following error message to the log. 52 is not a valid ldap link resource Anything I can check or look at? I am a little clueless here. Thanks I have 3 basic questions. I did a few Google Searches for this data and could not find anything substantion. What options are available to somewho who wants to send notifications to a Desktop PC (main thing), Android phone, and maybe a few other phone types. The main thing I need to figure out is about desktop notifications. I heard that GMail was about to release this feature soon, so I know there must be options out there for it. Are there any options, besides a standard custom desktop application development? Hi I have this serach function, wich searches on site by a lot of parameters at the same time (titolo, titolo2, attore1,etc...) , but I want to make them options, so you would have a search field and an options dropdown menu. Can anyone help me with this? My code follows: PHP Code: [Select] function jm_search(){ global $database, $sstring, $my, $cinConfig, $Itemid, $option, $mainframe; $tl_title = _JMOVIES_SEARCHRESULT." ".$sstring; $suchstring = trim( strtolower( $sstring ) ); $query1 = "SELECT * FROM #__jmovies WHERE" ."\n (titolo LIKE '%".$suchstring."%'" ."\n OR titolo2 LIKE '%".$suchstring."%'" ."\n OR attore1 LIKE '%".$suchstring."%'" ."\n OR attore2 LIKE '%".$suchstring."%'" ."\n OR attore3 LIKE '%".$suchstring."%'" ."\n OR attore4 LIKE '%".$suchstring."%'" ."\n OR nazione LIKE '%".$suchstring."%'" ."\n OR regista LIKE '%".$suchstring."%'" ."\n OR descrizione LIKE '%".$suchstring."%'" ."\n OR anno LIKE '%".$suchstring."%') AND published = 1 AND access <= ".(int)$my->gid." ORDER BY titolo"; $database->setQuery($query1); //echo $database->getQuery(); $rows = $database->loadObjectList(); if(is_file($mainframe->getCfg('absolute_path')."/components/".$option."/templates/".$cinConfig['template']."/show_search_tpl.php")) require($mainframe->getCfg('absolute_path')."/components/".$option."/templates/".$cinConfig['template']."/show_search_tpl.php"); else require($mainframe->getCfg('absolute_path')."/components/".$option."/templates/default/show_search_tpl.php"); } HTML Code: [Select] <td width="44%" valign="middle" bgcolor="#eeeeee" style="text-align:right"> <input name="sstring" type="text" class="jmoviesInputSearch" title="<?php echo _JMOVIES_SEARCH?>" onfocus="if(this.value=='<?php echo _JMOVIES_SEARCH?>') this.value='';" onblur="if(this.value=='') this.value='<?php echo _JMOVIES_SEARCH?>';" onchange="javascript:document.jmoviesSearchForm.submit();" value="<?php echo _JMOVIES_SEARCH?>" size="50"/><input type="submit" value="OK" class="button"/></td> Thank you. I am new to PHP and wasting no time have jumped into creating my own database system. Its actually a psuedo-database, but who cares it works. I've done something some-what similar in Python but with a static single file database. What I have is directories as like: ./1/index.listing ./2/index.listing ./3/index.listing The numbers are a product... product 1, product 2, you know.. What I want to do is on the product category page, using: Code: [Select] include('./*/index.listing');.. where * would mean for PHP to scan all relative directories and include 'index.listing', which will result in a list being built for the product category, showing all the available products. There is probably some way to do this in MySQL, but I am already familiur with this style of database, so why waste more Saturday nights learning something I don't have to when I could be out getting drunk and partying with girls 10 years younger than me. LuLz Hello, I'm just learning php (by force), but am pretty well versed in html and css. I did not rite the following code and I'm not sure how to pull out the php in the following in order to make the page validate. <tr> <td width="15%"><b><b>Priority</b></td> <td> <select name="priority" size="1" value="priority"> <option value="" <?php if ($row['priority'] == "") echo " selected";?> ></option> <option value="Normal" <?php if ($row['priority'] == "Normal") echo " selected";?> >Normal</option> <option value="Elevated" <?php if ($row['priority'] == "Elevated") echo " selected";?> >Elevated</option> <option value="STAT" <?php if ($row['priority'] == "STAT") echo " selected";?> >STAT</option> </select> </td> </tr> The idea is to prefetch the "priority" info and populate the drop down with that. Afterwards, the user can change the value and once submitted, the value will change in the database. Any pointers would be appreciated - and thanks in advance. Rich I accidently posted this in the PHP applications board and didn't mean to because its a blizzard here and my comp is getting slow and lagging and I thought I had clicked in the right board but I was wrong so if a mod, admin can delete that other entry I'd be thankful. I'm trying to queries together because I have this query but I want to only put in those characters that have not been taken so I have another table that lists all the characters that are used. TABLE handler_characters which has fields called id, handler_id, character_id. What I want to somehow do is have it get all the character_ids out of that table and then subtract those ids from this query so it won't list them as options. Any thoughts on how to accomplish this? <?php $query = 'SELECT id, charactername FROM characters ORDER BY `charactername`'; $result = mysqli_query ( $dbc, $query ); // Run The Query while ( $row = mysqli_fetch_array ( $result, MYSQL_ASSOC ) ) { print "<option value=\"".$row['id']."\">".$row['charactername']."</option>\r"; } ?> Why dos this loop not split up after 15 options? Code: [Select] $count = 0; $maxPerList = 15; echo '<ul style="list-style: none; padding-left: 0px; margin: 0px; "><li style="list-style: none; "><input type="text" name='.$i.'_quantity value="" style="text-align:right;" size="3"> '; echo tep_draw_hidden_field($i.'_id[' . $products_options_name['products_options_id'] . ']', $products_options_array[$i]['id']) . $products_options_array[$i]['text']; echo "<ul>"; foreach($products_options_name as $currValue) { if($count == $maxPerList) { echo "</ul>"; echo "<ul>"; $count = 0; } echo "</li>"; $count++; echo "</ul>";all the file Code: [Select] <?php /* $Id$ adapted for Separate Pricing Per Customer v4.2 2007/06/23 osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2010 osCommerce Released under the GNU General Public License */ require('includes/application_top.php'); require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_PRODUCT_INFO); $product_check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'"); $product_check = tep_db_fetch_array($product_check_query); // BOF Separate Pricing per Customer if (isset($_SESSION['sppc_customer_group_id']) && $_SESSION['sppc_customer_group_id'] != '0') { $customer_group_id = $_SESSION['sppc_customer_group_id']; } else { $customer_group_id = '0'; } // EOF Separate Pricing per Customer require(DIR_WS_INCLUDES . 'template_top.php'); if ($product_check['total'] < 1) { ?> <div class="contentContainer"> <div class="contentText"> <?php echo TEXT_PRODUCT_NOT_FOUND; ?> </div> <div style="float: right;"> <?php echo tep_draw_button(IMAGE_BUTTON_CONTINUE, 'triangle-1-e', tep_href_link(FILENAME_DEFAULT)); ?> </div> </div> <?php } else { $product_info_query = tep_db_query("select p.products_id, pd.products_name, pd.products_description, p.products_model, p.products_quantity, p.products_image, pd.products_url, p.products_price, p.products_tax_class_id, p.products_date_added, p.products_date_available, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'"); $product_info = tep_db_fetch_array($product_info_query); tep_db_query("update " . TABLE_PRODUCTS_DESCRIPTION . " set products_viewed = products_viewed+1 where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and language_id = '" . (int)$languages_id . "'"); if ($new_price = tep_get_products_special_price($product_info['products_id'])) { // BOF Separate Pricing per Customer if ($customer_group_id > 0) { // only need to check products_groups if customer is not retail $scustomer_group_price_query = tep_db_query("select customers_group_price from " . TABLE_PRODUCTS_GROUPS . " where products_id = '" . (int)$HTTP_GET_VARS['products_id']. "' and customers_group_id = '" . $customer_group_id . "'"); if ($scustomer_group_price = tep_db_fetch_array($scustomer_group_price_query)) { $product_info['products_price']= $scustomer_group_price['customers_group_price']; } } // end if ($customer_group_id > 0) // EOF Separate Pricing per Customer $products_price = '<del>' . $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) . '</del> <span class="productSpecialPrice">' . $currencies->display_price($new_price, tep_get_tax_rate($product_info['products_tax_class_id'])) . '</span>'; } else { // BOF Separate Pricing per Customer if ($customer_group_id > 0) { // only need to check products_groups if customer is not retail $scustomer_group_price_query = tep_db_query("select customers_group_price from " . TABLE_PRODUCTS_GROUPS . " where products_id = '" . (int)$HTTP_GET_VARS['products_id']. "' and customers_group_id = '" . $customer_group_id . "'"); if ($scustomer_group_price = tep_db_fetch_array($scustomer_group_price_query)) { $product_info['products_price']= $scustomer_group_price['customers_group_price']; } } // end if ($customer_group_id > 0) // EOF Separate Pricing per Customer $products_price = $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id'])); } if (tep_not_null($product_info['products_model'])) { $products_name = $product_info['products_name'] . '<br /><span class="smallText">[' . $product_info['products_model'] . ']</span>'; } else { $products_name = $product_info['products_name']; } ?> <?php echo tep_draw_form('cart_quantity', tep_href_link(FILENAME_PRODUCT_INFO, tep_get_all_get_params(array('action')) . 'action=add_product')); ?> <div> <style="float: right;"><?php echo $products_price; ?> <h1><?php echo $products_name; ?></h1> </div> <div class="contentContainer"> <div class="contentText"> <?php if (tep_not_null($product_info['products_image'])) { $pi_query = tep_db_query("select image, htmlcontent from " . TABLE_PRODUCTS_IMAGES . " where products_id = '" . (int)$product_info['products_id'] . "' order by sort_order"); if (tep_db_num_rows($pi_query) > 0) { ?> <div id="piGal" style="float: right;"> <ul> <?php $pi_counter = 0; while ($pi = tep_db_fetch_array($pi_query)) { $pi_counter++; $pi_entry = ' <li><a href="'; if (tep_not_null($pi['htmlcontent'])) { $pi_entry .= '#piGalimg_' . $pi_counter; } else { $pi_entry .= tep_href_link(DIR_WS_IMAGES . $pi['image']); } $pi_entry .= '" target="_blank" rel="fancybox">' . tep_image(DIR_WS_IMAGES . $pi['image']) . '</a>'; if (tep_not_null($pi['htmlcontent'])) { $pi_entry .= '<div style="display: none;"><div id="piGalimg_' . $pi_counter . '">' . $pi['htmlcontent'] . '</div></div>'; } $pi_entry .= '</li>'; echo $pi_entry; } ?> </ul> </div> <script type="text/javascript"> $('#piGal ul').bxGallery({ maxwidth: 300, maxheight: 200, thumbwidth: <?php echo (($pi_counter > 1) ? '75' : '0'); ?>, thumbcontainer: 300, load_image: 'ext/jquery/bxGallery/spinner.gif' }); </script> <?php } else { ?> <div id="piGal" style="float: right;"> <?php echo '<a href="' . tep_href_link(DIR_WS_IMAGES . $product_info['products_image']) . '" target="_blank" rel="fancybox">' . tep_image(DIR_WS_IMAGES . $product_info['products_image'], addslashes($product_info['products_name']), null, null, 'hspace="5" vspace="5"') . '</a>'; ?> </div> <?php } ?> <script type="text/javascript"> $("#piGal a[rel^='fancybox']").fancybox({ cyclic: true }); </script> <?php } ?> <?php echo stripslashes($product_info['products_description']); ?> <?php // BOF SPPC Hide attributes from customer groups $products_attributes_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "' and find_in_set('".$customer_group_id."', attributes_hide_from_groups) = 0 "); $products_attributes = tep_db_fetch_array($products_attributes_query); if ($products_attributes['total'] > 0) { ?> <p><?php echo TEXT_PRODUCT_OPTIONS; ?></p> <p> <!-- // Code segment includes/modified for Multiple product option lines. // maintainance and Qns : Harishyam :> feenix_666@yahoo.com --> <?php if ($products_options_total['total'] == 1) { for($i=0;$i<$products_attributes['total'];$i++) { $products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "' and find_in_set('".$customer_group_id."', attributes_hide_from_groups) = 0 order by popt.products_options_name"); while ($products_options_name = tep_db_fetch_array($products_options_name_query)) { $products_options_array = array(); $products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix, pa.products_attributes_id from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pa.options_id = '" . (int)$products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . (int)$languages_id . "' and find_in_set('".$customer_group_id."', attributes_hide_from_groups) = 0"); $list_of_prdcts_attributes_id = ''; $products_options = array(); // makes sure this array is empty again while ($_products_options = tep_db_fetch_array($products_options_query)) { $products_options[] = $_products_options; $list_of_prdcts_attributes_id .= $_products_options['products_attributes_id'].","; } if (tep_not_null($list_of_prdcts_attributes_id) && $customer_group_id != '0') { $select_list_of_prdcts_attributes_ids = "(" . substr($list_of_prdcts_attributes_id, 0 , -1) . ")"; $pag_query = tep_db_query("select products_attributes_id, options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES_GROUPS . " where products_attributes_id IN " . $select_list_of_prdcts_attributes_ids . " AND customers_group_id = '" . $customer_group_id . "'"); while ($pag_array = tep_db_fetch_array($pag_query)) { $cg_attr_prices[] = $pag_array; } // substitute options_values_price and prefix for those for the customer group (if available) if ($customer_group_id != '0' && tep_not_null($cg_attr_prices)) { for ($n = 0 ; $n < count($products_options); $n++) { for ($i = 0; $i < count($cg_attr_prices) ; $i++) { if ($cg_attr_prices[$i]['products_attributes_id'] == $products_options[$n]['products_attributes_id']) { $products_options[$n]['price_prefix'] = $cg_attr_prices[$i]['price_prefix']; $products_options[$n]['options_values_price'] = $cg_attr_prices[$i]['options_values_price']; } } // end for ($i = 0; $i < count($cg_att_prices) ; $i++) } } // end if ($customer_group_id != '0' && (tep_not_null($cg_attr_prices)) } // end if (tep_not_null($list_of_prdcts_attributes_id) && $customer_group_id != '0') for ($n = 0 ; $n < count($products_options); $n++) { $products_options_array[] = array('id' => $products_options[$n]['products_options_values_id'], 'text' => $products_options[$n]['products_options_values_name']); if ($products_options[$n]['options_values_price'] != '0') { $products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $products_options[$n]['price_prefix'] . $currencies->display_price($products_options[$n]['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') '; } } // EOF SPPC attributes mod if (is_string($HTTP_GET_VARS['products_id']) && isset($cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']])) { $selected_attribute = $cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']]; } else { $selected_attribute = false; } ?> <?php $count = 0; $maxPerList = 15; echo '<ul style="list-style: none; padding-left: 0px; margin: 0px; "><li style="list-style: none; "><input type="text" name='.$i.'_quantity value="" style="text-align:right;" size="3">&#8194;'; echo tep_draw_hidden_field($i.'_id[' . $products_options_name['products_options_id'] . ']', $products_options_array[$i]['id']) . $products_options_array[$i]['text']; echo "<ul>"; foreach($products_options_name as $currValue) { if($count == $maxPerList) { echo "</ul>"; echo "<ul>"; $count = 0; } echo "</li>"; $count++; echo "</ul>"; }} } // End of loop } else { //do your regular thing $products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "' order by popt.products_options_name"); while ($products_options_name = tep_db_fetch_array($products_options_name_query)) { $products_options_array = array(); $products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pa.options_id = '" . (int)$products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . (int)$languages_id . "'"); while ($products_options = tep_db_fetch_array($products_options_query)) { $products_options_array[] = array('id' => $products_options['products_options_values_id'], 'text' => $products_options['products_options_values_name']); if ($products_options['options_values_price'] != '0') { $products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $products_options['price_prefix'] . $currencies->display_price($products_options['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') '; } } if (isset($cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']])) { $selected_attribute = $cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']]; } else { $selected_attribute = false; } } ?> <strong><?php echo $products_options_name['products_options_name'] . ':'; ?></strong><br /><?php echo tep_draw_pull_down_menu('id[' . $products_options_name['products_options_id'] . ']', $products_options_array, $selected_attribute); ?><br /> <?php } ?> </p> <?php } ?> <div style="clear: both;"></div> <?php if ($product_info['products_date_available'] > date('Y-m-d H:i:s')) { ?> <p style="text-align: center;"><?php echo sprintf(TEXT_DATE_AVAILABLE, tep_date_long($product_info['products_date_available'])); ?></p> <?php } ?> </div> <?php $reviews_query = tep_db_query("select count(*) as count from " . TABLE_REVIEWS . " where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and reviews_status = 1"); $reviews = tep_db_fetch_array($reviews_query); ?> <div class="buttonSet"> <span class="buttonAction"><?php if ($products_options_total['total'] != 1) { echo 'Enter Quantity: ' . tep_draw_input_field('cart_quantity','1','size="3" style="text-align:right;"') . ' ' ; } ?> <?php echo tep_draw_hidden_field('products_id', $product_info['products_id']) . tep_draw_button(IMAGE_BUTTON_IN_CART, 'cart', null, 'primary'); ?></span> </div> <?php if ((USE_CACHE == 'true') && empty($SID)) { echo tep_cache_also_purchased(3600); } else { include(DIR_WS_MODULES . FILENAME_ALSO_PURCHASED_PRODUCTS); } ?> </div> </form> <?php } require(DIR_WS_INCLUDES . 'template_bottom.php'); require(DIR_WS_INCLUDES . 'application_bottom.php'); ?> I'm creating a blog for my wife. I've been a programmer for 15 years or so, but I have always avoided file upload due to fear of the security risks. I want to allow guests at my wife's website to upload photos. I have done a lot of research, but I can't really find a solution that takes away the anxiety. I've looked into a few cdn's such as cloudshare and amazon s3, but their services seem like overkill for just wanting to be able to display pictures for her blog. I'm just curious if anyone has any suggested routes, tutorials, or personal experiences. It seems most sites offer image uploads, I feel like it shouldn't be that complicated in 2019. The link below seems to make the most sense, but I haven't found a whole lot like it, and that was written four years ago. I host all my clients on subdomains, and most of my work is geared towards inventory which is why I have stayed away from file uploads. https://paragonie.com/blog/2015/10/how-securely-allow-users-upload-files This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=359241.0 Hi.. Im generating daily reports for employees I have to give PRINT AND SAVE AS PDF button ..how to implement this.. Any code for this in php Thanx in Advance Hello PHPFreaks, I am busy with creating a search script that will search the database. I got it working so far but i want it to search for not only one thing but several things so actually make options in the form that you you choose only to search on name or only on address. How do i do this? The PHP code: Code: [Select] <?php mysql_connect ("localhost", "username","password") or die (mysql_error()); mysql_select_db ("database table"); $term = $_POST['term']; $sql = mysql_query("select * from databasetable where naam like '%$term%'"); while ($row = mysql_fetch_array($sql)){ echo "<center>"; echo "<table width='600px'>"; echo "<tr>"; echo "<td><b>Naam:</b> </td><td>".$row['naam']; echo "</td><td><b>Telefoon:</b> </td><td>".$row['telefoon']; echo "</td></tr><tr>"; echo "<tr>"; echo "<td><b>Adres:</b> </td><td>".$row['adres']; echo "</td><td><b>Mobiel:</b> </td><td>".$row['mobiel']; echo "</td></tr><tr>"; echo "<tr>"; echo "<td><b>Postcode:</b> </td><td>".$row['postcode']; echo "</td><td><b>E-mail:</b> </td><td>".$row['email']; echo "</td></tr><tr>"; echo "<tr>"; echo "<td><b>Woonplaats:</b> </td><td>".$row['woonplaats']; echo "</td></tr>"; echo "</table>"; echo "<br /><br />"; echo "<table width='400px'>"; echo "<tr>"; echo "<td><b>Datum:</b> </td><td>".$row['datum']; echo "</td></tr><tr><td><b>Probleem:</b> </td><td>".$row['probleem']; echo "</td></tr><tr>"; echo "<td><b>Mogelijke oplossing:</b> </td><td>".$row['oplossing1']; echo "</td></tr><tr><td><b>Oplossing:</b> </td><td>".$row['oplossing2']; echo "</td></tr><tr>"; echo "<td><b>Wachtwoord:</b> </td><td>".$row['wachtwoord']; echo "</td><tr><td><b>Geschatte Prijs:</b> </td><td>".$row['prijs']; echo "</td></tr><tr>"; echo "<td><b>Bijgeleverd:</b> </td><td>".$row['bijgeleverd']; echo "</td></tr>"; echo "</table><br />"; echo "---------------------------------------------------------------------------------------"; echo "</center>"; echo "<br/><br/>"; } ?> HTML Form: Code: [Select] <form action="search.php" method="post"> <b>RMA Zoeken:</b><br /> <input type="text" name="term" /><br /><br /> <input type="submit" class="art-button" name="submit" value="Submit" /> </form> Is this a mistake in the documentation? I am running PHP7.4 and get warning: unserialize() expects parameter 2 to be array, bool given. QuoteEither an array of class names which should be accepted, false to accept no classes, or true to accept all classes. If this option is defined and unserialize() encounters an object of a class that isn't to be accepted, then the object will be instantiated as __PHP_Incomplete_Class instead. Omitting this option is the same as defining it as true: PHP will attempt to instantiate objects of any class.
I've been working on JSON and have found a way to send variables from the PHP to the JavaScript using AJAX and no JQuery. For an ecommerce site does it make more sense to send the variables : description, title, cost, etc. to the JavaScript page, or would it make more sense to echo the html on the PHP page? The idea, right now, is a product page for editing and deleting product. Thanks, Josh Edited December 22, 2020 by JoshEirThis topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=320482.0 Okay so I'm trying to come up with as many alternative methods to accomplish something. So I'm just seeking input from anyone who is willing to supply some. After the user clicks on a match type it'll know HOW MANY sides to the match there are so say for a singles match it'd have 2 sides (1 vs. 1) for a Triple Threat Match it'd have 3 sides (1 vs. 1 vs. 1) and so on. All matches have a stored field in the database of how many sides they have. So I'm thinking that I could have it create 3 divs (or something) down in the competitors area of how many sides there are in the match (separated by a VS. text block) and when the user selects a character from the dropdown and adds a character the user can maybe drag and drop the character's name to whatever side they choose. Its one idea. If you think of an EASIER more EFFICIENT way to do something like this and have an idea say something please or even if you can't let me know that you think it's a worth while idea. Code: [Select] <label for="matchtypedrop<?php echo $i+1 ?>">Match Type:</label> <select class="dropdown" name="matchtypedrop<?php echo $i+1 ?>" id="matchtypedrop<?php echo $i+1 ?>" title="Match Type <?php echo $i+1 ?>"> <option value="0">- Select -</option> <?php $query = 'SELECT id, matchtype FROM matchtypes'; $result = mysqli_query ( $dbc, $query ); // Run The Query while ( $row = mysqli_fetch_array ( $result, MYSQL_ASSOC ) ) { print "<option value=\"".$row['id']."\">".$row['matchtype']."</option>\r"; } ?> </select> <label for="competitors<?php echo $i+1 ?>">Competitors:</label><ul id="competitors<?php echo $i+1 ?>" style="list-style: none; margin-left: 195px;"></ul> <select class="dropdown" name="charactersdrop<?php echo $i+1 ?>" id="charactersdrop<?php echo $i+1 ?>" title="Characters Dropdown <?php echo $i+1 ?>" style="margin-left: 195px;"> <option value="0">- Select -</option> <?php $query = 'SELECT id, `character` FROM characters ORDER BY `character`'; $result = mysqli_query ( $dbc, $query ); // Run The Query while ( $row = mysqli_fetch_array ( $result, MYSQL_ASSOC ) ) { print "<option value=\"".$row['id']."\">".$row['character']."</option>\r"; } ?> </select> <input type="button" value="Add Character" class="" onclick="Competitors(<?php echo $i+1 ?>)"/> This would seem like a simple question, but I can't seem to find the answer anywhere. Perhaps I'm asking it wrong. What I'd like to do is add a hash of optional arguments for a function. For example, I might have a function that has two required arguments, and three optional arguments. The only way I know to design this function is to put the arguments in a specific order, and fill them out to the degree needed. So if the 5th argument needs to be called, but the 3rd and 4th don't, you'd still have to give them values. function example($arg1, $arg2, $arg3, $arg4, $arg5) Must be used by: example('red', 'horse', '', '', 'texas'); Is there anyway of designing a function to only use the specified arguments? example('red', 'horse', ['arg5: texas']); I've been banging my head against the keyboard trying to figure this out. This is the first time I've used PHP so I'm sure I'm just doing something wrong. The API response that's relevant looks like this: //returns a list of pet records <xs:complexType name="petfinderPetRecordList"> <xs:sequence> <xs:element name="pet" type="petfinderPetRecord" minOccurs="0" maxOccurs="unbounded"/> </xs:sequence> </xs:complexType> //pet record <xs:complexType name="petfinderPetRecord"> <xs:sequence> <xs:element name="id" type="petIdType"/> <xs:element name="shelterId" type="shelterIdType"/> <xs:element name="shelterPetId" type="xs:string" minOccurs="0"/> <xs:element name="name" type="xs:string"/> <xs:element name="animal" type="animalType"/> <xs:element name="breeds" type="petfinderBreedList"/> <xs:element name="mix"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:enumeration value="yes"/> <xs:enumeration value="no"/> </xs:restriction> </xs:simpleType> </xs:element> <xs:element name="age" type="petAgeType"/> <xs:element name="sex" type="petGenderType"/> <xs:element name="size" type="petSizeType"/> <xs:element name="options"> <xs:complexType> <xs:sequence> <xs:element name="option" type="petOptionType" minOccurs="0" maxOccurs="unbounded"/> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="description" type="xs:string"/> <xs:element name="lastUpdate" type="xs:dateTime"/> <xs:element name="status" type="petStatusType"/> <xs:element name="media"> <xs:complexType> <xs:sequence> <xs:element name="photos" minOccurs="0"> <xs:complexType> <xs:sequence> <xs:element name="photo" type="petPhotoType" minOccurs="0" maxOccurs="15"/> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="contact" type="petContactType" minOccurs="0"/> </xs:sequence> </xs:complexType> //options <xs:simpleType name="petOptionType"> <xs:restriction base="xs:string"> <xs:enumeration value="specialNeeds"/> <xs:enumeration value="noDogs"/> <xs:enumeration value="noCats"/> <xs:enumeration value="noKids"/> <xs:enumeration value="noClaws"/> <xs:enumeration value="hasShots"/> <xs:enumeration value="housebroken"/> <xs:enumeration value="altered"/> </xs:restriction> </xs:simpleType> I want to get the options applicable for that pet. Here's a code snip: $xml = new SimpleXMLElement($xmlResponse); $i=0; foreach($xml->pets->pet as $pet) { $data[$i]['id'] = (string)$pet->id; $data[$i]['name'] = (string)$pet->name; $o=0; foreach($pet->options->option as $option) { $data[$i]['option'][$o] = (string)$option; $o++; } $i++; } ... Name: <?php echo $data[$i]['name'];?><br/> //This works Number of options: <?php echo count($data[$i]['option']);?><br/> //Only returns 1 if the last option (altered) is true, otherwise returns 0. The weird thing is that I can get the options no problem calling pet.get which returns a single petfinderPetRecord. Code snip of that looks like: $o=0; foreach($xml->pet->options->option as $option) { $data['option'][$o] = (string)$option; $o++; } ... Number of options: <?php echo count($data['option']);?><br/> Anyway, sorry to bug, I just have no idea where else to turn. I'm sure it has to be me, because I've seen other sites display the options - such as http://www.petfinder.com/fpm/petlist/petlist.cgi?shelter=NS36&status=A&age=&limit=25&offset=0&animal=Dog&title=&style=10&ref=1I_sKmt3BFyiiTz (no dogs, no kids, etc) In case it helps the API docs are he http://www.petfinder.com/developers/api-docs and the schemas are he http://api.petfinder.com/schemas/0.9/petfinder.xsd I am trying to create a dynamic table that gets generated based upon users selection of last name (via a select menu) as well as the ability to filter all the table contents between two ages. Additionally, I would like the ability to select all last names between two ages as well. Each item I would hope to have a onchange command. Thanks in advance for any help on the above items. Here is the main php code <?php $con = mysql_connect('localhost', 'root', ''); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("test", $con); $lastname_result = mysql_query("SELECT lastname FROM user GROUP BY lastname"); $result = mysql_query("SELECT * FROM user"); ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link href="../themes/style.css" rel="stylesheet" type="text/css" media="print, projection, screen" /></link> <link href="../common.css" rel="stylesheet" type="text/css"></link> </head> <body> <table width="100%" border="0" cellspacing="0" cellpadding="5" class="main"> <tr> <td width="160" valign="top"></td> <td width="732" valign="top"> <table width="90%" border="0" align="center"> <form action="test3.php" method="post"> <select name="area" onchange="submit"> <option value="">Select an lastname</option> <option value=""></option> <?php while(list($lastname)=mysql_fetch_array($lastname_result)) { echo "<option value='$lastname'>$lastname</option>"; }?> </select> <label for="startage">From</label> <input type="text" id="from" name="from"/> <label for="endage">to</label> <input type="text" id="to" name="to"/> <input type="submit" name="Submit" value="Refresh" /> </form> </table> <table id="tablesorter" class="tablesorter" border="0" cellpadding="0" cellspacing="1"> <thead> <tr> <th>First Name</th> <th>Last Name</th> <th>Age</th> <th>Hometown</th> <th>Job</th> </tr> </thead> <tbody> <?php while($row=mysql_fetch_assoc($result)){ ?> <tr> <td><?php echo $row['firstname']; ?></td> <td><?php echo $row['lastname']; ?></td> <td><?php echo $row['age']; ?></td> <td><?php echo $row['hometown']; ?></td> <td><?php echo $row['job']; ?></td> </tr> <?php } // End while loop. ?> </tbody> </table> <p> </p> <p> </p> <p align="right"> </p></td> <td width="196" valign="top"> </td> </tr> </table> </body> </html> and here is the sql code to generate a test database. Code: [Select] CREATE DATABASE /*!32312 IF NOT EXISTS*/`test` /*!40100 DEFAULT CHARACTER SET latin1 */; DROP TABLE IF EXISTS `user`; CREATE TABLE `user` ( `id` int(11) NOT NULL AUTO_INCREMENT, `firstname` varchar(20) NOT NULL, `lastname` varchar(20) NOT NULL, `age` int(3) NOT NULL, `hometown` varchar(25) NOT NULL, `job` varchar(25) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM AUTO_INCREMENT=7 DEFAULT CHARSET=latin1; /*Data for the table `user` */ insert into `user`(`id`,`firstname`,`lastname`,`age`,`hometown`,`job`) values (1,'Peter','Griffin',41,'Quahog','Brewery'), (2,'Lois','Griffin',40,'Newport','Piano Teacher'), (3,'Joseph','Swanson',39,'Quahog','Police Officer'), (4,'Glenn','Quagmire',41,'Quahog','Pilot'), (5,'Megan','Griffin',16,'Quahog','Student'), (6,'Stewie','Griffin',2,'Quahog','Dictator'); |