dennismonsewicz Posted September 29, 2008 Share Posted September 29, 2008 I have this bit of code: $result = mysql_query("SELECT * FROM tbl_name WHERE project LIKE '%" . $project_name . "%'") or die(mysql_error()); $rows = mysql_num_rows($result); if ($rows > 0) { echo '<p>Here is a list of other projects that have similar Project Names:</p>'; while ($name = mysql_fetch_object($result)) { echo '<p><a href="tools.php?action=view&id=' . $name->id . '">' . $name->project . '</a></p>'; } } The above code is supposed to search through the DB when a new project is added and then spit out all project names that have the same or are like the same project that was added... well it is only spitting out the one you just inserted Anyone got any ideas? Quote Link to comment Share on other sites More sharing options...
revraz Posted September 29, 2008 Share Posted September 29, 2008 Did you echo the query to see what it actually looks like? Quote Link to comment Share on other sites More sharing options...
dennismonsewicz Posted September 29, 2008 Author Share Posted September 29, 2008 this is what i got Resource id #7 Quote Link to comment Share on other sites More sharing options...
revraz Posted September 29, 2008 Share Posted September 29, 2008 That is the Result, not the query. $qry = "SELECT * FROM tbl_name WHERE project LIKE '%" . $project_name . "%'"; echo $qry; $result = mysql_query($qry) or die(mysql_error()); $rows = mysql_num_rows($result); Quote Link to comment Share on other sites More sharing options...
dennismonsewicz Posted September 29, 2008 Author Share Posted September 29, 2008 sorry i wasn't thinking... Here is what I got: SELECT * FROM tbl_name WHERE project LIKE '%text%' the name text, '%text%', is the test name i gave the project when I added it. Quote Link to comment Share on other sites More sharing options...
revraz Posted September 29, 2008 Share Posted September 29, 2008 echo $rows Quote Link to comment Share on other sites More sharing options...
dennismonsewicz Posted September 29, 2008 Author Share Posted September 29, 2008 well I am not sure why but its working now... 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.