Jump to content

tascam424

Members
  • Posts

    29
  • Joined

  • Last visited

Everything posted by tascam424

  1. I have a lot of learning to do and i think this could be a great way to push to learn. Just getting the correct direction and start point is what i need. Your response is extremely valuable. Thank you so much.
  2. Hi folks, i'm Jonny, very amateur coder on the learning path. I have inherited a web script that fails on anything above php 7.4, creating lots of 500 errors. Although it works i WAMP localhost on PHP 8.0.26 it will not function correctly on any live server above php 7.4 (this has been reported by many users across different hosting providers. So as it is no longer supported by the developer, i am going to attempt to make it compatible. My question to the community is, is there any kind of programmes that will assist me in doing so ? Maybe something that will find deprecated code and suggest a better way of coding for forward compatibility ? I look forward to hearing your thoughts and suggestions.
  3. I'm trying to out put all Crelly Slider Alias's within Redux Framework Options in a Dropdown Select. I must confess i'm a novice at PHP ... I've attached the code from within Crelly Slider to show how it outputs the Alias names and i've also attached the Redux Code for the dropdown with an existing select .. I somehow need to output a list of all Crelly Alias's into 'options' => array( 'asc' => 'Ascending', 'desc' => 'Descending' ), Obviously replacing the exisiting options. Here is the full Crelly Output <?php global $wpdb; $sliders = $wpdb->get_results('SELECT * FROM ' . $wpdb->prefix . 'crellyslider_sliders'); if(!$sliders) { echo '<div class="cs-no-sliders">'; _e('No Sliders found. Please add a new one.', 'crellyslider'); echo '</div>'; echo '<br /><br />'; } else { ?> <table class="cs-sliders-list cs-table"> <thead> <tr> <th colspan="5"><?php _e('Sliders List', 'crellyslider'); ?></th> </tr> </thead> <tbody> <tr class="cs-table-header"> <td><?php _e('ID', 'crellyslider'); ?></td> <td><?php _e('Name', 'crellyslider'); ?></td> <td><?php _e('Alias', 'crellyslider'); ?></td> <td><?php _e('Shortcode', 'crellyslider'); ?></td> <td><?php _e('Actions', 'crellyslider'); ?></td> </tr> <?php foreach($sliders as $slider) { echo '<tr>'; echo '<td>' . $slider->id . '</td>'; echo '<td><a href="?page=crellyslider&view=edit&id=' . $slider->id . '">' . $slider->name . '</a></td>'; echo '<td>' . $slider->alias . '</td>'; echo '<td>[crellyslider alias="' . $slider->alias . '"]</td>'; echo '<td> <a class="cs-edit-slider cs-button cs-button cs-is-success" href="?page=crellyslider&view=edit&id=' . $slider->id . '">' . __('Edit Slider', 'crellyslider') . '</a> <a class="cs-delete-slider cs-button cs-button cs-is-danger" href="javascript:void(0)" data-delete="' . $slider->id . '">' . __('Delete Slider', 'crellyslider') . '</a> </td>'; echo '</tr>'; } ?> </tbody> </table> <?php } ?> <br /> <a class="cs-button cs-is-primary cs-add-slider" href="?page=crellyslider&view=add"><?php _e('Add Slider', 'crellyslider'); ?></a> And my Redux Option array( 'id' => 'alias_select', 'type' => 'select', 'title' => __( 'Alias Select', 'ultra-web-admin' ), 'desc' => __( 'Select Slider Alias.', 'ultra-web-admin' ), 'options' => array( 'asc' => 'Ascending', 'desc' => 'Descending' ), 'default' => 'asc' ), I would be really grateful if anyone could assist me . Thank you !
  4. Greatly appreciated ! I'm just learning all this and a point in the right direction is much more valuable than somebody pasting a code snippet. Nice to know i got it right too .. Thanks a lot !!
  5. Thanks for pointing me in the correct direction .. So i worked out a solution, but baring in mind i am an absolute newb, would you mind telling me if this is the cleanest way to achieve what i want. It works perfectly ! <?php $categories = get_the_category(); $category_names = array(); foreach ($categories as $category) { $category_names[] = $category->cat_name; } echo implode (',', $category_names); ?>
  6. Hi guys, i'm attempting to display Wordpress Categories per Post. I'm aware of this simple standard method <?php the_category( ', ' ); ?>. But i actually just want a list of the categories, unformatted and unlinked to the category itself, actually i just want the category name. So i am using this method <?php foreach((get_the_category()) as $category) { echo $category->cat_name . ' '; } ?> This works perfectly if the post only has 1 category, but in the event of multiple categories, there is no separator. Could anybody assist me in adding a separator which will not append to the last in the list ? I would be grateful for any assistance but please bare in mind i am a mere novice. Thanks
  7. Hi guys, i'm hoping someone can point me in the right direction here. I'm importing products into WooCommerce using WP All Import through a XML feed. I need a way to get certain data from the category field, which looks like this .. <range category='Cars'>Cars </range><range category='Vans'>Vans </range><range category='Lorries'>Lorries </range> I need to somehow convert this to Cars, Vans, Lorries I'm not really sure how to approach this, any help would be greatly appreciated.
  8. Ahhhh ok, i totally miss-understood .. I am just trying to learn php, as i'm sure you could tell. Thank you very much for your help, it is greatly appreciated !!
  9. Yeh i have been reading the manual, which is how i got this far. Ive also been looking at other functions to try and understand how they can be combined. I tried this function other_checkstr($x){ str_replace("Large","",$x); if(strpos($x,'-')==FALSE){ return trim(substr(strrchr($x, ' '), 1 )); }else{ return trim(substr($x,0, strpos($x,'-')),'-'); } } The function runs the second part successfully as required, but the str_replace has no effect.
  10. So i somehow need to combine this function other_checkstr($x){ if(strpos($x,'-')==FALSE){ return trim(substr(strrchr($x, ' '), 1 )); }else{ return trim(substr($x,0, strpos($x,'-')),'-'); } } and this str_replace("Large","","$x"); Ive tried multiple combinations, but i can't seem to get it to work. Can anybody help me please ? Thank you !
  11. I appreciate your response, but i would be really greatfull if you could help me further, i really have no idea how to contain it within my existing function.
  12. Thanks guys, this is now working for me, but i need to add to it do also remove the word "Large" from the start of the string, it is consistantly the first word in the string and it is the same word always. What would be the best way to add it to this function to do both. function other_checkstr($x){ if(strpos($x,'-')==FALSE){ return trim(substr(strrchr($x, ' '), 1 )); }else{ return trim(substr($x,0, strpos($x,'-')),'-'); } }
  13. Apparently it is !! Now i feel a little stupid ! Thank you both for your help !
  14. Well i can do that and that seems like the perfect option but is it as simple as renaming the function like so ? function this_is_my_other_checkstr($x){ if(strpos($x,',')==FALSE){ return trim(substr(strrchr($x, ' '), 1 )); }else{ return trim(substr($x, 0, strpos($x,',')),','); } } Thanks for your input !
  15. I should probably provide more information, i am using WP All Import to import a product csv. The Product titles appear like so : Crossover Crop Top In Burgundy, Burgundy So my first function allows me to extract "Burgundy" from the end to use as Category/Color My second function should strip ",Burgundy" from the end to leave me Crossover Crop Top In Burgundy to use as Product Title. As these are pulled into different fields i can use the same column name with multiple functions, unfortunately it would appear that i can't declare the same function twice in function.php.
  16. Thanks for your reply, i haven't been able to test it because i am already using the other function so i get an error Fatal error: Cannot redeclare checkstr() (previously declared in what would be the best way to achieve what i need .. i actually need to be able to call the 2 functions seperately .. here is what i have at the moment, which obviously causes the error. /** * Get Color From Title */ function checkstr($x){ if(strpos($x,',')==FALSE){ return trim(substr(strrchr($x, ' '), 1 )); }else{ return trim(substr($x, strpos($x,',')),','); } } /** * Remove Color From Title */ function checkstr($x){ if(strpos($x,',')==FALSE){ return trim(substr(strrchr($x, ' '), 1 )); }else{ return trim(substr($x, 0, strpos($x,',')),','); } }
  17. Hi i'm trying to edit a WP Custom function but i'm stumped. I'm using the following function currently to remove everything in a string up to and including "," Is it possible to edit it to remove everything AFTER and including "," Or is there a better alternative ? function checkstr($x){ if(strpos($x,',')==FALSE){ return trim(substr(strrchr($x, ' '), 1 )); }else{ return trim(substr($x, strpos($x,',')),','); } }
  18. Have you ever been told how wonderful you are ? Thank you so very much !! Worked perfectly just by adding that to the little piece of script. Is it necessary to do that when calling a script library also ? Like this <script type="text/javascript" src="templates/Custom/js/jquery.cslider.js"></script> It wasn't required in this circumstance but it it best practice ? Thank you again !!
  19. Hi folks, i'm trying desperately to convert an HTML template to a Smarty Template for WHMCS, everything is going fine except i can't get the Parallax Slider to function. It works perfectly in the standard HTML Template but won't work in the Smarty Template, so i'm guessing some of the core WHMCS scripting must be conflicting. The only thing i can see is Uncaught SyntaxError: Unexpected token ) ultrawebtemplates.com/ :94 Lines 94 - 106 look like this <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> <script type="text/javascript" src="templates/Custom/js/jquery.cslider.js"></script> <script type="text/javascript"> $(function() { $('#da-slider').cslider({ autoplay : true, bgincrement : 450 }); }); </script> Off course if anybody would care to look you can see the live domain http://ultrawebtemplates.com Greatly appreciate any help.
  20. Thanks for that .. Any direction on how i tie the dropdown value into the SELECT ? I am a total novice !!
  21. So i'm running a fairly simple myslqi select like so : $result = mysqli_query($con,"SELECT DISTINCT DiscNo, Description FROM cdg ORDER BY DiscNo"); What i would like to do is alter it slightly to add in a WHERE clause where Description CONTAINS the value from a drop down. So basically the first thing i need is a mysqli_query like so : $result = mysqli_query($con,"SELECT DISTINCT Description FROM cdg ORDER BY Description"); But i need the results of this to display in a DropDown list, then based on the selection, propogate my first query like this : $result = mysqli_query($con,"SELECT DISTINCT DiscNo, Description FROM cdg WHERE Description CONTAINS (dropdownselectvalue) ORDER BY DiscNo"); I hope this makes sense, i kinda know what i want to do, but i just don't know how to do it .. Any help would be greatly apreciated !
  22. Ahhh ok .. that makes things alot simpler, i was unaware ot that .. thank you very much !!
  23. Thanks for that !! Everything is starting to look fuzzy lol
  24. I am trying desperately to add checkbox names to a table on my database, i've read loads of tutorials and haven't really gotten very far. Here is my code <script language="JavaScript"> function toggle(source) { checkboxes = document.getElementsByTagName('input'); for(var i=0, n=checkboxes.length;i<n;i++) { checkboxes[i].checked = source.checked; } } </script> <?php $con=mysqli_connect("localhost","kslc_admin","password","kslc_cdg"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } $result = mysqli_query($con,"SELECT DISTINCT DiscNo, Description FROM CDG ORDER BY DiscNo"); echo "<td><input type=\"checkbox\" onClick=\"toggle(this)\" /> Toggle All<br/></td>"; echo "<form action=\"post.php\" method=\"post \" />"; echo "<table> <tr> <th>Tag</th> <th>Description</th> <th>DiscNo</th> <th>View Songs</th> </tr>"; while($row = mysqli_fetch_array($result)) { echo "<tr>"; echo "<td><input type=\"checkbox\" name=". $row["DiscNo"] ." id=\"checkbox\"></td>"; echo "<td>" . $row['Description'] . "</td>"; echo "<td>" . $row['DiscNo'] . "</td>"; echo "<td>" . $row['TrackNo'] . "</td>"; echo "<td><a href=\"tracks.php?DiscNo=" . $row["DiscNo"] . "\">View Tracks</a></td>"; echo "</tr>"; } echo "</table>"; echo "<input type=\"submit\" name=\"submit\" value=\"Submit \" />"; echo "</form>"; mysqli_close($con); ?> Now i don't know if this is even in the right direction but ive been trying to pass the checkbox names to post.php and somehow retrieve them and run a function to add to db table. Not sure how to achieve this or even if this is the correct way to go about it .. So far when i hit submit the URL looks like this http://mydomain.com/post.php?SF001=on&SF161=on&SF179=on&submit=Submit+ Where SF001, SF161 & SF179 are the correct checkbox names of selected checkboxes. So it is possible to retrieve these in post.php and somehow add them to database ? Really appreciate any help .. Thanks
  25. Thank you ever so much, that does the trick !!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.