Member Avatar for doctorphp

Hey everyone,

I am trying to develop an addon for my admin area to send a text to my clients.

I am trying to populate a select menu that will list clients that have added their mobile phones.

I am using the following tables.

  • tblclients
  • tblcustomfields
  • tblcustomfieldsvalues

At the moment I am just trying to display the clients who have added their numbers but I get a blank page when using the following code.

$clientSQL = "SELECT * FROM `tblclients`, `tblcustomfields`, ` tblcustomfieldsvalues` WHERE `tblcustomfields.id` = '1' AND `tblcustomfieldsvalues.fieldid` = '1' AND `tblcustomfieldsvalues.value` != ''";
		$clientQ = mysql_query( $clientSQL );
		while( $client = mysql_fetch_assoc( $clientQ ) ) {
			
			//get mobile phone
			echo $client['firstname'] . ' ' . $client['lastname'] . ' - ' . $client['value'] . '<br />';	
		}

In the table "tblcustomfields" the phone number field ID is 1.

If anyone could help me I would be very grateful.

Thanks in advance

Recommended Answers

All 3 Replies

Member Avatar for diafol
$clientSQL = "SELECT * FROM `tblclients`, `tblcustomfields` AS cf, ` tblcustomfieldsvalues` AS cfv WHERE cf.`id` = 1 AND cfv.`fieldid` = 1 AND cfv.`value` != ''";

maybe?

Member Avatar for doctorphp

Thanks but it doesn't work :(

Member Avatar for diafol

Paste the sql into phpmyadmin and see what it says. However, I'd recommend that you use explicit INNER JOIN syntax.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.