Angelojoseph17 Posted November 22, 2010 Share Posted November 22, 2010 I'm trying to create a pdf from a form where the user selects a machine_id and that pulls out a pdf based on the variable being passed. I'm pretty sure it is the query where i am doing something wrong. Can someone help. Much appreciated. <?php require('mysql_table.php'); $q=$_GET["q"]; class PDF extends PDF_MySQL_Table { function Header() { //Title $this->SetFont('Arial','',18); $this->Cell(0,6,'Machine Details',0,1,'C'); $this->Ln(10); //Ensure table header is output parent::Header(); } } //Connect to database mysql_connect('localhost','bla','bla'); mysql_select_db('bla'); $pdf=new PDF(); $pdf->AddPage(); //First table: put all columns automatically $this->Cell(0,6,'Repair History',0,1,'C'); $pdf->Table('SELECT * FROM repairs WHERE machine_number = $q'); $pdf->Output(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/219471-sql-query/ Share on other sites More sharing options...
Pikachu2000 Posted November 22, 2010 Share Posted November 22, 2010 You forgot to mention what the actual problem is. Quote Link to comment https://forums.phpfreaks.com/topic/219471-sql-query/#findComment-1137961 Share on other sites More sharing options...
Angelojoseph17 Posted November 22, 2010 Author Share Posted November 22, 2010 it will pull out the results from the database and insert it into the pdf. lol sorry bit of dumb moment there. Quote Link to comment https://forums.phpfreaks.com/topic/219471-sql-query/#findComment-1137968 Share on other sites More sharing options...
ManiacDan Posted November 22, 2010 Share Posted November 22, 2010 You've still forgotten to describe the problem. Describe the problem. Don't say "it doesn't work." What doesn't work? Does it email your grandmother? Does it launch nuclear weapons? Does it format your hard drive? -Dan PS - You cannot interpolate variables inside single quotes. Had you debugged this and echoed the query, you would have seen '$q' instead of the contents of $_GET['q']. Quote Link to comment https://forums.phpfreaks.com/topic/219471-sql-query/#findComment-1137977 Share on other sites More sharing options...
Angelojoseph17 Posted November 23, 2010 Author Share Posted November 23, 2010 $pdf->Table('select * from repairs where machine_number = '.$q.''); Thanks guys I got it to work in the end. Quote Link to comment https://forums.phpfreaks.com/topic/219471-sql-query/#findComment-1138329 Share on other sites More sharing options...
ManiacDan Posted November 23, 2010 Share Posted November 23, 2010 You've still given us zero information, but at least it appears to be working now. Quote Link to comment https://forums.phpfreaks.com/topic/219471-sql-query/#findComment-1138415 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.