Jump to content

can someone look at this code?


ckdoublenecks

Recommended Posts

I have a database with records containing fields named "compmo" which are int(2).  The below code results in the message "No listing for the month".  I print out the file and check the database and there are records that match? 

 

<?php
mysql_connect(localhost,root,"");
mysql_select_db(maintdb) or die( "Unable to select database");
if(!empty($_POST["submit"]))
{
$compmo = $_POST['compmo'];
$query="SELECT * FROM maintdata Where compmo='$compmo'
ORDER BY apt ASC, datereceived DESC ";
$result=mysql_query($query);
if(mysql_num_rows($result))
{
  echo "<form action='#' method='post'><b>Poject: Maintenance Log</b><br><br>
           <table cellspacing=5 cellpadding=0 border='0'>
     <tr>
    <TH>Apt</TH>
    <TH>Name</TH>
    <TH>Received</TH>
    <TH>Time</TH>
    <TH>Problem</TH>
    <TH>Correction</TH>
    <TH colspan=3>Finished</TH>     
    </tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['apt'] . "</td>";
echo "<td>" . $row['name'] . "</td>";
echo "<td>" . $row['datereceived'] . "</td>";
echo "<td>" . $row['time'] . "</td>";
echo "<td>" . $row['symptom'] . "</td>";
echo "<td>" . $row['action'] . "</td>";
echo "<td>" . $row['compmo'] . "</td>";
echo "<td>" . $row['compday'] . "</td>";
echo "<td>" . $row['compyear'] . "</td>";
echo "</tr>";
}
echo "</table>";
echo "</form>";
}
else{echo "No listing for the month $compmo.<br />";}
}
?>
<form method="post" action="#">
<br />
<input type="text" name="month"/> <p>
<input type="submit" name="submit" value="select maintenance month"/>
</form>

 

 

Link to comment
Share on other sites

I changed this

$result=mysql_query($query);

to this

$result = mysql_query($check) or die(mysql_error()); //remove when working 

and went from:

"Warning: mysql_num_rows() expects parameterNo listing for the month ." 1 to be resource, boolean given in C:\xampp\htdocs\hofiles\testing.php on line 11

 

to:

"query was empty
"

 

As I posted, the records all have the field named "compmo" and one of them has the value that I am entering.  the values could be from 1-12 - int(2). at this point the highest is 1 digit (9)?

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.