chriscloyd Posted March 28, 2007 Share Posted March 28, 2007 i wanna select all the rows in my table starting with A would I do this <?php $get_teams = mysql_query("SELECT * FROM cegl_teams WHERE name LIKE 'a' ORDER BY name ASC"); ?> Quote Link to comment Share on other sites More sharing options...
spamoom Posted March 28, 2007 Share Posted March 28, 2007 Nearly there! <?php $get_teams = mysql_query("SELECT * FROM cegl_teams WHERE name LIKE 'a%' ORDER BY name ASC"); ?> You add the % as a wild card, otherwize it will only select rows where the name just equals a Quote Link to comment Share on other sites More sharing options...
jitesh Posted March 28, 2007 Share Posted March 28, 2007 SELECT * FROM cegl_teams WHERE name LIKE 'a%' ORDER BY name ASC" Quote Link to comment Share on other sites More sharing options...
chriscloyd Posted March 28, 2007 Author Share Posted March 28, 2007 i got this error Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /usr/home/www5965/public_html/CEGL-Work/newsite/adminfiles/viewteams.php on line 12 here all the code <?php //get teams //switch on type switch($_GET['type']) { case "1": $name = $_GET['name'].'%'; $get_teams = mysql_query("SELECT * FROM cegl_teams WHERE name LIKE '$name' ORDER BY name ASC"); break; case "2": break; } while ($teams = mysql_fetch_array($get_teams)) { echo $teams['name'].'<br>'; } ?> Quote Link to comment Share on other sites More sharing options...
spamoom Posted March 28, 2007 Share Posted March 28, 2007 <?php //get teams //switch on type switch($_GET['type']) { case "1": $name = $_GET['name'].'%'; $get_teams = mysql_query("SELECT * FROM cegl_teams WHERE name LIKE '{$name}' ORDER BY name ASC"); break; case "2": break; } while ($teams = mysql_fetch_array($get_teams)) { echo $teams['name'].'<br>'; } ?> You need to add the { } around $name 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.