Question:

Help with PHP and sorting out some data.... 10 POINTS TO BEST ANSWER!!!

by  |  earlier

0 LIKES UnLike

K here's my problem.

The php code you see below is a new window that will display the "Materials" from the database. The $invoice that you see is getting the invoice number from the previous screen and searching for the record number with that invoice number in it. Basically, it is a record finder using the invoice number as the search term, and displaying the rest of that specific record on the new window.

i need to somehow make it so it will say "Materials: " and then the actual materials in the database ($materials?).

Then if there isn't any materials in the database ($materials = NULL), it will display "No materials found".

Can someone please tell me how to do this? If you need more information just let me know.

10 pts to the best answer!!

<?php

mysql_connect("@@", "@@", "@@") or die(mysql_error()) ;

mysql_select_db("@@") or die(mysql_error()) ;

$data = mysql_query("SELECT * FROM main ORDER BY date DESC")

or die(mysql_error());

$invoice=mysql_real_escape_string($_PO...

$result=mysql_query("SELECT * FROM main WHERE Invoice LIKE '$invoice' ");

if ($result != NULL) {

goodMat();

}

if ($invoice = NULL) {

echo "No materials found!";

}

function goodMat() {

if ($row != NULL) {

While ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {

$materials=mysql_real_escape_string($_PO...

echo "Materials: " . $materials;

}

}

}

?>

 Tags:

   Report

1 ANSWERS


  1. looks like you defined your results as a function, without ever calling the function to get the results.

    Either call the function, or don&#039;t define the results, just show them.

    To be more exact, that last bit could be:

    if ($row != NULL) {

    While ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {

    $materials=mysql_real_escape_string($_...

    echo &quot;Materials: &quot; . $materials;

    }

    }

    ?&gt;

    Also be aware that NULL might not be the correct way to verify if data exists.  If you are still having trouble, double check the tables to see if NULL is the correct value for determining whether data exists or not.

Question Stats

Latest activity: earlier.
This question has 1 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.
Unanswered Questions