Jump to content

Search result is not showing up in HTML table


bugzy

Recommended Posts

Hello!

 

I have this code

 

<?php

include_once('../database_connection.php');


$thiskeyword = addslashes($_REQUEST['keyword']);

$sqlquery = "Select * from nba_info where player_id like '%$thiskeyword' OR fname like '%$thiskeyword' OR lname like '%$thiskeyword' OR team like '%$thiskeyword' OR email like '%$thiskeyword'";


$result = MYSQL_QUERY($sqlquery);
$numberOfRows = MYSQL_NUM_ROWS($result);


?>





<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Search Result</title>
</head>

<body><center><br /><br />
<?php



if($numberOfRows==0)
	{

		die('You keywords haven\'t much any data from the database');
        
	}
else if($numberOfRows>0)
	{
	echo $numberOfRows. " Results have been found!";
	$i = 0;	


?>

<table>
<tr>
    	<td>player_id</td>
    
    	<td>fname</td>
  
    	<td>lname</td>

    	<td>team</td>

    	<td>email</td>
        
    </tr>


<?php

while($i<$numberOfRows)
{

	$player_id = MYSQL_RESULT($result,$i,"player_id");
	$fname = MYSQL_RESULT($result,$i,"fname");
	$lname = MYSQL_RESULT($result,$i,"lname");
	$team = MYSQL_RESULT($result,$i,"team");
	$email = MYSQL_RESULT($result,$i,"email");


?>



<tr>
    
    	<td><? echo $player_id; ?></td>
	<td><? echo $fname; ?></td>
	<td><? echo $lname; ?></td>
	<td><? echo $team; ?></td>
	<td><? echo $email; ?></td>

    </tr>

<?php

	$i++;

}

?>


</table>

<?php } ?>



<ul>
<li><a href="/php/database/ManipulatingDatabase/add_database.php">Add New Player</a></li>
    <li><a href="/php/database/ManipulatingDatabase/edit_form.php">Edit Player</li>
    <li><a href="/php/database/ManipulatingDatabase/delete_form.php">Delete Player</li>
    <li><a href="/php/database/ManipulatingDatabase/search_form.php">Search Player</li>
    <li><a href="/php/database/ManipulatingDatabase/manipulate_database.php">BACK TO MAIN</a></li>
</ul>




</center>
</body>
</html>

 

 

I have no problem with the sql statement as  code

 

echo $numberOfRows. " Results have been found!";

 

is giving me a numbers of rows. The problem is the rows that have been found is not showing up in the html row.

 

 

I wonder what the problem is.. anyone?

 

 

What do you get when you do a 'view source' of the page in your browser?

 

Hey I already solved it

 

the problem is on

                <td><? echo $player_id; ?></td>
	<td><? echo $fname; ?></td>
	<td><? echo $lname; ?></td>
	<td><? echo $team; ?></td>
	<td><? echo $email; ?></td>

 

 

so I make it

 

<td><?php echo $player_id; ?></td>

<td><?php echo $fname; ?></td>

<td><?php echo $lname; ?></td>

<td><?php echo $team; ?></td>

<td><?php echo $email; ?></td>

 

 

 

Just a question, I thought PHP is accepting this?

 

 

<? //open



?> //close

 

I wonder why the rows didn't show up by just using that....

Don't use php's lazy-way short open tags <?. They are not always enabled and you won't always be on a server where you will have the ability to enable them. All the short-cuts php put into the language waste more time then they ever saved.

 

The full opening <?php tag will always work and should always be used.

Don't use php's lazy-way short open tags <?. They are not always enabled and you won't always be on a server where you will have the ability to enable them. All the short-cuts php put into the language waste more time then they ever saved.

 

The full opening <?php tag will always work and should always be used.

 

Alright! Thank you very much sir!

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.