1

I've create a form by metabox and save data in custom table

my table is:

$table_name = $wpdb->prefix . 'aacv';
$sql = "CREATE TABLE $table_name (
    id int(11) NOT NULL AUTO_INCREMENT,
    user_id int(20) Not Null,
    name varchar(255) collate utf8_unicode_ci NOT NULL,
    lastname varchar(255) collate utf8_unicode_ci NOT NULL,
    post_title varchar(255) collate utf8_unicode_ci NOT NULL,
    food_selected varchar(255) collate utf8_unicode_ci NOT NULL,
    guest_number bigint(20)  NOT NULL,
    email varchar(255) NOT NULL,
    PRIMARY KEY (Id)
);";

I want to get entry WHERE LIKE post title by this code:

<?php $abcde = $abc = the_title();
                    $mylink = $wpdb->get_results('SELECT * FROM wp_aacv WHERE post_title LIKE' .$abcde); ?>
                    <?php foreach ($mylink as $post){ ?>
                    <?php echo $post->food_selected;} ?>

but not work.

0

Use

get_results('SELECT * FROM wp_aacv WHERE post_title LIKE '".$abcde."' ');
  • error Parse error: syntax error, unexpected '"' in – Essi Dec 24 '14 at 17:51
  • can u post full error.. – jay.jivani Dec 24 '14 at 17:53
  • Parse error: syntax error, unexpected '"' in /home3/adalatne/public_html/nahar/wp-content/themes/twentyfourteen/content.php on line 74 – Essi Dec 24 '14 at 17:54
  • It's error on content page & you are working on your custom page.. right?? – jay.jivani Dec 24 '14 at 17:57
  • Change the quote in query "select * from wp_aacv where post_title like '".$abcde."' " – jay.jivani Dec 24 '14 at 17:58
0

Use this

<?php $abc = the_title();
 $abcde = '%' . $abc . '%';


      $mylink = $wpdb->get_results('SELECT * FROM wp_aacv WHERE post_title LIKE' .$abcde); ?>

             <?php foreach ($mylink as $post){ ?>

             <?php echo $post->food_selected;} ?>
  • Tanks a lot my friend – Essi Dec 27 '14 at 21:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.