Jump to content

aztec

Members
  • Posts

    100
  • Joined

  • Last visited

    Never

Posts posted by aztec

  1. Thanks for your input

     

    It is not what I want to do but it appears from the input it can be done.

    I want to pass an id number say id=1 to a standard php page ie index.php and place the id number into pagename.

    Then I want to use that id number in a mysql query.

     $a_result = @mysql_query("SELECT id,first_name, fid, mid FROM table_x where id= '$page'
    

    Where $page contains the id number.

    Is this part possible using PHP

     

    Regards

  2. Thanks fenway

     

    Having looked through and tried your code with only the table name changed it does indeed produce the data for the fid link. In it's present format the code lost some data but I am working on recoding to get it back.

     

    Am I right in thinking that the inner join produces a "virtual" table that can be searched. If this is correct then what fields would be in the "virtual" table.

     

    I know that these are basic questions but it would help me get a better understanding of the workings of joins.

     

    Kind Regards

  3. Thanks for your reply fenway.

     

    I am now searching for a way to implement your suggestion which is not easy never having used joins before. I have looked at the Manuel for an explanation of joins but at this time in my learning process it is beyond my comprehension. Is there "model code" that I could look at to help me understand what a self_join is and how to code it for my query.

     

    Kind Regards

  4. Hello

    I am using XAMPP 2.5.8

    PHP 5.10

    MySql 5.1.37

    Apache 2.2.12

     

    The following code with no error testing is used to test my database and returns the expected results. The $page for the test is hard coded.

    What I need to do is to use the "fid" data (which is a number and links to the id field) that is returned on the first row of the query to find another id and the associated data row.

     

    If it is possible can anyone please show me an example how this can be done.

     

    Kind Regards

     

    <?php
      // connect to database
      mysql_connect("localhost","USER","PW");
    mysql_select_db("DB");
    $page =1;
      $a_result = @mysql_query("SELECT id, first_name, surname, fid FROM TABLE WHERE id='$page' or link_to_spouse='$page'
    or fid= '$page' ");
    
      
      if ($a_result) {
        if (mysql_num_rows($a_result) > 0) {
          // here we loop through each member in the database
          while ($row = mysql_fetch_assoc($a_result)) {
          
            echo $row['id'];
            echo $row['first_name'];
            echo $row['surname'];
          }
        } 
      }
      
    php?>
    

  5. Hello

     

    I have a website that is hard coded and I have decided to make it database driven, the current site works fine but to keep it up-to-date requires a lot of work.

     

    I do not use tables in the current website but use div's extensively and all of the styling is with CSS. If you go to http://www.westonheritage.co.uk/john1906.html you may get a better understanding of what I am saying.

     

    What I need to do is to create div's depending on the number of rows held in an array from a MySql query, an example of the div is:-

     

    <div id="content_bottom_container">
         					<ul>
         					  	
    					<div id="content_bottomleft">
    					<ul>          	    
    					<li><a href="John1884.html">Audrey Weston (1884-1937)+</a></li>                             
    					</ul>
    					</div>  
    					 <div id="content_bottomright">
         					<ul>          	    
    					<li><a href="Sidney1889.html">John Derek Weston (1889-1964)+</a></li>                             
    					</ul>
    					</div>
    					 <div id="content_bottomleft">
    					<ul>          	    
    					<li><a href="Madeline1891.html">Maurice A Weston (1891-1965)+</a></li>                             
    					</ul>
    					</div>
    

     

    The code above creates 3 div's, 1 left, 1 right and a second left. You will also notice that the Href data is hard coded, I want to change this and input the data from the database. It is important that they are created in this strict order to maintain the shape of the site.

     

    I know this is pretty long winded but it is difficult to explain, a view of the website and a quick look at the source code will help explain it better.

     

    Kind Regards

  6. Hello

    I have a website that I am trying to upgrade so that all the data can be placed into a MySql database.

    I know what I need but I do not know if it is possible with PHP and MySql.

     

    I need to insert into a Href link a variable so that when the link is clicked it would initiate a MySql search for data.

     

    The variable would contain the Key id of the person whose name was clicked. This is very difficult to explain so a visit to the static website may help understand what I am trying to achieve, www.westonheritage.co.uk

    If you go to the second page by clicking the key then click on any of the surnames listed.

     

    I have the database setup on localhost and can get out the data I require.

     

    Kind regards

     

     

  7. Hello

     

    Sorry Maq. I was concentrating on getting the info down and forgot the main part.

     

    I want to create an external text file and when the panel is called by pressing f1 or clicking on the Help button to load that text into the inner panel that slides out.

     

    Regards

  8. Hello

     

    I am no expert when it comes to javascript so would like your help to modify a script I found at the following address

     

    http://www.dhtmlgoodies.com/index.html?showDownload=true&whichScript=slide_in_pane

     

    I have modified the script so that if Javascript is turned off it will load a html help page.

     

    Now I would like to create a separate file that will load into the slideout panel when a link or f1 is pressed

     

    The operation of the panel works very well but there is one BIG drawback, the text for the inner panel needs to go on every page.  This is not acceptable, every time I modify the help page means updating every page on the site.

     

    I have been trying to contact the person who wrote the script though their forum but to no avail.

     

    Kind Regards

  9. Hello

     

    My website uses the "normal· combination of HTML, CSS, PHP and MySQL in its construction.  I have read many times on the forum about attacks and injection.

     

    My question is this:- if the end user has no means via the webpage to update anything in the database and is therefore a passive user, only getting from the database the information programmed into the page they request. Should I be concerned with injection and security.

     

    The password database and the information database are not in the root folder and were created using my hosts facilities, MySQL version 6.

     

    Kind Regards

  10. Hello

     

    Does anyone know the answer to the last part

     

    Is two calls to a database a bad thing because in effect I am making three selects at present.

    This may help me to sort out the rest of the inquiry,

     

    Regards

  11. Hello

     

    Is it possible to extract a data field from a select statment and use it in a "second" union statement. A look at the code will probably explain a little better what I am trying to do.

     

    $a_result = @mysql_query("SELECT id, first_name, surname FROM weston_gen_10 WHERE id='$page' or link_to_spouse='$page'
    UNION SELECT id, first_name, surname FROM weston_gen_11 WHERE link_to_fid='$page'
    UNION SELECT id, first_name, surname FROM weston_gen_9 WHERE fid=5 or 6 or 7 or 8" );
    

     

    The variable $page is passed to the page that will be displayed and is a different number that is in the TITLE of all my pages.

     

    The numbers 'fid=5 or 6 or 7 or 8 are all contained in the results of the first SELECT statement.

     

    Without using a separate call to the database is it possible to extract that data and use it instead of the numbers in the second Union.

     

    The code works but it is not flexible because the numbers change with each web page.

     

    Is two calls to a database a bad thing because in effect I am making three selects at present.

     

    Kind Regards

  12. Hello

     

    Using the code provided by redarrow I get the following error message:-

     

    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM one,two,three WHERE one.Fid=two.Fid AND two.Fid=three.Fid'

     

    I have only changed the table1, table2 and table3 to the actual table name in the database.

     

    Regards

  13. Hello

     

    This is my table structure and is common acros the database

     

    id is auto increment and is table based.

    fid is unique number across the database

     

    id  	int(11)
    Fid  	int(10)
    first_name  	varchar(255)
    second_name  	varchar(255)
    surname  	varchar(255)
    mf  	text
    dob  	date
    pob  	varchar(40)
    dod  	date
    pod  	varchar(40)
    burial  	varchar(40)
    dom  	date
    spouses  	int(4)
    link_to_spouse
    link_to_fid  	int(4)
    

     

     

    Regards

  14. Hello

     

    I am using PHP with a MySQL database.

     

    I have multiple tables in the database each with the same column names.

     

    There is a FID column which contains a unique number across all the database.

     

    The data in each row contains a link to the table above, i.e. table9 is linked to table10 etc.

     

    At this time I am using three queries to get data from three different tables.

     

    Question 1:- how do I start to construct a query that will get data from three tables given that the column names for each table are the same.

     

    Question 2:- is it more economical on the server to run one complex query than three small queries.

     

    Kind Regards

  15. Hello Discomatt

     

    Thanks a lot for your help and your code, you have moved my project forward my a considerable amount.

     

    I can now report that I can get the exact data I need and use it in the way I want.

     

    Once again thanks

     

    Kind Regards

     

    The topic is now resolved

     

  16. Hello discomatt

     

    Thanks for your reply. Looking at what it produces is quite complex, but it does provide me one answer.

     

    Could I ask you how would you extract say the second row, field 2.

     

    At this stage of knowledge that would help me to get to grips with extracting the data I need.

     

    Regards

×
×
  • 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.