web_master Posted April 12, 2008 Share Posted April 12, 2008 hi, how can I request 2 id-s from dBase? WHERE `id` = '1' AND `id` = '1546' ... if I want to print id 1 and id 1546 only? thnx Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted April 12, 2008 Share Posted April 12, 2008 <?php $query = mysql_query("SELECT id FROM table WHERE id=1 and id=1546"); while ($row = mysql_fetch_assoc($query)){ echo $row['id'].'<br>'; } ?> Quote Link to comment Share on other sites More sharing options...
web_master Posted April 12, 2008 Author Share Posted April 12, 2008 it dont work, I use like this <?php WHERE `id` = '1546' AND `id` = '1' while($request = mysql_fetch_array($query_return)) { } ?> Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted April 12, 2008 Share Posted April 12, 2008 Did you try my code? What didn't work about it? You have this line just by itself: WHERE `id` = '1546' AND `id` = '1' You have to put that in an actual query. That is only part of a query, look at the example I gave you above. Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted April 12, 2008 Share Posted April 12, 2008 You'll probably want to match with OR, not AND Quote Link to comment Share on other sites More sharing options...
web_master Posted April 12, 2008 Author Share Posted April 12, 2008 well, script is complecsly mailer: <?php include "../mysql_connect.php"; error_reporting(E_ERROR); @ini_set('display_errors', '1'); include ('nxs_mimemail.inc.php'); if($_POST['email_sendto'] == "0") { $where = "WHERE `id` = '1546' AND `id` = '1' AND `email_id` = '".$_POST['email_id']."' ";} if($_POST['email_sendto'] == "1") { $where = "WHERE `ugyfel_korlevel` = '1' ORDER BY `id` ASC" ;} // Reload from dBase $query_return = mysql_query("SELECT `email`.`email_id`, `email`.`email_txt`, `email`.`email_sendto`, `ugyfelek`.`id`, `ugyfelek`.`e_mail`, `ugyfelek`.`ugyfelnev`, `ugyfelek`.`ugyfel_korlevel` FROM `email`,`ugyfelek` ".$where." "); if(!$query_return) { print mysql_error(); exit; } while($request = mysql_fetch_array($query_return)) { // Reload photo $email_photo = $request['email_id']."_email_photo.jpg"; if(is_file($email_photo)){ $photo_view = "<img src=\"".$email_photo."\" alt=\"\" />"; } else { $photo_view = "—"; } // MAIL $from = "foliahaz@gmail.com"; $to = $request['e_mail']; // Embedded pictures $image2 = "mailer_headline.jpg"; $image3 = "headline_fruits.jpg"; $image = $email_photo; $subject = "Hiros foliahaz kft. :: Megoldasok foliahazakhoz"; $text = $request['email_txt']; $html =" <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"> <html xmlns=\"http://www.w3.org/1999/xhtml\"> <head> <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /> <title>Hírös Fóliaház Kft. • körlevél</title> <style type=\"text/css\"> <!-- body { background: #ffdead; } .maintable { width: 500px; } .headlinetable { height: 64px; } .headlinescroll { height: 10px; border: solid; border-width: 0px 1px 0px 1px; border-color: #d6d8d9; } .maintd { border: solid; border-width: 0px 1px 1px 1px; border-color: #d6d8d9; vertical-align: top; padding: 10px; } .footertd { border: solid; border-width: 0px 1px 1px 1px; border-color: #d6d8d9; padding: 10px; } .footertxt { font-family: Georgia, \"Times New Roman\", serif; font-size: 10px; font-weight: bold; color: #bcb9b8; text-align: center; margin: 0px; } .bodytext { font-family: Georgia, \"Times New Roman\", serif; font-size: 14px; font-weight: normal; color: black; text-align: left; line-height: normal; margin: 0px; } .nomail { font-family: Georgia, \"Times New Roman\", serif; font-size: 8px; font-weight: bold; color: green; text-align: center; margin: 0px; } --> </style> </head> <body> <table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\" class=\"maintable\"> <tr> <td class=\"headlinetable\"><img src=\"mailer_headline.jpg\" alt=\"\" /></td> </tr> <tr> <td class=\"headlinescroll\"><img src=\"headline_fruits.jpg\" alt=\"\" /></td> </tr> <tr> <td class=\"maintd\"> <p class=\"bodytext\">".nl2br($request['email_txt'])."</p> <p class=\"bodytext\"> </p> ".$photo_view." </td> </tr> <tr> <td class=\"footertd\"> <p class=\"footertxt\"> Hírös Fóliaház Kft.<br /> H 6000 Kecskemét<br /> Heliport Technik-Park<br /> Mobil: +36 30/550-9870<br /> email: foliahaz@gmail.com<br /> url: http://www.foliahaz.hu</p> <p class=\"nomail\">Leiratkozás a hírlevélről</p></td> </tr> </table> </body> </html> "; $mimemail = new nxs_mimemail(); $mimemail->new_mail($from, $to, $subject, $text, $html); $mimemail->add_attachment($image2, "mailer_headline.jpg"); $mimemail->add_attachment($image3, "headline_fruits.jpg"); $mimemail->add_attachment($image, $email_photo); // Sent mail if ($mimemail->send()) print $request['id'].". ".$request['ugyfelnev']." ( ".$request['e_mail']." )<br />"; else print "ERROR nincs elküldve a mail!<br />"; } // end of while ?> Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted April 12, 2008 Share Posted April 12, 2008 Ummm. id won't be both 1 AND 1546 at the same time in any row. To retrieve the rows with id's = 1, 1546, you need to use the OR operator or use the IN() function. Assuming that id is a numeric data type - WHERE id = 1 OR id = 1546 WHERE id IN(1,1546) Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted April 12, 2008 Share Posted April 12, 2008 Oops, I completely looked over the "AND" that was there. They are right, you need to use "OR". Quote Link to comment Share on other sites More sharing options...
web_master Posted April 12, 2008 Author Share Posted April 12, 2008 Thanks, its work with IN(1,1546) thnx people!!! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.