Jump to content

very important


user4fun

Recommended Posts

$Letter= c ;i need a statment that would look in table Main column 'names' and the records that have the fifith letter to match the $Letter.or if there is any other ideasAll the records in the 'names' column start with www.i want to find all the names that i have listed ( obviously websites) to match the $Letter ( hence the fifth letter )how can i do that.examplewww.charleybrown.comwould come up if $Letter = c

Link to comment
Share on other sites

Hi... You can check 5th letter='c' in column 'name' via following query:Query1: "select if (substring(name,5,1)='c',1,0) as cThere from tblName;" this query will return 1 if c present as 5th and 0 if not. and for starting name with 'www' for that Query2: select * from tblName where name='www%' suppose this will help you..Regards,Vijay

Link to comment
Share on other sites

this is what i have so far.not working thoughconfimred = the table that has the infromation

$result = mysql_query("SELECT Website,Email FROM confirmed"); echo "<table border='1'><tr><th>Website</th><th>Email</th></tr>";while($row = mysql_fetch_array($result))  {  $rest = substr($row['Website'], 5, 1);		if ($rest == c)		  {		  echo "<td>"  . $row['Website'] .  "</td>";   	 echo "<td>"  . $row['Email'] . "</td>";	  		   }		else 		  {		  echo " ";		   }echo "</tr>";  }echo "</table>";

Link to comment
Share on other sites

This query will return all records where the first 5 characters are "www.<letter>":

$sql = "SELECT Website, Email FROM confirmed WHERE Website LIKE 'www.{$letter}%'";

You don't need to do any additional checking with PHP.

Link to comment
Share on other sites

$letter= "o"; $sql = "SELECT Website, Email FROM confirmed WHERE Website LIKE 'www.{$letter}%'";echo "<table border='1'><tr><th>Website</th><th>Email</th></tr>";while($row = mysql_fetch_array($result)) { echo "<td>" . $row['Website'] . "</td>"; echo "<td>" . $row['Email'] . "</td>"; echo "</tr>"; }echo "</table>";I am not getting any results back, the table shows up but it is empty?i know there are entries starting with letter o

Link to comment
Share on other sites

Between this:$sql = "SELECT Website, Email FROM confirmed WHERE Website LIKE 'www.{$letter}%'";and this:while($row = mysql_fetch_array($result))you don't do anything with the database. If you are actually doing that and just decided not to include it, run the query on the database server and see what it is doing.

Link to comment
Share on other sites

What is it that need to be done, here is the full code

$link = mysql_connect("mysql", " ", " ") or die ("No connection");   mysql_select_db("business") or die ("no database");  $letter= "o";	   $result = "SELECT Website, Email FROM confirmed WHERE Website LIKE 'www.{$letter}%'";echo "<table border='1'><tr><th>Website</th><th>Email</th></tr>";while($row = mysql_fetch_array($result))  {  		  echo "<td>"  . $row['Website'] .  "</td>";   	 echo "<td>"  . $row['Email'] . "</td>";	  		echo "</tr>";  }echo "</table>";?>more stuff</td>	</tr>  </table>  </center></div><?include ("../main_btm1.php");?>

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...