PHP - Moved: Php Toggle Code Similar To Javascript Toggle Div Script
This topic has been moved to JavaScript Help.
http://www.phpfreaks.com/forums/index.php?topic=310618.0 Similar TutorialsThis topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=348953.0 I'm trying to show my data under the toggle button according to the order_id. But i do not know why when i click on my toggle button it does not work. I do not know what is wrong with it. Any advice will be appreciated. <?php $dsql = "SELECT o.order_id , o.purchase_price , o.order_datetime, u.id, u.user_fullname , p.id, p.product_title , c.id , c.category, s.id , s.seller_fullname FROM ordered_items o INNER JOIN users u ON o.user_id = u.id INNER JOIN sellers s ON o.seller_id = s.id INNER JOIN products p ON o.product_id = p.id CROSS JOIN category c ON p.product_category = c.id WHERE category = '".$category."' ORDER BY o.order_id DESC"; $dquery = $conn->query($dsql); $tot_orders = mysqli_num_rows($dquery); if (!mysqli_num_rows($dquery)) { echo ' <div class="col-12"> <div class="badge badge-danger">No Orders Found</div> </div> '; } else { while ($drow = $dquery->fetch_assoc()) { ?> <tr> <td> #<?php echo $drow['order_id']; ?> </td> <td> <?php echo $drow['user_fullname']; ?> </td> <td> RM<?php echo number_format($drow['purchase_price'],2); ?> </td> <td class="text-center"> <a style="text-decoration: none;color: #000;" title="View Details" data-toggle="collapse" data-target="#products-details<?php echo $drow['order_id']; ?>"> <i class="nc-icon nc-minimal-down" onclick="changeToggleIcon(this)"></i> </a> </td> </td> </tr> <?php $p_sql = "SELECT o.order_id , o.purchase_price , o.order_datetime , o.quantity , o.quantity_unit, u.id, u.user_fullname , p.id, p.product_title , p.product_photo , c.id , c.category, s.id , s.seller_fullname FROM ordered_items o INNER JOIN users u ON o.user_id = u.id INNER JOIN sellers s ON o.seller_id = s.id INNER JOIN products p ON o.product_id = p.id CROSS JOIN category c ON p.product_category = c.id WHERE category = '".$category."'" ; $p_query = $conn->query($p_sql); while ($p_row = $p_query->fetch_assoc()) { ?> <tr class="collapse" id="products-details<?php echo $drow['order_id']; ?>" > <td style="border-top: none; font-size: 10px;"> <img src="https://dev.gopasar.today/images/product-main/<?php echo $p_row['product_photo']; ?>" style="height: 50px; width: 50px;"> </td> <th style="border-top: none; font-size: 10px;"> <?php echo $p_row['product_title']; ?> </th> <th style="border-top: none; font-size: 10px;"> Order Quantity :<?php echo $p_row['quantity']; ?><?php echo $p_row['quantity_unit']; ?> </th> <th style="border-top: none; font-size: 10px;"> RM <?php echo $p_row['purchase_price'];?> </th> </tr> </div> </div> </div> <?php } } } ?>
Hi. I am looking for a way to have a button that toggles the background colour of my website. So for instance, I will have one button called 'switch to light', when its clicked it switches the colour of the background to a light colour, and another button replaces this that says 'switch to dark', and so on. I have turned to PHP because it appears to be the only way I would be able to have the change saved throughout the site, when pages are refreshed. However, I am a complete newbie, so have no idea what to do! Anyone that can help is a life saver! Thanks Hi All, I have a page where people can enter the name of food, like you would order in a restaurant (would appear on the menu). They can set if the food is gluten free, nut free, vegan etc. I am wanting to use buttons that can be clicked going red if they are not gluten free or not vegetarian and green if they are vegan or vegetarian. I have working code that does this but i dont feel like i am being efficient with how i am writing it as it is turning into a lot of repeated code. I would appreciate some help pointing me in the right direction. function popManageMenuModal($conn, $miid){ $stmt = $conn -> prepare(' SELECT menu_item_name, menu_item_is_vegan, menu_item_is_vegitarian, menu_item_is_gf, menu_item_is_nf, menu_item_is_df FROM ssm_menu_items WHERE menu_item_id = ? '); $stmt -> bind_param('i', $miid); $stmt -> execute(); $stmt -> bind_result($miname, $miisvegan, $miisveg, $miisgf, $miisnf, $miisdf); $stmt -> fetch(); if($miisvegan == '1'){ $vegansel = 'btn-success'; $vegan = 'Vegan'; $veganop = 'Is'; }else{ $vegansel = 'btn-danger'; $vegan = 'Vegan'; $veganop = 'Not'; } if($miisveg == '1'){ $vegsel = 'btn-success'; $vegi = 'Vegi'; $vegop = 'Is'; }else{ $vegsel = 'btn-danger'; $vegi = 'Vegi'; $vegop = 'Not'; } $output = ""; $output .= "<form><div class='form-group'><label>Menu Item Name</label><textarea class='form-control'>$miname</textarea></div>"; $output .= "<div class='form-inline'>"; $output .= "<div class='drButton btn $vegansel' data-value='$miisvegan'>{$veganop} {$vegan}</div>"; $output .= "<div class='drButton btn $vegsel' data-value='$miisveg'>{$vegop} {$vegi}</div>"; $output .= "<div>$miisvegan, $miisveg, $miisgf, $miisnf, $miisdf</div>"; $output .= "</form>"; return $output; } $(document).on('click','.drButton', function(){ var polarity = $(this).data("value") if(polarity == '0'){ $(this).addClass("btn-success") $(this).removeClass("btn-danger") $(this).data("value", '1') return } if (polarity == '1'){ $(this).addClass("btn-danger") $(this).removeClass("btn-success") $(this).data("value", '0') return } });
Hello all, This topic has been moved to HTML Help. http://www.phpfreaks.com/forums/index.php?topic=350182.0 This topic has been moved to Other Programming Languages. http://www.phpfreaks.com/forums/index.php?topic=312147.0 I have the following code in html: <html> <head> <script type="text/javascript"> <!-- function delayer(){ window.location = "http://VARIABLEVALUE.mysite.com" } //--> </script> <title>Redirecting ...</title> </head> <body onLoad="setTimeout('delayer()', 1000)"> <script type="text/javascript"> var sc_project=71304545; var sc_invisible=1; var sc_security="9c433fretre"; </script> <script type="text/javascript" src="http://www.statcounter.com/counter/counter.js"></script><noscript> <div class="statcounter"><a title="vBulletin statistics" href="http://statcounter.com/vbulletin/" target="_blank"><img class="statcounter" src="http://c.statcounter.com/71304545/0/9c433fretre/1/" alt="vBulletin statistics" ></a></div></noscript> </body> </html> Is a basic html webpage with a timer redirect script and a stascounter code. I know a bit about html and javascript, but almost nothing about php. My question is: How a can convert this html code into a php file, in order to send a variable value using GET Method and display this variable value inside the javascript code where says VARIABLEVALUE. Thanks in adavance for your help. im trying to run a query which will get posts from the database that have tags similar to the current ones. Unfortunatly the echoed result isnt displaying as it should. $query = $link->query("SELECT t.*, p.* FROM ".TBL_PREFIX."topics t JOIN ".TBL_PREFIX."posts p ON (p.p_tid = t.t_tid) WHERE t.t_name = '".decode_url($_GET['t_name'])."' LIMIT 1") or die(print_link_error()); $row = $query->fetch(PDO::FETCH_ASSOC); $tag_query = $link->query("SELECT p_name FROM ".TBL_PREFIX."posts WHERE MATCH (p_tags) AGAINST ('".$row['p_tags']."' IN BOOLEAN MODE) ")or die(print_link_error()); $result = $tag_query->fetch(); foreach($result as $key => $value) { echo 'Name = '.$result[$key]['p_name'].'<br />'; } i have done a dump of result and it shows: Code: [Select] $ => Array (2) ( ['p_name'] = String(12) "File Updates" ['0'] = String(12) "File Updates" ) but there should only be one item in this array(p_name). I dont know where the second is coming from. The query has pulled the right results, it just isnt displaying it right. I'm pretty sure there isn't, but I was wondering if there was a php function that would return partial matches similar to MySQL's LIKE, I've been searching for a while and haven't found one. If not, is there a class or something that someone knows of that will accomplish a like of search or a string comparison? I want to be able to compare two variables and return one of three results - Exact Match, Partial Match, No Match. I suppose regex may do the trick but I'm a complete novice when it comes to regex and I have no idea where to even begin. Thanks for any suggestions. How can I check if an array contains two items that are the same? For example ("apples", "bananas", "oranges") returns false But ("apples", "bananas", "bananas") returns true Hello, I am looking for a push in the right direction. I would like to be able to view a website that is duplicated on many servers by specifying the IP address. Similar to how one would use the hosts file. I can do this using netcat nc 1.2.3.4 80 Host: example.com GET /contact-us.html <CR><CR> Can someone tell me how I would go about porting this to PHP? I would just like to set up a small page on my webserver where I can enter the domain and IP address and have the page displayed back to me. Thanks Colin hi My first language is not english so i hope you bear it i am new to php am am making my shopping Cart as my web engineering course i have made everything i all want to know how to i show similar products when a user click on any product details it open new page and shows a detail of that page i want to show similar products list below to details so can any tell me how to do it plzz kindly see the pic in atttachment i have posted snap shop of my page i put similar product statically i want to show it dynamically from tha data base kindly answer please regards This topic has been moved to PHP Freelancing. http://www.phpfreaks.com/forums/index.php?topic=348869.0 How to COUNT the number of records (pulled from a db)which contains the word "APPROVED". This code doesn't work though. $result1; $result2; $result3; $approvedApplicants = COUNT($result1=='Approved', $result2=='Approved', $result3=='Approved') echo ($approvedApplicants) are all of the following same, or some same or all different: $variable="" $variable=0 $variable=NULL and which of the above will satisfy if(empty($variable)) { blah!; } Hi Folks, i have been at this for ages and its now depressing me as i cannot figure out why i cant get it to work. I am using a re-hashed version of a facebook style wall post system where it limits the amount of replies, you click a button and gets the next set and so on until there are no more results to get. The original script runs ok but is not really suitable for what i need So to my script which is based loosley on the same principal. Ok i have a veiwmember.php page which uses pagination to limit the amount of wall posts to 5. I have included the various javascript files jquery and another which is needed. The function used is this one: Code: [Select] <script type="text/javascript" src="jquery.livequery.js"></script> <script type="text/javascript" src="jquery-1.2.6.min.js"></script> <script type="text/javascript"> //more records show $('a.more_records').livequery("click", function(e){ var next = $(this).attr('id').replace('more_',''); $.post("data.php?show_more_post="+next, { }, function(response){ $('#bottomMoreButton').remove(); $('#posting').append($(response).fadeIn('slow')); }); }); </script> The php code in veiwmember.php that gets the wall posts is: Code: [Select] Pagination code here <?php $getwallposts= ("SELECT * FROM wallposts WHERE recipientid='$memberid' ORDER BY id DESC LIMIT $offset, $rowsperpage"); $result = mysql_query($getwallposts,$con); while ($row2 = mysql_fetch_assoc($result)) { $messageid= $row2['id']; $senderid= $row2['senderid']; $wallpost= $row2['wallpost']; $timesent= $row2['timesent']; $timestamp = strtotime($timesent); $likes= $row2['likes']; $getname= ("SELECT fname, lname, image1 FROM memocp WHERE unid='$senderid'"); $nameresult= mysql_query($getname,$con); while ($rowws = mysql_fetch_array($nameresult)) { $fname= $rowws['fname']; $lname= $rowws['lname']; $wallpostprofilethumb= "{$rowws['image1']}"; if (empty($wallpostprofilethumb)) {$wallpostprofilethumb= "noimage.png";} } ?> <div class="wallpost"><div class="from"><div class"profilethumb"><img src="profilethumb/<?php echo $wallpostprofilethumb; ?>"></div><a href="veiwmember.php?membid=<?php echo "$senderid"; ?>"><?php echo "$fname $lname"; ?></a></div><div class="postbody"><?php echo txt2link($wallpost) ?><div class="timesent"><?php echo date('l jS F Y @ H:i a', $timestamp); ?></div></div><div class="likes"><form action="like.php" method="post"><?php if (isset($_GET['currentpage'])) {$currentpage= $_GET['currentpage']; echo "<input name=\"currentpage\" type=\"hidden\" value=\"$currentpage\">";} ?><input name="messageid" type="hidden" value="<?php echo "$messageid"; ?>"><input name="base" type="hidden" value="<?php echo "$memberid"; ?>"><input name="like" type="image" src="ima/like.jpg"><?php echo " $likes people like this"; ?></form></div></div> <?php include_once('data.php'); ?> <?php } rest of pagination The pagination sort of works, but only displays one result per page when it should show 5 results plus how ever many replies, but i can sort that out later, would prefer to get the replies working first. You will see that data.php is included which gets the replies to the wall posts. It should limit the amount of replies shown to five, and then if there is more, it will show a link to get more. If that link is clicked it should get the next five results and show them. However it shows the first five and the link if there are more results, but if the link is clicked, nothing happens. data.php Code: [Select] require ("database.php"); $next_records = 5; $show_more_button = 0; if(isset($_REQUEST['show_more_post'])) // more posting paging { // button has been clicked so we need to get next set of results $next_records = $_REQUEST['show_more_post'] + 5; $result = mysql_query("SELECT * FROM wallreplies2 WHERE messageid='$messageid' ORDER BY wallreplyid DESC limit ".$_REQUEST['show_more_post'].", 5"); // see if there are any more replies to get $check_res = mysql_query("SELECT * FROM wallreplies2 order by wallreplyid DESC limit ".$next_records.", 5"); $show_more_button = 0; // button in the end $check_result = mysql_num_rows($check_res); if($check_result > 0) { // if there any more results counted the button needs to be shown $show_more_button = 1; } } // if the button hasnt been clicked we need to get the first results else { // lets count the number of results that exist $countreplies= mysql_query("SELECT * FROM wallreplies2 WHERE messageid='$messageid'"); $countresult= mysql_num_rows($countreplies); // if there are more than 5 results if ($countresult > 5) { // the button needs to be shown $show_more_button = 1; } else { // if there are 5 or less replies in total, dont show the button $show_more_button = 0;} //there are only 5 or less replies to get so get the first results $result = mysql_query("SELECT * FROM wallreplies2 WHERE messageid='$messageid' ORDER BY wallreplyid DESC limit 0,5"); } //$replyresult = mysql_query($result,$con); while ($roww = mysql_fetch_array($result)) { $wallreplyid= $roww['wallreplyid']; $sendid= $roww['senderid']; $wallreply= $roww['wallreply']; $time= $roww['timesent']; $Timestamp = strtotime($time); $like= $roww['likes']; $getreplynames = ("SELECT fname, lname, image1 FROM memocp WHERE unid='$sendid'"); $nameresults = mysql_query($getreplynames,$con); while ($roww = mysql_fetch_array($nameresults)) { $fnames= $roww['fname']; $lnames= $roww['lname']; $wallreplyprofilethumb= "{$roww['image1']}"; if (empty($wallreplyprofilethumb)) {$wallreplyprofilethumb= "noimage.png";} } ?> <div class="wallreplies" id="record-<?php echo"$wallreplyid"; ?>"> <div class="wallreplywrap"> <div class="wallfrom"> <div class"profilethumb"><img src="profilethumb/<?php echo $wallreplyprofilethumb; ?>"></div> <a href="veiwmember.php?membid=<?php echo "$sendid"; ?>"><?php echo"$fnames $lnames"; ?></a> </div> <div class="wallmessbody"><?php echo txt2link($wallreply) ?></div> <div class="timesent"><?php echo date('l jS F Y @ H:i a', $Timestamp); ?></div> <div class="likes"><form action="like2.php" method="post"><?php if (isset($_GET['currentpage'])) {$currentpage= $_GET['currentpage']; echo "<input name=\"currentpage\" type=\"hidden\" value=\"$currentpage\">";} ?><input name="messageid" type="hidden" value="<?php echo "$wallreplyid"; ?>"><input name="base" type="hidden" value="<?php echo "$memberid"; ?>"><input name="like" type="image" src="ima/like2.jpg"><?php echo " $like people like this"; ?></form> </div> </div> </div> <?php } if($show_more_button == 1){ echo "<div class=\"bottomMoreButton\"> <a id=\"more_$next_records\" class=\"more_records\" href=\"javascript: void(0)\">Get more replies</a> </div>"; }?> <div class="wallreply"> <form action="wallreply.php" method="post"> <input name="sendrid" type="hidden" value="<?php echo "$loginuniqid"; ?>"> <input name="messageid" type="hidden" value="<?php echo "$messageid"; ?>"> <input name="base" type="hidden" value="<?php echo "$memberid"; ?>"> <?php if (isset($_GET['currentpage'])) {$currentpage= $_GET['currentpage']; echo "<input name=\"currentpage\" type=\"hidden\" value=\"$currentpage\">";} ?> <textarea class="newwallpostreply<?php echo $i++ ; ?>" name="wallreply" autocomplete="off" maxlength="1000" placeholder="Reply"></textarea> <span class="wallreply-holder<?php echo $p++; ?>"> <div class="button_block"> <input type="submit" class="post" value="Post"> <input type="submit" class="cancel" value="Cancel"> </div> </span> </form> </div> I know its a lot of info there, but if anyone can see the problem i would be greatful. I have a brain twister in a script i'm working on. It have a multidimensional array that hold values to populate a google charts js script. To make it work as I plan I need to merge the data from similar arrays together. I'll give an example and hopefully it will make more sense. Also, this page is being loaded over ajax so, the faster/smaller the better. Example Array: Code: [Select] Array ( [0] => Array ( [item] => 1 [quant] => 2 [price] => 12.5 [day] => 18 [onl] => ) [1] => Array ( [item] => 1 [quant] => 2 [price] => 12.5 [day] => 18 [onl] => ) [2] => Array ( [item] => 1 [quant] => 5 [price] => 12.5 [day] => 17 [onl] => 1 ) [3] => Array ( [item] => 1 [quant] => 12 [price] => 12.5 [day] => 19 [onl] => 1 ) [4] => Array ( [item] => 1 [quant] => 4 [price] => 12.5 [day] => 21 [onl] => ) ) So since array 0 and 1 both have data from sales on the 18th for the same item I would want to merge them into a single array and leave all others in the parent array the same. I apologize in advance if this doesn't make sense, I've been working too many hours. X| If anyone knows of a good solution for this or perhaps a better approach, that would be great. Thank You, E Hello, I need to be able to find what is inbetween 2 values in a string of text. For example, <?php $string="Hello and welcome to the site. Click [link]welcome.php[/link] here to continue to the site"; ?> So I need some method of searching the string to see what values are in between the [link] and [/link] which I will then deal with in my own way. I have a feeling that I could do this with explode, but I'm not really sure. Any advice? Thanks in advance This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=322839.0 |