Jump to content

kel

Members
  • Posts

    24
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

kel's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi I'm trying to develop a web page that is to be used on a tablet pc. As part of this I need to change the orientation of the page so that it can be used in portrait mode (assuming landscape is normal mode). So my question is, is this possible using css ? if not does anyone know of any other way (php, java etc) to hard code the orientation of a web page. The tablet will be using XP, so I guess a simple way around this would be to change the display settings here (may be my way out in the end :0) but the requirements that I've been given suggest that they want the orientation of the page itself changed - likely to be several users using this so I guess the XP alternative would be to somehow default the tablet to portrait regardless of who is logged on. Anyway, apologies for rambling Thanks kel
  2. Ok, I've put these lines inside the POST and the code now does what I wanted. 44 $query=mysql_query("SELECT * FROM area a, item i, make m, model mo, workstation w, make_model mm 45 WHERE i.mm_id=mm.mm_id AND mm.model_id=mo.model_id AND a.area_id=w.area_id AND i.ws_id=w.ws_id AND m.make_id=mm.make_id AND i.asset_tag='$asset'") ; 46 47 $row=mysql_fetch_array($query); It's a bit messy I guess to put the code in more than once, but it seems to do the job Thanks for the help
  3. Keep at it, you'll probably find that the error is caused by something like anupamsaha is saying. When you have tables associated with each other via foreign keys, you will find that one of the tables usually has to be populated first before you can enter data into the other table because the tables require the data to be there. you could try removing all of the data from those tables - hopefully you don't have a lot in them (or can reinsert the data back in easily) and then try putting the data into one table and then the other. If unsuccessful try inserting data into the 2nd one first and then the other table - this may show you how one table relies on the other.
  4. So, do you mean that I should add another GET statement and that should repopulate the table? The only problem is that the GET only holds the 'asset' value and so a query would probably be needed to request the other information - this would be doubling up on code I think
  5. It may be worth posting the schema for your tables so that we can see how your tables are set up. That way maybe we'll be able to find what constraints you have on which tables and perhaps find the problem
  6. Ok, thanks I'll have to look into it in about an hour - I'm stuck in work and have an IT conference call to join in on,
  7. Ok, trust me - it drove me mad for days until I found that it was related to data type. They can often be really small things, but if you don't make sure everything is right it can cause you headaches
  8. Ok Basically, this maint_serv page is being called by another page - the asset value is being passed via GET. When the page loads it has relevant data for the piece of equipment loaded into the form - via a query. It also should list any previous service records (if any exist) for the equipment below the form. When the user enters some data (comments/username), then clicks add, the relevant data should be sent to the database. All of the previously filled in fields should still hold they're previous values e.g. asset, serial etc. but as soon as add is selected, the script updates the database and blanks out the data that was initially passed to the form by my original query. I know that I should somehow use the POST statement to either keep the fields filled in or repopulate them, but I'm not sure how. Thanks
  9. You may also want to check your data. I had a similar problem before where I was loading data in via a text file and the only reason I had the error was that one of the entries was of the wrong data type. Try inserting the data into your database directly (e.g. without php) does this work? Also, you may find that certain of your tables need to hold values before you can insert data into related tables - hence the foreign key constraint. Play around with your data and your database (I assume mysql or other) and see if that is where the issue lies. It looks to me at least like there is an issue loading your data into the database rather than the issue being php related.
  10. I guess so. Initially I am querying the DB and sticking that info into the form, then on action (e.g. clicking button) any user entered data is sent to the database
  11. Hi maint_serv is the page containing the code I posted - basically the page is passing data back to itself
  12. Hi Guys I'm fairly new to php and haven't quite grasped all of the concepts 100% yet, but have a working script - well mostly. I am having problems with the following Page is meant to display data relating to various equipment in a form and allow me to create a service record for whichever item. The problem is that on the first parse my form displays the relevant data, but on second parse (when the add button is clicked) the only fields in the form that are still populated are asset, next service date and service date. Could anyone help me to find a way to keep the other info such as serial, make, model etc (not inc. comment/username) in the form after the 'add' action has been performed? Everything else on the page seems to work fine. Thanks in advance Here is my code: 1 <Html> 2 3 <Head><B><font size = "18">Printer Servicing</font></Head> 4 <H2>This page is for viewing existing and creating new service records</H2> 5 <Body> 6 <A HREF="maint_index.php">Index page<BR><BR></A> 7 8 <?php $db_link = mysql_connect('localhost', '****', '****');?> 9 <?php if (!$db_link) 10 { 11 die('Could not connect: ' . mysql_error()); 12 } 13 14 $db_selected = mysql_select_db('maint_db', $db_link); // selects the relevant database --> 15 16 17 $date=date("Y-m-d"); 18 19 $asset=$_REQUEST["asset_num"]; 20 $frequency = 90; 21 22 $sched_date=$date; 23 24 if ($_POST['action'] == "add") 25 { 26 $sched_date=date('Y-m-d',(strtotime($date) + $frequency*24*3600)); 27 $sql=("INSERT INTO service(asset_tag, serv_date, comment, username) 28 VALUES($asset, '$sched_date', '$_POST[comment]', '$_POST[username]')"); 29 30 if (!mysql_query($sql,$db_link)) 31 { 32 die('Error: ' . mysql_error()); 33 } 34 35 $sched_upd=("UPDATE item SET sched_date='$sched_date' WHERE asset_tag=$asset"); 36 mysql_query($sched_upd,$db_link); 37 38 echo "1 x service record has been added"; 39 } 40 else 41 { 42 // need to find a way to make the screen refresh - keeping details in form 43 44 $query=mysql_query("SELECT * FROM area a, item i, make m, model mo, workstation w, make_model mm 45 WHERE i.mm_id=mm.mm_id AND mm.model_id=mo.model_id AND a.area_id=w.area_id AND i.ws_id=w.ws_id AND m.make_id=mm.make_id AND i.asset_tag='$asset'") ; 46 47 $row=mysql_fetch_array($query); 48 49 $sched_date=$row['sched_date']; 50 print "sched_date=$sched_date"."<BR>"; 51 $frequency = 90; 52 53 $serial=$row['serial']; 54 } 55 56 ?> 57 58 <FORM ACTION="maint_serv.php" METHOD="POST"> <! this(action bit) says which page(or script) is going to receive data from the form --> 59 60 <INPUT TYPE="HIDDEN" NAME="action" VALUE="add" > 61 <INPUT TYPE="HIDDEN" NAME="asset_num" VALUE="<?php echo $asset;?>"> 62 63 64 <!Populates the table with asset specific values --> 65 <TABLE BORDER=1><TR BGCOLOR="RED"></TR> 66 <TD BGCOLOR="RED"><B>Asset:</B></TD> 67 <TD><?php echo "$asset" ?></TD> 68 <TD BGCOLOR="RED"><B>Area:</B></TD> 69 <TD><?php echo $row['descript']; ?></TD> 70 </TR> 71 <TR> 72 <TD BGCOLOR="RED"><B>Serial:</B></TD> 73 <TD><?php echo $row['serial']; ?></TD> 74 <TD BGCOLOR="RED"><B>Workstation:</B></TD> 75 <TD><?php echo $row['description']; ?></TD> 76 </TR> 77 <TR> 78 <TD BGCOLOR="RED"><B>Printer Name:</B></TD> 79 <TD><?php echo $row['prt_name']; ?></TD> 80 </TR> 81 <TR> 82 <TD BGCOLOR="RED"><B>Make:</B></TD> 83 <TD><?php echo $row['manufacturer']; ?></TD> 84 <TD BGCOLOR="RED"><B>Model:</B></TD> 85 <TD><?php echo $row['model']; ?></TD> 86 </TR> 87 <TR><TD></TD></TR> 88 <TR> 89 <TD BGCOLOR="RED"><B>Next Scheduled Service:</B></TD> 90 <TD><?php echo $sched_date; ?></TD> 91 <TD BGCOLOR="RED"><B>Service Date:</B></TD> 92 <TD><?php echo $date ?><BR></TD> 93 </TR> 94 <TR> 95 <TD BGCOLOR="RED"><B>Comment:</B><BR> (max 255 char)</TD> 96 <TD><TEXTAREA NAME='comment' ROWS=5 COLS=40></TEXTAREA><BR></TD> 97 </TR> 98 <TD BGCOLOR="RED"><B>User:</B></TD> 99 <TD><INPUT TYPE=TEXT NAME='username' SIZE=10><BR></TD> 100 </TR> 101 </TABLE> 102 <BR> 103 104 <INPUT TYPE=SUBMIT NAME="ADD" VALUE="ADD"> 105 <INPUT TYPE=RESET NAME="RESET" VALUE="RESET"> 106 107 </FORM> 108 109 <?php $db_selected = mysql_select_db('maint_db', $db_link); ?> <! selects the relevant database --> 110 <! query --> 111 <?php 112 113 $result = mysql_query("SELECT sv.serv_date, sv.comment, sv.username FROM service sv WHERE sv.asset_tag='$asset'"); 114 // Start table 115 print ("<TABLE BORDER=1>\n"); 116 print ("<TH>SERVICE DATE</TH><TH>COMMENT</TH><TH>SERVICED BY</TH>"); 117 118 while ($row_array = mysql_fetch_array($result)) 119 { 120 $serv_date = $row_array[0]; 121 $comment = $row_array[1]; 122 $Username = $row_array[2]; 123 124 print ("<TR ALIGN=LEFT VALIGN=TOP>"); 125 print ("<TD>$serv_date</TD>"); 126 print ("<TD>$comment</TD>"); 127 print ("<TD>$Username</TD>"); 128 129 print "</TR>"; 130 } 131 132 ?> 133 </TABLE> 134 135 </Body> 136 137 </Html>
  13. Just noticed that I've done 2 dbase connection statements without needing too - will have to edit that out lol
  14. if your files aren't too big, you could also go for the option of sticking your data into say a text file and then running a command in mysql to import that data (make sure that your data is formatted correctly e.g. no blank lines etc) i believe the command is: load data local infile "pathname/filename.txt" INTO table tablename lines terminated by "\r\n"; the last bit just puts a carriage return in etc. It may not be suitable, but is fairly straight forward
  15. Hi I'm trying to create a system that amongst other things displays data (in this case printer information) from a mysql database. I have created a page that displays some stuff in a table with the number of records displayed and hyperlinked next to it. Each count depends on the status of each record (e.g. by date). Anyway, what I am trying to do is as follows: When the respective count/total hyperlink is selected, then I want the data that this total represents to be pulled from the database and displayed (maybe in a table) below the table and hyperlinks (see above). something like: Total printers on site - some number (hyperlinked) Printers that require maintenance - some number (h/linked) blah blah and then when whichever link is selected, the respective data should be displayed here (bearing in mind that the data returned will be hyperlinked too - but I think I can do that bit) - I can send it to a different page (using POST) but what I really want is for it to display on the same page as the totals. Here is my code so far: As you can see i want to use a function (see top of code) to display this stuff, preferably want a reusable function that will display depending on the hyperlink selected. <?php function listAllPrinters() { print "hi"; //function to get data displayed under table } ?> <Html> <Head><B><font size = "18">Printer Maintenance</font></Head> <Body> <?php $db_link = mysql_connect('localhost', 'deeb', 'deeb');?> <! db_link is just a variable name, could've called it foo, this bit connection to mysql server --> <?php if (!$db_link) { die('Could not connect: ' . mysql_error()); } ?> <?php $db_selected = mysql_select_db('maint_db', $db_link); ?> <! selects the relevant database --> <?php $db_link = mysql_connect('localhost', 'deeb', 'deeb');?> <?php if (!$db_link) { die('Could not connect: ' . mysql_error()); } ?> <?php $db_selected = mysql_select_db('maint_db', $db_link); ?> <! selects the relevant database --> <?php //All printers $prt_count = mysql_query("SELECT asset_tag, serial, prt_name, sched_date FROM item"); $prt_num = mysql_num_rows($prt_count); //printers that need maintaining $maint_count = mysql_query("SELECT * FROM item WHERE sched_date < Date_sub(current_date(), interval 3 month)"); $maint_num = mysql_num_rows($maint_count); //Printers that are overdue for maintenance $over_count = mysql_query("SELECT * FROM item WHERE sched_date < Date_sub(current_date(), interval 4 month)"); $over_num = mysql_num_rows($over_count); ?> <TABLE BORDER=1><TR BGCOLOR="RED"></TR> <TD><B>PRINTERS (HP AND ZEBRA)</TD> <TD> <?php echo ("<A HREF=\"maint_index.php?action=printall\">$prt_num</A>\n"); ?> <!displays the number of printers and hyperlinks the result --> </TD> </TR> <TR> <TD><B>PRINTERS REQUIRING MAINTENANCE</TD> <TD> <?php echo ("<A HREF=\"maint_index.php?action=printall\">$maint_num</A>\n"); ?> <!displays the number of printers that are due for maintenance and hyperlinks the result --> </TD> </TR> <TR> <TD><B>MAINTENANCE OVERDUE</TD> <TD> <?php echo ("<A HREF=\"maint_index.php?action=printall\">$over_num</A>\n"); ?> <!displays the numer of printers that are overdue for maintenance and hyperlinks the result --> </TD> </TR> </TABLE> <BR> <?php if ( $_GET['action'] == "printall" ) { listAllPrinters(); } ?> </Body> </Html> Suggestions welcome - I'm fairly new to all of this stuff Thanks
×
×
  • 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.