Jump to content


Photo

Tired of seeing no record found


  • Please log in to reply
2 replies to this topic

#1 dransiksapoc

dransiksapoc
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 02 June 2006 - 06:19 AM

Ok, so I'm pretty new to php as well as databases so I beg you; keep it simple for me.
Anyway, I'm trying to make a results page for a database of mine and I keep getting the no record found script. This is what I have so far:

<center>
<table border="1" cellpadding="5" cellspacing="0" bordercolor="#000000">
<tr>
<td><b>Name</b></td>
<td><b>Level</b></td>
<td><b>Average HP</b></td>
<td><b>Damage Type</b></td>
<td><b>Resistances</b></td>
<td><b>Vulnerabilities</b></td>
<td><b>Class</b></td>
<td><b>Type</b></td>
<td><b>Edition</b></td>
</tr>
<tr>
<td>
<?php

$hostname = 'localhost';
$username = 'XXXXX';
$password = 'XXXXX';
$dbname = 'warriors_members';


MYSQL_CONNECT($hostname, $username, $password) OR DIE("DB connection unavailable");
@mysql_select_db( "$dbname") or die( "Unable to select database");
?>
<?
//error message (not found message)begins
$XX = "No Record Found, to search again please close this window";
//query details table begins
$query = mysql_query("$sql = 'SELECT * FROM `Montster` LIMIT 0, 30 '");
while ($row = @mysql_fetch_array($query))
{
$variable1=$row["Name"];
$variable2=$row["Level"];
$variable3=$row["Average HP"];
$variable4=$row["Damage Type"];
$variable5=$row["Resistances"];
$variable6=$row["Vulnerabilities"];
$variable7=$row["Class"];
$variable8=$row["Type"];
$variable9=$row["Edition"];
//table layout for results

print ("<tr>");
print ("<td>$variable1</td>");
print ("<td>$variable2</td>");
print ("<td>$variable3</td>");
print ("<td>$variable4</td>");
print ("<td>$variable5</td>");
print ("<td>$variable6</td>");
print ("<td>$variable7</td>");
print ("<td>$variable8</td>");
print ("<td>$variable9</td>");
print ("</tr>");
}

//below this is the function for no record!!
if (!$variable1)
{
print ("$XX");
}
//end
?>
</table>
</center>

I would love some help if you see anything wrong, lol again the help is much appreciated because as I stated earlier: I'm tired of seeing no record found.


#2 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,017 posts

Posted 02 June 2006 - 06:50 AM

$query = mysql_query('SELECT * FROM `Montster` LIMIT 0, 30 ');

If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#3 dransiksapoc

dransiksapoc
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 02 June 2006 - 06:59 AM

[!--quoteo(post=379268:date=Jun 2 2006, 01:50 AM:name=Barand)--][div class=\'quotetop\']QUOTE(Barand @ Jun 2 2006, 01:50 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
$query = mysql_query('SELECT * FROM `Montster` LIMIT 0, 30 ');
[/quote]

Holy mother, thank you so much. (also kinda feel like an idiot for not seeing that lol)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users