Search the Community
Showing results for tags 'tables'.
-
Hi Freaks, the weekend is upon us again. I wish you all well. I have an issue I've been working on today and have hit a mental roadblock. Hoping someone with the time and will will talk me through it. I'm creating a table while looping through an API array and I've hit a couple snags. Here is the repeated HTML -> $html = " <tr class='mt-2'> <td>{$rank}.</td> <td><img src='{$image}' height='75' width='75'></td> <td>{$name}</td> <td class='bold'>\${$final_worth}B</td> <td class='{$class}'>\${$last_change}</td> <td>{$country}</td> <td>{$source}</td> <td><button class='bg-color-primary text-color-third px-2' id='more_btn' onclick='showDetails({$cnt})'>More</button></td> </tr> <tr > <div id='details'>lorem fucking ipsum wahoo baby</div> </tr> "; Everything was going as expected until I went to add the second row (div#details). There's actually 2 issues at play here - the first is how I make each button/div#details connected so button1 only effects div1 etc. I can't tackle that one yet though, because right now when any button is clicked div#details shows up above the table header rather than underneath the previous row. So until I have the positioning correct I can't really tackle the js functionality. Can someone please tell me why the <tr><div#details> is not appearing underneath it's previous row? The js code is as follows -> <script> var cnt = <?php echo $cnt; ?>; function showDetails(cnt) { var details = "details"; var x = document.getElementById(details); if (x.style.display === "none") { x.style.display = "block"; } else { x.style.display = "none"; } } </script> I know the code is a mess right now. It's kind of shameful lol but like I said I can't really do more with it until I can figure out why that table row isn't positioning properly
-
firstly, I am not a db programmer. I ply my trade in WordPress stuff, but not in-depth db structuring from scratch. please keep that in mind as I do my best to ask this question? I have made some headway creating two tables that I think will almost, kinda do what I want, which is: Phillips pid1Barnes pid2Moore pid3de Mohrenschildt pid4Oswald pid5 Hunt pid6Sturgis pid7Moore pid3 I've created a (really large) outline in html that simply shows, in effect: Phillips (knows) » Barnes (supervised) » Moore (supervised) » de Mohrenschildt (knows) » Oswald ... AS WELL AS, Phillips (knows) » Hunt (knows) » Sturgis (followed, who also knows) » Moore (same, pid3) ... I put Sturgis followed by Moore specifically to show that these relationships are in no way numerically sequential from the ASSOCS table. There will be 4 or 500 Persons, (and 40 or 50 Organizations, once I get this solved). You can see an example of it here (there's lots of data going on in this outline): http://stemmonsfreeway.com/military-industrial-intelligence-anti-castro-syndicated So, I've come up with these tables: [persons] id, name ----------------- 1 Phillips 2 Barnes 3 Moore 4 de Mohrenschildt 5 Oswald 6 Hunt 7 Sturgis [assocs] p_id, a_id ---------------- 1 2 2 3 3 4 4 5 1 6 6 7 7 3 And I have this query: SELECT a1.p_id, p1.name AS 'Name', a2.p_id, p2.name AS 'FName1', a3.p_id, p3.name AS 'FName2' FROM assocs a1 JOIN assocs a2 ON a1.p_id = a2.a_id JOIN assocs a3 ON a2.p_id = a3.a_id JOIN persons p1 ON a1.p_id = p1.id JOIN persons p2 ON a2.p_id = p2.id JOIN persons p3 ON a3.p_id = p3.id WHERE p1.id = 1 AND p2.id = 2 AND p3.id = 3;which returns: 1 Phillips 2 Barnes 3 Moore *** The problem I have is where a trail ends, Phillips to Oswald, and starts again, Phillips to Hunt to Moore, for instance. *** What I need is a way to define an end to a string of associations and a start of the next one, perhaps with another field or two in the ASSOCS table, or another table... (I'd also love to be able to denote one of a few types of relationships, i.e. "friend" "foe" "supervised" "worked for" ...) *** I'm hoping some kind soul can help me with a query that can do this, and some advice on how to handle it in the tables I've started with...?
- 11 replies
-
- tables
- relational database
-
(and 1 more)
Tagged with:
-
So i've bought two themes but need to transplant one function to the other (both are very similar) and i'm trying to get my head around whats required and what does what... So apart from the basic CSS these are the related files i've found The main code <?php /** * Job Listing: Business Hours * * @since Listify 1.0.0 */ class Listify_Widget_Listing_Business_Hours extends Listify_Widget { public function __construct() { $this->widget_description = __( 'Display the business hours of the listing.', 'listify' ); $this->widget_id = 'listify_widget_panel_listing_business_hours'; $this->widget_name = __( 'Listify - Listing: Business Hours', 'listify' ); $this->settings = array( 'title' => array( 'type' => 'text', 'std' => '', 'label' => __( 'Title:', 'listify' ) ), 'icon' => array( 'type' => 'text', 'std' => 'ion-clock', 'label' => '<a href="http://ionicons.com/">' . __( 'Icon Class:', 'listify' ) . '</a>' ) ); parent::__construct(); } function widget( $args, $instance ) { global $job_manager; extract( $args ); $title = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ); $icon = isset( $instance[ 'icon' ] ) ? $instance[ 'icon' ] : null; if ( $icon ) { if ( strpos( $icon, 'ion-' ) !== false ) { $before_title = sprintf( $before_title, $icon ); } else { $before_title = sprintf( $before_title, 'ion-' . $icon ); } } $hours = get_post()->_job_hours; if ( ! $hours ) { return; } global $wp_locale; $numericdays = listify_get_days_of_week(); foreach ( $numericdays as $key => $i ) { $day = $wp_locale->get_weekday( $i ); $start = isset( $hours[ $i ][ 'start' ] ) ? $hours[ $i ][ 'start' ] : false; $end = isset( $hours[ $i ][ 'end' ] ) ? $hours[ $i ][ 'end' ] : false; if ( ! ( $start && $end ) ) { continue; } $days[ $day ] = array( $start, $end ); } if ( empty( $days ) ) { return; } ob_start(); echo $before_widget; if ( $title ) { echo $before_title . $title . $after_title; } do_action( 'listify_widget_job_listing_hours_before' ); ?> <?php foreach ( $days as $day => $hours ) : ?> <p class="business-hour" itemprop="openingHours" content="<?php echo $day; ?> <?php echo date_i18n( 'Ga', strtotime( $hours[0] ) ); ?>-<?php echo date( 'Ga', strtotime( $hours[1] ) ); ?>"> <span class="day"><?php echo $day ?></span> <span class="business-hour-time"> <?php if ( __( 'Closed', 'listify' ) == $hours[0] ) : ?> <?php _e( 'Closed', 'listify' ); ?> <?php else : ?> <span class="start"><?php echo $hours[0]; ?></span> – <span class="end"><?php echo $hours[1]; ?></span> <?php endif; ?> </span> </p> <?php endforeach; ?> <?php do_action( 'listify_widget_job_listing_hours_after' ); echo $after_widget; $content = ob_get_clean(); echo apply_filters( $this->widget_id, $content ); } } I guess it's calling this for the styling and formatting information for the table? <?php /** * */ global $wp_locale; if ( is_admin() ) { global $field; } $days = listify_get_days_of_week(); ?> <table> <tr> <th width="40%"> </th> <th align="left"><?php _e( 'Open', 'listify' ); ?></th> <th align="left"><?php _e( 'Close', 'listify' ); ?></th> </tr> <?php foreach ( $days as $key => $i ) : ?> <tr> <td align="left"><?php echo $wp_locale->get_weekday( $i ); ?></td> <td align="left" class="business-hour"><input type="text" class="timepicker" name="job_hours[<?php echo $i; ?>][start]" value="<?php echo isset( $field[ 'value' ][ $i ] ) && isset( $field[ 'value' ][ $i ][ 'start' ] ) ? $field[ 'value' ][ $i ][ 'start' ] : ''; ?>" class="regular-text" /></td> <td align="left" class="business-hour"><input type="text" class="timepicker" name="job_hours[<?php echo $i; ?>][end]" value="<?php echo isset( $field[ 'value' ][ $i ] ) && isset( $field[ 'value' ][ $i ][ 'end' ] ) ?$field[ 'value' ][ $i ][ 'end' ] : ''; ?>" class="regular-text" /></td> </tr> <?php endforeach; ?> </table> and lastly this... <?php class Listify_WP_Job_Manager_Business_Hours extends Listable_Integration { public function __construct() { $this->includes = array(); $this->integration = 'wp-job-manager'; parent::__construct(); } public function setup_actions() { add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) ); // save [front, back] add_action( 'job_manager_update_job_data', array( $this, 'job_manager_update_job_data' ), 10, 2 ); add_action( 'job_manager_save_job_listing', array( $this, 'job_manager_update_job_data' ), 10, 2 ); // add to frontend add_filter( 'submit_job_form_fields', array( $this, 'submit_job_form_fields' ) ); // custom input add_action( 'job_manager_input_business_hours', array( $this, 'job_manager_input_business_hours' ), 10, 2 ); // get current value add_filter( 'submit_job_form_fields_get_job_data', array( $this, 'get_job_data' ), 10, 2 ); // output in admin add_action( 'listify_writepanels_business_hours', array( $this, 'output_admin' ) ); } public function admin_enqueue_scripts() { global $pagenow; if ( ! ( in_array( $pagenow, array( 'post-new.php', 'post.php' )) && get_post_type() == 'job_listing' ) ) { return; } wp_enqueue_script( 'timepicker', Listable_Integration::get_url() . 'js/vendor/jquery.timepicker.min.js' ); wp_enqueue_style( 'timepicker', get_template_directory_uri() . '/css/vendor/jquery.timepicker.css' ); } public function submit_job_form_fields( $fields ) { $fields[ 'job' ][ 'job_hours' ] = array( 'label' => __( 'Hours of Operation', 'listify' ), 'type' => 'business-hours', 'required' => false, 'placeholder' => '', 'priority' => 4.9, 'default' => '' ); return $fields; } public function job_manager_update_job_data( $job_id, $values ) { if ( ! isset( $_POST[ 'job_hours' ] ) ) { return; } update_post_meta( $job_id, '_job_hours', stripslashes_deep( $_POST[ 'job_hours' ] ) ); } public function get_job_data( $fields, $job ) { $hours = get_post_meta( $job->ID, '_job_hours', true ); if ( ! $hours ) { return $fields; } $fields[ 'job' ][ 'job_hours' ][ 'value' ] = $hours; return $fields; } public function job_manager_input_business_hours( $key, $field ) { global $wp_locale, $post, $thepostid; $thepostid = $post->ID; ?> <div class="form-field" style="position: relative;"> <?php if ( ! is_admin() ) : ?> <label for="<?php echo esc_attr( $key ); ?>"><?php echo esc_html( $field['label'] ) ; ?>:</label> <?php endif; ?> <?php global $field; if ( empty( $field[ 'value' ] ) ) { $field[ 'value' ] = get_post_meta( $thepostid, '_job_hours', true ); } get_job_manager_template( 'form-fields/business-hours-field.php' ); ?> <script> (function($) { $( '.timepicker' ).timepicker({ timeFormat: '<?php echo str_replace( '\\', '\\\\', get_option( 'time_format' ) ); ?>', noneOption: { label: '<?php _e( 'Closed', 'listify' ); ?>', value: '<?php _e( 'Closed', 'listify' ); ?>' } }); })(jQuery); </script> </div> <?php } public function output_admin() { do_action( 'job_manager_input_business_hours', '_job_hours', array( 'label' => __( 'Hours of Operation', 'listify' ), 'type' => 'business_hours', 'placeholder' => '', 'priority' => 99 ) ); } } Do i need to manually create the mysql tables or are they already being created? Is there more files i should be looking for? Absolutely clueless despite watching lots of tutorials on youtube, having a PHP & Mysql for dummies book beside me...
-
Hi all, I have some data in a table to do with 20 users appointments every day for a month. I am trying to organise the appointments in to a large table so the clients can see all the appointments of every colleague by date (in columns) and by user name (in rows). for example: 20th May | 21st May | 22nd May | 23rd May Mike Jones London, Paris | Paris, Rome | Rome, London | London, New York 06:15 - 10:15 | 08:20 - 14:00 | 03:30-05:30 | 05:25-09:30 ----------------------------------------------------------------------------------------------------------------------------------------- Bethan Cray OFF | Belfast, Madrid | Madrid, Fez | Fez, Athens 11:15 - 16:35 | 08:45 - 12:10 | 13:55-15:30 | 09:25-13:20 The data is currently stored in the mysql table such as below, and has over 40 users with over 30 rows each in the same format. SectorDate Code BeginTime Dep Arr EndTime 2016-05-20 Mike Jones 06:15 London Paris 10:15 2016-05-21 Mike Jones 08:20 Paris Rome 14:00 2016-05-20 Bethan Cray 11:15 OFF 16:35 Please can someone show how best to arrange the mysql database to give the output above! Thanks
-
Hi Firstly I am new to programming so go easy on me I am building a page where the user inputs text into a table called 'products'. This is the code I am using: $productname=$_POST['productname']; $productprice=$_POST['productprice']; $productpostage=$_POST['productposage']; $productquick=$_POST['productquick']; $productdescription=$_POST['productdescription']; $productdelivery=$_POST['productdelivery']; mysql_connect('localhost', 'username', 'password') or die(mysql_error()); mysql_select_db('Kanga') or die(mysql_error()); mysql_query("INSERT INTO 'product' VALUES ('$productname', '$productprice', '$productpostage', '$productquick', '$productdescription', '$productdelivery')"); print "$productname has been added to the database."; ?> When I press the submit button on the form, I get "Hello world(this is what i entered into the productname field) has been added to the database." I am using phpmyadmin, so should all the data that is submitted show up in there? Thanks Jarrod
- 5 replies
-
- mysql
- phpmyadmin
-
(and 2 more)
Tagged with: