Jump to content

Search the Community

Showing results for tags 'tables'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (Dreamweaver, Zend, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 6 results

  1. I'm attempting to create a SQL command that can sort through a concatenated string in my database it is listed at Colors: blue,red,green,yellow is SELECT * FROM `shoes` WHERE CONCAT(',',color,',') LIKE '%,blue,red%' How do I filter the data where it can come up with shoes that are available in red or blue or red and blue and so on? I could use where find_in_set('blue', colors) > 0 and find_in_set('red', colors) > 0 Is there a better way of doing this? Shoe name: shoe A Shoe size: 7,8,9 Shoe color: black , brown, grey For example could have a shoe available in black , size 8 or 9 or 8 and 9.
  2. 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...?
  3. 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
  4. This is what I am trying to accomplish. 1. I have two tables. T1: Users and T2: Earnings. 2. I want to find a single random user whose deposit amount is greater than the listed amount. Below is my foreach loop within foreach loop trying to do the above. I was wondering if there is a more simple way to do this task? Is there a way to combine these two queries together? $listed_amount = 1000; // find a random user $find_user = $db->prepare("SELECT user_id FROM users WHERE user = :user AND active = :active ORDER BY RAND() LIMIT 1"); $find_user->bindValue(':user', 1); $find_user->bindValue(':active', 1); $find_user->execute(); $result_user = $find_user->fetchAll(PDO::FETCH_ASSOC); if(count($result_user) > 0) { foreach($result_user as $row) { $user_id = $row['user_id']; // find that random user's deposit amount $get_deposits = $db->prepare("SELECT deposit FROM earnings WHERE sent_to = :sent_to AND status = :status"); $get_deposits->bindParam(':sent_to', $user_id); $get_deposits->bindValue(':status', 1); $get_deposits->execute(); $result_deposits = $get_deposits->fetchAll(PDO::FETCH_ASSOC); if(count($result_deposits) > 0) { $ub = 0; foreach($result_deposits as $key=>$row) { $ub+= $row['deposit']; } $total_deposits = $ub; } if($total_deposits > $listed_amount) { // show the user } else { // hide the user } } }
  5. 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
  6. 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...
×
×
  • 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.