Page 2 of 2 FirstFirst 12
Results 11 to 18 of 18

Thread: Call Data From Mysql ...

  1. #11
    TRshady
    Guest
    thanks for the reply ....
    I get what you mean ... well, most of it.
    I do similar at the moment with my site, with each page looking like this and simply being called in the the main template and the .css also being done similar. So I should be fine. Could you tell me how to go about calling the text from tables please mate?

    Never done it before so am unsure of how it all works, but pretend I have an index with the link: "read this new article", how would I make the template load that article from the db?

    Cheers

  2. Internet, Programming and Graphics   -   #12
    TRshady
    Guest
    *bump*

    someone help me on this please

  3. Internet, Programming and Graphics   -   #13
    OK if you want to pick a certain article out then your going have to have some way of distinguishing which article is what. To do this and I was hoping you would of realised you need to add a column to your table and give each row of data a number. You can either have it Auto Number the rows so you don't need to add anything or you can give it a number yourself. Either way the column must be made UNIQUE so that no same article has the same Identifier.

    I would add a column ID and make it UNIQUE and AUTO INDEX this may mean you have to start the table off again but it should take long.

    If you do that each Article or row of data will be easy to pick out as it will have a UNIQUE identifier and you then just use a bit of PHP/MySQL to call to that exact article. if you added this link to your page:

    Cool Article Here

    That link would send a Variable of: $id = 1 to the article.php page so if the article page was set up to use $id to grab certain article from the database it would know which one to get in that case whichever article has the UNIQUE id of 1.

    Get it ?

    Set your Database correct and see if you can set up a article.php page.

    Article page will need to Connect to Database and the correct table which we know how to do ?? if not look above again. and then only grab 1 article from the database using the variable which is set when you use the link to go to that page. when testing if your page works don't bother using the link until you know it works. already set a variable in the article page.

    ill leave the Article page to you as I think I have gave too much help already. you wont learn otherwise but Im sure myself or someone else will reply if you get stuck.

    Laters

  4. Internet, Programming and Graphics   -   #14
    Bollocks to it im too nice

    <?php
    //article.php

    &#036;id = 1;

    &#036;db = mysql_connect("localhost", "triley_test", "test");
    mysql_select_db ("triley_content");

    &#036;result = mysql_query("select * from software where id = &#036;id");
    while(&#036;r=mysql_fetch_array(&#036;result)) {
    &#036;section = &#036;r[section];
    &#036;title = &#036;r[title];
    &#036;content = &#036;r[content];

    echo &#036;section;
    echo "
    ";
    echo &#036;title;
    echo &#036;txt;
    echo &#036;content;

    }

    ?>

    So in other words all we have done is add a WHERE clause to the SELECT query and it will only pick an article from the table software if there is a column called ID with a VALUE of 1 in it.

    Have not tested this as I stopped coding PHP a long time ago so if it dont work then Oooopps but it should

    So take the variable out of it once you have tested it and then for each article you want to grab and say look here use the link to it.

    BTW there are a lot of things I would do differently in that code but im not gonna start picking out the bad coding bits else we will be here forever

  5. Internet, Programming and Graphics   -   #15
    TRshady
    Guest
    Thank you so much Nogimics ... your a star
    Knew part of what you said ... but you really did make things clear and Ive managed it&#33;

    Click here to see the little thingy I set up with your help.

    Got it quite simple after your first post .... and really am thankfull for putting in the effort to help and doing so. Its people like you and Nakor who make this place so great, looking out and helping each other ... tis real kind.

    Cant believe Ive finally managed it ... of course, there are no other things Id like to ask, and only continue helping if wanted ....

    Its works great, and with css fdoesnt look to bad either ... but here are a few questions Id love to be answered:

    Should a whole site only use one table?
    - or should I have a new new table for each category? (reviews, guides etc)

    How would I place data from db in a table?
    - Have the &#036;title in one cell ... above another cell with the actual content
    Have tried making a table using print commands, but then unsure of how to place the data from the table into them.

    What did this variable do in the script?: echo &#036;txt;

    I&#39;ll get playing with it ... but am off to a good start and thanks again&#33;

  6. Internet, Programming and Graphics   -   #16
    Off to the pub to watch England vs Sweden so if someone wants to point out my coding mistake with the &#036;txt and explain go for it else ill be back later. Probably drunk so the coding will be even worse

    To put the article into a table you can exit PHP at any point on any HTML page.

    <?php
    //your code up until we echo the article then exit PHP

    ?>
    PUT HTML TABLE HERE (NOW ITHIN THIS TABLE YOU CAN PUT PHP TAGS LIKE:
    <table width="100%" border=0 cellspacing=1 cellpadding=1 height=10>
    <tr>
    <td height=5><?php echo "&#036;section"?></td>
    </tr>
    </table>
    <?php
    //back into PHP to stop the query
    }
    ?>

    Really got to go now there may be a mistake in that lol but in other words you get to exit PHP then go back into it as long as you open up the <?php tags and close ?>

    Will explain better later comon England

    LATERS

  7. Internet, Programming and Graphics   -   #17
    TRshady
    Guest
    Anyone able to explain the &#036;txt then?
    Have just removed it from the script and it still works fine .. so I&#39;ll be without for now, lol. Just tried as you said .. and it worked&#33; .....

    Right now im tired, so cant think of what else Id love to know (thankfully for you, lol) ... but ill be back, will try out different things. Such as creating a links tables, with different categories .. and a click of &#39;computer sites&#39; for example, brings all links with the category field a computing etc. Thanks again mate .. you&#39;ve made me a happy dude.

  8. Internet, Programming and Graphics   -   #18
    h1
    Guest
    Use different tables for different sections. And just echo out variables to put data in a custom table.

    I don&#39;t know why you&#39;re going through the trouble though, I mean, it&#39;s cool to learn, but once you do, find a CMS that&#39;s a lot easier to use.

Page 2 of 2 FirstFirst 12

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •