Jump to content

rocky48

Members
  • Posts

    261
  • Joined

  • Last visited

Everything posted by rocky48

  1. I HOPE THIS IS IN THE CORRECT FORUM! I am developing a program that filters a MySQL database to choose a type of verse. I am using an HTML form with check boxes to select the type. The variable that is passed using $POST is a text string. I am using this string to query the database in the table Events to get all of the verses with that Event_Type. Using mysqli_fetch_array, I am then extacting the ID to use in another MySQL query, this time querying the Verses table to list the verses of this type. What is actually happening is that all the types up to 9 are displaying the correct result, but the ones with ID 10 to 19 are displaying verses with ID = 1 and the last 3 are displaying versed with ID = 2. So it is obvious that it is only looking at the first digit of the ID. How do you get it to recognise complete ID number? PHP Version 5.3.6 Here is the PHP code: <?php include("Loc_cverse_connect.php"); doDB(); //check for required info from the query string //verify the Event exists $verify_Event_sql = "SELECT ID, Event_Type FROM Events WHERE Event_Type = '".$_POST["Event_Type"]."'"; $verify_Event_res = mysqli_query($mysqli, $verify_Event_sql) or die(mysqli_error($mysqli)); echo $_POST["Event_Type"]; if (mysqli_num_rows($verify_Event_res) < 1) { //this Event does not exist $display_block = "<p><em>You have selected an invalid Event.<br/> Please try again.</em></p>"; } else { //get the Event ID while ($Event_info = mysqli_fetch_array($verify_Event_res)) { $Event_ID = stripslashes($Event_info['ID']); } //gather the Events $get_Event_sql = "SELECT ID, Verse FROM Verses WHERE Event = '".$Event_ID["ID"]."' ORDER BY ID ASC"; $get_Event_res = mysqli_query($mysqli, $get_Event_sql) or die(mysqli_error($mysqli)); //create the display string $display_block = " <p> The Event Type is <b>" .$_POST["Event_Type"]."</b> </p> <table width=\"50%\" cellpadding=\"3\" cellspacing=\"1\" border=\"1\" BGCOLOR=\"#87CEEB\" > <tr> <th>ID</th> <th>VERSE</th> </tr>"; while ($Verse_info = mysqli_fetch_array($get_Event_res)) { $Event_id = $Verse_info['ID']; $Verse_text = nl2br(stripslashes($Verse_info['Verse'])); //add to display $display_block .= " <tr> <td width=\"1%\" valign=\"top\">".$Event_id."<br/></td> <td width=\"35%\" valign=\"top\">".$Verse_text."<br/><br/> </tr>"; } //free results mysqli_free_result($get_Event_res); mysqli_free_result($verify_Event_res); //close connection to MySQL mysqli_close($mysqli); //close up the table $display_block .= "</table>"; } ?> <html> <head> <title> List of Verses</title> </head> <body BGCOLOR="#87CEEB"> <h1>Verses</h1> <?php echo $display_block; ?> </body> </html> mysqlnd 5.0.8-dev - 20102224 - $Revision: 308673 $ MySQL Table Structure: Event:- ID Event_Type Verses:- ID Event Sub_Type Verse
  2. I have sussed out the problem that it was ignoring the CSS completely by including in the DIV#text class, but it is ignoring the @page directive in the HTML. I am not sure if I have got the syntax correct in the HTML. The book I am reading says body {page: Port;} Does this mean that after the <body> you add the statement or have I got this wrong? Rocky48
  3. I have partially solved this topic. I have posted a new topic in PHP Forum, as it is a PHP/HTML problem I think. Consider this closed!
  4. I am trying to format for printing some text which I have queried from a MySQL database. I have written 2 CSS scripts one for screen and the other for printing. They work up to a point, but I can't get it to display the correct font and font size. I am sure it is because it is ignoring the <p>. Here is the source script: <?php include("Loc_cverse_connect.php"); doDB(); //verify the Event exists $Get_Verse_sql = "SELECT ID, Event, Sub_Type, Verse FROM verses WHERE ID = '".$_POST["ID"]."'"; $Get_Verse_res = mysqli_query($mysqli, $Get_Verse_sql) or die(mysqli_error($mysqli)); //echo $_POST[iD]; if (mysqli_num_rows($Get_Verse_res) < 1) { //this Event does not exist $display_block = "<p><em>You have selected an invalid Event.<br/> Please try again.</em></p>"; } else { //get the Event ID while ($Verse_info = mysqli_fetch_array($Get_Verse_res)) { $Verse = stripslashes($Verse_info['Verse']); } //create the display string $display_block = "<h1>$Verse</h1>"; //free results mysqli_free_result($Get_Verse_res); //close connection to MySQL mysqli_close($mysqli); } ?> <html> <head> <link rel="stylesheet" type="text/css" href="Prn_Scrn.css" media="screen"> <link rel="stylesheet" type="text/css" href="print.css" media="print"> <title> List of Verses</title> </head> <body {page: land}> <div id="Text" align="center"> <p> <?php ECHO $display_block; ?> </p> </div> </body> </html> Here is the print CSS script: /*--Print stylesheet*/ p {font: 25pt French Script MT;} @page land {size: landscape;margin: 0in} div#Text { /* <DIV>Text</DIV> */ position : absolute; left : 6.9in; top : 2.25in; width : 3.625in; height : 1.625in; } Here is the screen CSS: /*--- Page Style ---*/ @page land {size:landscape; margin: 0in;} p {font: 25pt French Script MT;} div#Text { /* <DIV>Text</DIV> */ position : absolute; left : 6.9in; top : 2.25in; width : 3.625in; height : 1.625in; } /*--- EndOfFile ---*/ Where am I going wrong? Rocky48
  5. Here are the scripts: PrnScrn.php <?php include("Loc_cverse_connect.php"); doDB(); //verify the Event exists $Get_Verse_sql = "SELECT ID, Event, Sub_Type, Verse FROM verses WHERE ID = '".$_POST["ID"]."'"; $Get_Verse_res = mysqli_query($mysqli, $Get_Verse_sql) or die(mysqli_error($mysqli)); //echo $_POST[iD]; if (mysqli_num_rows($Get_Verse_res) < 1) { //this Event does not exist $display_block = "<p><em>You have selected an invalid Event.<br/> Please try again.</em></p>"; } else { //get the Event ID while ($Verse_info = mysqli_fetch_array($Get_Verse_res)) { $Verse = stripslashes($Verse_info['Verse']); } //create the display string $display_block = "<h1>$Verse</h1>"; //free results mysqli_free_result($get_Verse_res); //close connection to MySQL mysqli_close($mysqli); } ?> <html> <head> <link rel="stylesheet" type="text/css" href="Prn_Scrn.css" media="all"> <title> List of Verses</title> </head> <body> <?php ECHO $display_block; ?> </body> </html> PrnScrn1.php <?php include("Loc_cverse_connect.php"); doDB(); //verify the Event exists $Get_Verse_sql = "SELECT ID, Event, Sub_Type, Verse FROM verses WHERE ID = '".$_POST["ID"]."'"; $Get_Verse_res = mysqli_query($mysqli, $Get_Verse_sql) or die(mysqli_error($mysqli)); //echo $_POST[iD]; if (mysqli_num_rows($Get_Verse_res) < 1) { //this Event does not exist $display_block = "<p><em>You have selected an invalid Event.<br/> Please try again.</em></p>"; } else { //get the Event ID while ($Verse_info = mysqli_fetch_array($Get_Verse_res)) { $Verse = stripslashes($Verse_info['Verse']); } //create the display string $display_block = "<h1>$Verse</h1>"; //free results mysqli_free_result($get_Verse_res); //close connection to MySQL mysqli_close($mysqli); } ?> <html> <head> <style type="text/css"> body{ background-color: #FFFFFF; h1 {font-family:Arial, sans-serif; font-size:x-large;} } </style> <title> Print Verse</title> </head> <body> <?php ECHO $display_block; ?> </body> </html> Prn_Scrn.css /*--- Page Style ---*/ @page {size:landscape; margin-left: 175mm; margin-top: 55mm} h1 {font: large Ariel; color: Black;} /*--- EndOfFile ---*/ Any ideas why either of these do not work?
  6. I am trying to create an output for a printer, for a string that is queried from an SQL database. I am using PHP to query the database and the result is passed to a variable called $display block. I want to be able to define the Font face and the Font size. I have tried 2 methods to implement CSS for this code but niether work. I am relitively new to programming and have exhusted all of the avenues to resolve this. PrnScrn.php - External CSS file PrnScrn1.php - embeded CSS file Prn_Scrn.css.zip - zipped version of CSS external file I would be most appreciative if someone could advise where I am going wrong! Rocky48 17220_.php 17221_.php 17222_.zip
×
×
  • 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.