After a bit of help with PHP

Associate
Joined
10 May 2007
Posts
541
Location
Kent
Hey guys,

Am trying to make a script for work to save us some time and I'm having trouble. I'm trying to pull data from a text area for multiple SQL Select, and then display the data.

I'm at a stand still as I've been trying for the good part of 5-6 hours to get it working. As you can see, just a basic form / display, but it only displays the first number. And then has the first 2-3 sets of numbers in the array but doesnt display them properly. I'm going to guess its a silly error but I'm pretty tired ATM. If any of you could spot it I'd be in your debt :)

2cfcu81.jpg

Code:
require("dompdf-0.5.1/dompdf_config.inc.php");
require("include/config.php");
if (isset($_POST['textarea'])) {
           $text = explode("\n", $_POST['textarea']);
for ( $i=0, $size = count($text); $i<$size; $i++ )
{
	$mydata = $text[$i];
	$sql = "SELECT * FROM company WHERE AccID= '$mydata'";
	$result = mysql_query($sql);
	echo "<table border='1'><tbody><tr>\n";
// Acc Id //
echo '<th>
Acc No
</th>';

// Company Name //
echo '<th>
Company Name
</th>';

// E-Mail // 
echo '<th>
E-mail
</th>';

// Acc Manager //
echo '<th>
Acc Manager
</th>';

// PDF //
echo '<th>
PDF
</th>';

/// Search Results Displayed ///
   if ($text !=NULL) {echo "<h3><font face='Verdana'>Search results for $text[$i]:</h3></face>"; }
   for( $i = 0; $row = mysql_fetch_array($result); $i++ )
{
  echo "<tr>";
  echo '<td><a href=companyinfo.php?AccID='  .$row['AccID'] . '>' .$row['AccID'] . '</a></td>';
  echo "<td>"  .$row['Customer_Name'] . "</td>";  
  echo '<td><a href=mailto:'.$row['Email']. '>'.$row['Email']. '</a></td>';
  echo "<td>"  .$row['Acc_Manager'] . "</td>";
  echo '<td>PDF:<a href=http://myurl.dompdf-0.5.1/dompdf.php?base_path=..%2Fdompdf-0.5.1%2Fwww%2Ftest%2Fvoucher.php&input_file=..%2Fdompdf-0.5.1%2Fwww%2Ftest%2Fvoucher.php>'.$row['Customer_Name']. '</a></td>';
  echo "</tr>";
}
echo "</tbody></table>";
		
			  }
exit();}
 
Ladforce: Ah, see that now. Will remember for future. Thanks :)

Pho: Just went through the code, amazing mate. Can't believe how quick it is as well with my database with ~100,000 records. I have got the PDF export to work aswell now, was pretty tricky but seems to be working as intended. One thing though I have found atm is that I don't think it says which AccID's is doesn't find. Is it possible to show if it doesn't find any? That would be extremely helpful.

Cheers mate, thx a ton.
 
Last edited:
Thanks a lot man, just added this in. Works great :)

I'm just touching up a few things with this PDF export and should be good to go!
 
Back
Top Bottom