Query Problem

Codes here !

Moderators: macek, egami, gesf

New php-forum User
New php-forum User
Posts: 2
Joined: Thu Aug 16, 2012 12:14 pm

Query Problem

Postby gacoksa » Thu Aug 16, 2012 1:18 pm

Hi All, help me please!.
How to create Query for my project problem.

Mysql table:

Code: Select all

CREATE TABLE `contacts` (
  `id` int(11) NOT NULL auto_increment,
  `name` varchar(25) NOT NULL,
  `phone` varchar(20) NOT NULL,
  `group_name` varchar(20) NOT NULL,
  PRIMARY KEY  (`id`)
INSERT INTO `contacts` VALUES (1, 'jala', '+60111', 'friends');
INSERT INTO `contacts` VALUES (2, 'jali', '+60222', 'friends');
INSERT INTO `contacts` VALUES (3, 'jalu', '+60333', 'friends');
INSERT INTO `contacts` VALUES (4, 'kada', '+60444', 'members');
INSERT INTO `contacts` VALUES (5, 'kadi', '+60555', 'members');
INSERT INTO `contacts` VALUES (6, 'kadu', '+60666', 'members');


Code: Select all

<h1>Form Send SMS Message</h1>
<form method="post" action="insert.php">
  <tr><td>Send To</td><td>:</td><td>
       <select name="group">
       <option selected>Select Phone Group</option>
         <option value="members">Members Group</option>
         <option value="friends">Friends Group</option>
  <tr><td>Message</td><td>:</td><td><textarea name="message" rows="10" cols="20"></textarea></td></tr> 
<input type="submit" name="submit" value="submit">

Proses form:

Code: Select all

include ("koneksi.php");
$con = mysql_connect($servername,$username ,$password);
if (!$con)
die('Could not connect: ' . mysql_error());
    $qr_contacts = "SELECT phone FROM contacts WHERE group_name = '$group' ";
    $rs_contacts = mysql_query($qr_contacts);
    while($data = mysql_fetch_array($rs_contacts))
        $id= $data['id'];
        $phone= $data['phone'];
        // I Want insert to outbox tabel (phone_number, text) VALUES ('$phone','$message')
        // How to Create Query?
        // Thank you.

User avatar
php-forum Active User
php-forum Active User
Posts: 335
Joined: Tue Feb 22, 2011 8:19 am
Location: Canada

Re: Query Problem

Postby freshnet » Mon Aug 20, 2012 4:06 am

If you want help, you'll probably need to provide some details on what the problem is, and what you're looking to do.

Return to “mySQL & php coding”

Who is online

Users browsing this forum: No registered users and 3 guests