Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Searching Multi Tables and Multi fields

Featured Replies

Hey there,

 

I need to be able to search all of the fields across a few of my tables i have created.

 

I managed to get that far at least but im unsure on how to go about echoing out the data for links that go direct to that search item.

 

  if(preg_match("/^[a-zA-Z]+/", $_POST['search'])){
  $name= mysql_real_escape_string($_POST['search']);
  $select = mysql_real_escape_string($_POST['where']);
  $moi = $_SESSION['id'];
  if ($select == 1):{
  $src = '_clients';
  }
  elseif ($select == 2):{
$src = '_invoices';
  }
  elseif ($select == 3):{
$src = '_users';
  }
    elseif ($select == 4):{
$src = '_product';
  }
    elseif ($select == 5):{
$src = '_sales';
  }
    elseif ($select == 6):{
$src = '_projects';
  }
  endif;
  //connect  to the database
	$res = mysql_query("SHOW COLUMNS FROM $src");
	if (mysql_num_rows($res) > 0){
	$i=0;
		while($rows = mysql_fetch_array($res)){
		if ($i == 0){
		$q = "SELECT * FROM $src WHERE ".$rows[0]." LIKE '%".$name."%'";
		echo $rows[0];
		}
		else {
		$q.=" or ".$rows[0]." LIKE '%".$name."%'";
		}
		$i++;
		
	}
	$q .= "AND uid = $moi";
	}
	$newstr = str_replace('_', '', $src);
  $sql = "SELECT * FROM $src WHERE name LIKE '%" . $name .  "%'";
  $result = mysql_query($q) or die(mysql_error());
  echo 'We found <strong>'.mysql_num_rows($result).'</strong> Results to Display for the term <strong>'.$name.'</strong>.<br/><br/>';
  while($row=mysql_fetch_assoc($result)){
  //-display the result of the array
  echo '<a href="'.$newstr.'.php">found</a><br/><br/>';
  }
  if (mysql_num_rows($result)==0){
  echo 'Found <strong>0</strong> Results to Display for the Term <strong>'.$name.'</strong>.';
  }
  }
  else{
  echo  "<p>Please enter a search query</p>";
  }

 

Hope fully this makes sense just by reading the above.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.