Jump to content

Query HElp


john666

Recommended Posts

Hi Guys Help ma in this Query 1st part is Working Fine but When i enter name it doesnt work i have 3 names in Database

 

1.Jason

2.Rooni

3.Jacob

when i Press Jason it doesnt Give me result but when i Press just N its shows me 2 result

if ($_REQUEST['search']) {
	$txt = addslashes($_REQUEST['search']);
	$query="select * from students WHERE stdrollno='$txt' OR stdname LIKE ('{$txt}%') ";
	$result = mysql_query($query);
}

And help me to understand these Lines some 1 make for me this lines but unable to get these lines

if ($result) {
	$class_qry = "select * from classes ";
	$class_res = mysql_query($class_qry) or die(mysql_error());
	if ($class_res) {
		while ($class = mysql_fetch_assoc($class_res)) {
			$class_list[$class['id']] = $class['name'];// This line i cant get All other Got what is actually happneing here
		}
	}
}
while ($row=mysql_fetch_assoc($result))
	{
		
		?>
		<tr>
		<td> <?php echo $row['stdname'];?> </td>
        <td> <?php echo $row['stdrollno'];?> </td>
		<td> <?php echo $row['stdfname'];?> </td>
		<td> <?php echo $class_list[$row['stdclass']];?> </td>// This Line too What is mean of that.......
		<td> <?php echo $row['stdcell'];?> </td>
		<td> <?php echo $row['stddob'];?> </td>
        <td> <?php echo $row['stdaddress'];?> </td>
       <td> <?php echo $row['stdfee'];?> </td>
		<td>
		
		            
					<a href="std_update.php?student_id=<?php echo $row['sn'];?> ">Update</a> |					
					<a href="std_delete.php?student_id=<?php echo $row['sn'];?>" onclick="return confirm('Do you really want to delete this student?');">Delete</a>|
                    <a href="std_view.php?student_id=<?php echo  $row['sn']; ?>">View</a>
					
					
		</td>
	</tr>
Link to comment
Share on other sites

In a previous post you gave your column names as

 


1..(sn)seriel number

2..std_name

3.std_father_name

3..std_roll_num

4..std_class

5..std_cell

6..std_address

7..std_dob

8..std_address

9..std_fee

 

1.class_id

2.class_name

3.date_created

 

so in your last example above you need to reference $row['std_cell'] and not $row['stdcell']. The $row array indices will be the same as the column names.

 

Similarly, in your second code, you need $class['class_id']  and $class['class_name']

Edited by Barand
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.