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?

 

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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!

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.