Hi,
I have to do this query:
select all from a table, say lesson
where 'the variable inserted' is equal to any column in table students and students. verified= yes.
Can anyone help me on this.
I have programmed as the following, however it just displays all
column without doing the query
I need to put another condition; verified should be yes, then the result will be displayed.
help is much appreciated
<form action="cuba.php" method="get" name="form" class="style1">
<div align="center">
<input type="text" name="q" />
<input type="submit" name="Submit" value="Search" />
</div>
</form>
<?
$con = mysql_connect( "localhost", "root", "rootroot" );
$db="permis";
mysql_select_db( $db );
// Get the search variable from URL
$query = "select * from lesson";
$result = mysql_query($query, $con);
$fields = mysql_num_fields($result);
while ($row=mysql_fetch_array($result)) {
for ($i=0; $i<$fields; $i++) {
$name=mysql_field_name($result, $i);
// echo "$name = $row[$name]<BR>\n";
}
// echo "<br><br>\n";
// }
$query2 = "select * from ".$name." where $q like '%".$name."%' and lesson.verified= 'yes'"; //search the table column for the search string
$result2 = mysql_query($query2, $con);
echo "$result2 = $row[$result2]<BR>\n";
}
?>