Jump to content

DangerM0use

Members
  • Posts

    41
  • Joined

  • Last visited

    Never

Everything posted by DangerM0use

  1. Hi all. I'm just wondering what ways there are to open up another HTML/PHP page without using text hyperlinks. Thanks
  2. Hi all. I'm struggling with something and I hope that someone can help. Basically, what I need to do is create a page, that when loaded runs a PHP script. The result of this PHP script basically joins two tables together. I have done that and it works OK. But, what I need to do after that is display this data in an XML document. I have this partly created, but, no data is being displayed. I believe this is because I have no elements declared. The fieldnames from the tables are to be used to name the containing in the XML document. This is the code that I have in the PHP page; # opens the file xyz.xml for writing $handle=fopen("xyz.xml","w"); # writes the header to the xml file fwrite($handle,'<?xml version = "1.0" encoding="UTF-8" standalone="yes"?>'); # puts a space in the file fwrite($handle,"\n"); /*Remove these quote marks once CSS is created # writes the stylesheet code to the xml file fwrite($handle,'<?xml-stylesheet type="text/xsl" href="xyz.xsl"?>'); */ # puts a space in the the next line fwrite($handle,"\n"); # opens the tag 'data collection' that is used to signify the beginning of the data collection from the SQl tables that # will be put in the xml file and uses the XSL stylesheet to view it in a browser correctly fwrite($handle,"<getdata>"); # the SQL query to get the data from the database while ($newrow=mysql_fetch_row($result)) { # writes the opening tag 'data' that shows the beginning of the data got from the sql tables fwrite ($handle,"<data>\n"); # counts number of lines in the data for($i=0;$i<$num;$i++){ # writes the fieldnames fwrite ($handle,"<$fieldnames[$i]>$newrow[$i]</$fieldnames[$i]>"); } # counts the fieldnames for($i=$num;$i<count($fieldnames);$i++){ # writes the fieldnames fwrite ($handle,"<$fieldnames[$i]>$newrow[$i]</$fieldnames[$i]>"); } # writes the 'data' closing tags fwrite ($handle,"</data>\n"); } # writes the closing 'data collection' fwrite($handle,"</getdata>"); From this when I run the .php page and then go to the xml page I get the following; <getdata> <data> </data> <data> </data> <data> </data> etc </getdata> So, where am I going wrong. Where do I put the tables fieldnames in so that it links to the information that is brought from the earlier php query?
  3. Can anybody give me any info??
  4. Hello all. I'm just wondering what the best practise for this code is. I have several queries and I don't know whether it is best to have a seperate query for each one or to have one main query. Here is the code; $file=file_get_contents("mydata.txt"); //read entire file into a string $query=explode(";",$file); //breaks the sting into an array foreach($query as $value) { //loops through the SQL statements mysql_query($value); //execute the statements } mysql_query('update wes_ica_8 SET sss = (sss * 0.90)'); //change the value of column sss - decreasing by 10% $query = "select * from wes_ica_8 LEFT JOIN wes_tut_f ON wes_ica_8.id = wes_tut_f.id"; $result = mysql_query($query); while ( $row = mysql_fetch_array($result)) { extract($row); echo"$id: $dinosaur: $id: $fat<br>)"; } mysql_close(); //close SQL connection echo "DONE"; //confirmation text Thanks
  5. Does anyone feel they will be able to help?
  6. Here is the original assignment. I've edited it so it only contains the need to know bits [attachment deleted by admin]
  7. Don't think I'd be able to post it, there's a lot of text with it. And the going rate, not too sure but i don't think it's a brilliant amount!!
  8. Hello all. I am a university student that is taking a web scripting course, with a piece of coursework that I have just failed, miserably I might add. I have the resit due in for December, which I haven't yet got but am expecting soon. I am looking for someone that is willing to help me go through the original piece of coursework that I had and help me understand it better. I think that is mainly trying to understand what my lecturer was looking for me to deliver. The coursework is basically wanting 4 pages that incorporate PHP/SQL, Javascript and XML. Please please please someone help me go through the original piece of work so I am better prepared and have more chance of passing the resit in December. Please let me know. Thanks
  9. I have a sales table and I need to make a query that takes the initial sale price and the last sale price. Now normally what I would do is a query that took the first sales_# and the last sales_# to do this. The problem is that the product may not be sold everytime - it may be withdrawn from sale and those details are kept in the same table. Is it possible to do a query that gets the first sales_# that has a sales_price or am I going to have to look again at how I have created my table? Cheers for your time and any help!
  10. I am using identity so that everytime a new entry is entered into the db it automatially chooses the next available number Type_# int not null identity(1,1), I am just wondering if it is a good idea to have a constraint as well to make sure the number is in a set limit, so for example; constraint Type_# check (Type_# between '000000' and '999999'), Cheers
  11. Does no one know how to create a date field in MS SQL?
  12. Hi all, I know this is probably a very very simple question with an even simpler answer, but to me this is causing some problems. I need to create a date_of_birth field in one of my tables in my database where an artists date of birth can be entered. For some reason I can't use date and from what I have read it's because MSSQL does it differently. What is the best way to have a date field in a table? All I want is a date, no times etc. Cheers
  13. I've already designed and created all of the database, I am now going through it again trying to get a few extra marks here and there. One of the bits I am looking at again is the bio_location field in the Artist table. I want this to only allow web addresses in and not sure what the best way to do this is
  14. I use SQL Query Analyzer, this is connected to my database so any queries are run and then executed and effect the database. I can check what tables have been created using SQL Server Enteprise Manager. But currently there is nothing to display the data with other than that as this is just a database module and we are not required to do anything other than create the database
  15. SQL and no there is no actual form. The database has to be created for an imaginary website that isn't actually there
  16. Sorry I thought I should have put more info. I don't need to create a website to go with this. Basically I am creating a database that will run a website for purchasing art. Part of the requirement is to log the url of an artists bio (if they have one!) The database will be created and stored in my own student database on the uni server. I have completed just about every other aspect of it and am going through it all once more to try and get a few extra marks. I currently have it set so www is default but don't think this will really work too well. I also think that they would be told to type in the websites url on the form in the website, but if I can I want to try and limit what is typed in.
  17. Hi, not sure if this is in the right forum, so sorry if it is! I am doing an assignment where I have to create an SQL database. I am just wondering what the constraint is to make sure they type in a web address. Cheers
  18. This is a bit of code from it, drop table if exists wes_ica_6; drop table if exists wes_ica_7; drop table if exists wes_ica_8; create table wes_ica_6 (id int(11), country varchar(255), prizes int(11), fff varchar(255), uuu float); create table wes_ica_7 (id int(11), fruit varchar(255), prizes int(11), ggg varchar(255), ttt float); create table wes_ica_8 (id int(11), dinosaur varchar(255), prizes int(11), hhh varchar(255), sss float); There is more drop tables and create tables and there is also code for inserting data into each table
  19. Hi again, I am in the middle of an assignment at uni which has lots of tasks which will eventually create 4 different dynamic pages. On one of the pages, I need to create a script to open a file containing MySql in it. The MySql has commands to delete, recreate and repopulate a table. I currently have; $handle=fopen("filename" , "r"); $lines=file("filename"); but I'm not entirely sure where to go from here. Can someone point me in the right direction as to where I need to look? Cheers.
  20. Yer I did try that but got an error with the aspx part of things. Oh well, will have to go digging further
  21. Hi, this is a really simple question and one I should know the answer to. I am doing a tutorial task at uni where I have to get one row of data from every field in the table using asp.net The MySql part I currently have is; "SELECT * FROM Film showing" but as you know this is getting everything from the film showing table. What do I change to get what I want?? Cheers
  22. I have a php document that takes information from a database table and places it in its relevent text field in a form. Now, all the fields that are textboxes work fine and display the info, but when I changed one of the textboxes to a textarea the data no longer displays. I have tried 2 different things to try and get it to work; echo "Article: <input name='article' type='textarea' cols='65' rows='15' value='".$row['article']."></textarea><br>\n"; echo "Article: <textarea name='article' cols='65' rows='15' value='".$row['article']."'></textarea><br>\n"; Neither won't display any of the data from the database. Any idea where i'm going wrong
  23. Nope the config file is fine, works with other documents that are working fine. It was my error, shock horror, I just can't count! Cheers for pointing out the obvious mistake!
  24. I can't figure out why I am getting the following error; Parse error: syntax error, unexpected $end in /misc/27/000/107/398/6/user/web/xb-online.net/testing/article1.php on line 50 for the following code. <html> <head> <title>Website article test version</title> </head> <body> <?php if(empty($_GET['id'])) { echo "<p class='error'>No article ID supplied.</p>\n"; } else if(!$_POST['id']) { //include config file include "config.php"; $title = ($_POST['title']); $query = "SELECT title, author, text FROM news WHERE id=".$_GET['id']; $result = mysql_query($query) or die("Query failed: ".mysql_error()); if (mysql_num_rows($result) > 0) { // yes // print them one after another echo "<table cellpadding=10 border=1>"; while($row = mysql_fetch_assoc($result)) { // I like fetch_assoc better echo "<tr>"; echo "<td>".$row['title']."</a></td>"; echo "<td>".$row['author']."</td>"; echo "<td>".$row['text']."</td>"; echo "</tr>"; } echo "</table>"; } else { // no // print status message echo "No rows found!"; } // free result set memory mysql_free_result($result); // close connection mysql_close($connection); ?> <a href ="index.php">Home</a> </body> </html> As far as I can tell I have closed all the PHP lines so I can't figure out why it won't allow me to close the html
×
×
  • 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.