thereaper87 Posted January 7, 2011 Share Posted January 7, 2011 Hello there, I have run into a problem. I have a search box, which searches through my database and gets results hopefully. But I need to be able to print the list. There is the problem. If I just print the page, it does not print the results. Here is the search.php with the php and the current print javascript. -Search By Address or Postcode-<br> <form name="search" method="post" action="search.php" id="searchform"> Query: <input type="text" name="name"> <input type="submit" name="submit" value="Search"></form> <br><br> -Search By REFID-<br> <form name="search2" method="post" action="search.php" id="searchform2"> Query: <input type="text" name="name2"> <input type="submit" name="submit2" value="Search"></form> <br><br> <?php if(isset($_POST['submit'])){ if($_POST['name'] > NULL){ $name=$_POST['name']; $sql="SELECT * FROM propertyaddress WHERE `address 1` LIKE '%" . $name . "%' OR `postcode` LIKE '%" . $name ."%'"; //-run the query against the mysql query function $result=mysql_query($sql); //-create while loop and loop through result set ?> <SCRIPT LANGUAGE="JavaScript"> if (window.print) { document.write('<form>' + '<br><input type=button name=print value="Print Results" ' + 'onClick="javascript:window.print()"></form>'); }</script> <script language="javascript" type="text/javascript"> <?php while($row=mysql_fetch_array($result)){ echo "<ul>\n"; echo '<a href="display.php?id='.$row['id'].'">'.$row['address 1'].', '.$row['address 2'].' at '.$row['postcode'].'</a><br>'; echo "</ul>"; } } else{ echo "<p>Please enter a search query</p>"; } } I'm at a lost. I'm not sure what to do, I don't think the code as anything to do with printing, but I put it there just in case. I thought about writing it to a temp html page in a popup, but I don't really no how to do that really well. I appreciate any help or suggestions you give. Link to comment https://forums.phpfreaks.com/topic/223664-sending-php-results-to-the-printer/ Share on other sites More sharing options...
runnerjp Posted January 7, 2011 Share Posted January 7, 2011 http://www.zend.com//code/codex.php?ozid=977&single=1 Creat the page to be print friendly then try Link to comment https://forums.phpfreaks.com/topic/223664-sending-php-results-to-the-printer/#findComment-1156200 Share on other sites More sharing options...
Pikachu2000 Posted January 7, 2011 Share Posted January 7, 2011 The code in the linked script is out of date. Link to comment https://forums.phpfreaks.com/topic/223664-sending-php-results-to-the-printer/#findComment-1156227 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.