mtvaran Posted November 28, 2010 Share Posted November 28, 2010 could anyone provide code for me how to search data using column name. example: if i have 2 columns called NAME,ID then i select NAME or ID and enter the keyword to search. would greatly appreciate your help! Link to comment https://forums.phpfreaks.com/topic/220032-searching-data-column-wise/ Share on other sites More sharing options...
mtvaran Posted December 1, 2010 Author Share Posted December 1, 2010 could anyone please check this code for me. i get the error msg like... Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\wamp\www\dis_study.php on line <?php $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("uni", $con); $result = mysql_query("SELECT study.StudentID,student.StudentName,study.ProgrammeName FROM study,student WHERE study.StudentID = student.StudentID AND StudentID LIKE '$_POST[sid]%' ORDER BY StudentID ASC"); echo"<br>"; echo "<center><table width=700 border=1>"; echo "<tr><th>StudentID</th><th>StudentName</th><th>ProgrammeName</th></tr>"; while($row = mysql_fetch_array ($result)) { echo "<tr><td>"; echo $row['StudentID']; echo "</td><td>"; echo $row['StudentName']; echo "</td><td>"; echo $row['ProgrammeName']; echo "</td></tr>"; } echo "</table>"; mysql_close($con); ?> Link to comment https://forums.phpfreaks.com/topic/220032-searching-data-column-wise/#findComment-1141607 Share on other sites More sharing options...
Pikachu2000 Posted December 1, 2010 Share Posted December 1, 2010 The query execution is failing and returning a boolean FALSE. Link to comment https://forums.phpfreaks.com/topic/220032-searching-data-column-wise/#findComment-1141610 Share on other sites More sharing options...
mtvaran Posted December 1, 2010 Author Share Posted December 1, 2010 whats wrong with query and how should i change it? could you please tell me? Link to comment https://forums.phpfreaks.com/topic/220032-searching-data-column-wise/#findComment-1141621 Share on other sites More sharing options...
Pikachu2000 Posted December 1, 2010 Share Posted December 1, 2010 You need to make use of mysql_error() to see what errors it's generating. Link to comment https://forums.phpfreaks.com/topic/220032-searching-data-column-wise/#findComment-1141672 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.