Jump to content


  • Posts

  • Joined

  • Last visited

Posts posted by Drongo_III

  1. Hi mate



    I am assuming your queries actually work. If so, here's the script to generate the links with the IDs. Typing this off the top of my head so sorry if there are any errors.


    $result = mysql_query("SELECT * FROM topics");
    while($row = mysql_fetch_array($result))
      echo '<a href="/YourScript.php/?id=';
      echo $row['id'];
      echo '">' . $row['topic_subject'] . ' </a>';
      echo "<br/>";


    You need to change YourScript.php to whatever script the user will be directed to in oder to generate the content. But this should generate a list of topics with the links dynamically created from the IDs in the database.


    You would most likely use the query strings and $_GET[] to identify the topic you want to pull out from a database (in this instance).


    So depending how you separate your code you would use the $_GET[] on whatever page processes the DB query and displays the content.



    So on one page you might generate a list of anchor tags like


    <a href="/SelectedTopics.php?id=20"> Go to topic 20 </a>


    When a user clicks that linkt they'll go to the Select.php and the in the address bar there will be the querystring on the end of ?id=20


    So your script would then do something like :


    $id = $_GET['id'];  // Here you assign the query string that is stored in the $_GET array to a new variable name - $id


    Then you run a database query using that ID  and generate your content.

  3. $_GET[] is a built in array.


    You generally set the $_GET[] in one of two ways. Either through a web form with method="GET" or via a query string.


    So if you had a script and want to pass in some data via a query string you might do:




    The query string is everything after the ? That gets placed in the $_GET[] array by default.


    You can then access that array by using:



    $variable = $_GET['id'];


    You could of course have multiple parts to the query string like Yourfile.php?id=32&de=43


    So you could access multiple variables from the GET array.



    Query strings are very handy for passing in parameters for like the ID of a page or a piece of content. Look at the url of this site and you'll see things like topic=350294.0.


    So your script could then do


    $tipic = $_GET[topic];

    So the variable $topic is now set as 350294.0 and as your script now has access to this you can use it however you like - most likely in a query on the database to pull that particular article.

  4. Hi Kleb


    Your tables should be setup so that both the USERS table and the CONTENT table share a common id. So in your USERs table 'Bill' might be ID 1.


    Bill has created  a topic and content that is stored in table 2. So this would have three columns like so: id 1, Topic, Content



    Then you run a statement along the lines of the following (which is a very simplistic example). In the example 'Content' refers to your content table and Users refers to your users table.  The query looks for a common id in both tables and joines the data when an id match is found so it's all accessible as one row.


    $result = mysql_query("SELECT * FROM Content, Users WHERE (content.id= user.id) ");
    while($row = mysql_fetch_array($result))
      echo $row['id'] . " " . $row['name'] . " " . $row['topic'] . " " . $row['content'];
      echo "<br />";


    Hope this helps!




  5. You can do a time stamp just by going into your database on php myadmin. Then add a column to the table and in the drop down for 'type' (that's the dropdown with VARCHAR, INT etc.) there is an option for DATE and TIME.  You can select various variations on the date and time from the drop down. Then everytime a record is added to the database it will automatically add the current date and time to that field. So you don't have to do it.


    You can then retreive the date and time as you would any other database value.




    how do i use the time stamp..do i write it together as in TIMESTAMP?

  6. Shoot me down if this is an overly simplistic suggestion...but could you not just use 'Time stamp' as one of your mysql  table columns? This would then save you having to do all the date processing to create the date.




    i have been trying to insert date with when users post there comment but when i echo the date() with the comments..it just display 0000.00.00.00 just like that and when i checked my DB it was like that too..please what can i do.this is my code

    Thankd in advance

    $ins="INSERT INTO post(post_content,post_date)VALUES('$comment','$postdate')";
    mysql_query($ins) or die(mysql_error());
    echo"You can not post an empty page";

  7. Well they'd all be in the same row so yes.


    So you'd have






    Keep in mind this is an extremely simplistic example and you may benefit from having multiple tables and structuring it more clevely if you plan to scale this to hundreds of recrods. But if you just have a handful and it's finite then it should be ok to do this.





    but will i be able to link the a TOPIC from the TOPIC column to the CONTENT in the CONTENT column?

  8. Yeah not quite following what you're getting at. Code would help.


    Otherwise if you want to just make it so you can't see through the div you could set a background colour on it...


    But i'm not usre that's what you're trying to achieve.


    Hi guys,

    I have a background image, and then a fixed div.


    My issue is when i scroll the page, i can see the scrollable content underneath the fixed div (transparent background, because of whole page image background).


    How can I make the scrollable div content not viewable behind the fixed div?


    Any method, css, jquery, PHP, is appreciated, cheers in advance.

  9. OR you could dumb it down still further just to test it and do


    if(empty($_POST['loginname']) && empty($_POST['loginpass'])) {
    echo "Display form";
    echo "process form data";


    I suggest this because sometimes white space can mean a var isset even when it's not

  10. Try add the following before you echo:


    $reminders= count($reminders);


    I tried double quotes, but I'm still missing something


    <?php echo ((count($reminders)) > 0) ? "<span id=\"reminder_counter\" class=\"menu_number f_right mrm\"> {count($reminders)}</span>" : ""; ?>

  11. sorry change postID to just ID.






    Why are you still trying to join the tables?


    help it gave me an error

    Notice: Undefined index: postID in C:\wamp\www\topic_content.php on line 3


    $sql="SELECT* FROM post JOIN topics ON postID=topics.topicsID WHERE topicid='$id'";
    $result=mysql_query($sql)or die(mysql_error());
    echo "{$row['post_content']}";

  12. Ok.


    so you have two tables.


    Table 1 contains rows with - ID and Topic Name


    Table 2 contains rows with - ID and Content - the ID here should match with it's counterpart in the Topic table.


    Your topics page generates a list of links all of which have a query string (i.e. ?id=postID).


    The user clicks that link and gets directed to the contents.php page. Because the links have the query string you pull that from the GET array - i.e.


    $id = $_GET('id')


    You now know the topic the person has clicked on and you have the ID of the topic which should match the ID of the Content tables -therefore you know the content you want.


    $result = mysql_query("SELECT * FROM Contents
    WHERE id=$id")
    while($row = mysql_fetch_array($result))
      echo $row['Contents'] 


    Somethng like that...


    This is assuming that you have two tables which is what I thought was the case from the start...

  13. Hi Kleb


    Since you're echoing the topics links with a query string you could do something like this in you contents.php to pull that ID.


    $contentID = $_GET['postID'];  //access GET array to get the query string then use this to query the Contents table


    Then use that $contentID to search for the specific content record in the database.


    If you have two separate tables for the Topic and Content then there should be a key (like an ID value) that is matched in both cases. So if ID 1 is Animals - in your Topics table




    ID 1 will be Content on Animals - in the Content table


    Do you get that?



  14. You could just use an bit of old school javascript on your body tag:


    <body onload="YourAnimationFunction()" >


    This will load the function once the page loads.  The anim function refers to the function that holds all your animation functions.





  15. It might be clearer if you post your code mate :)


    I have a bit of Jquery that searches in a div for another div with the id "show" then it will remove that class from that div and give the next div in the z-index the same value. My problem is i have a while loop which is repeating the div with the id "show". What i need is for the while loop to display one return with a div with the id of "show" then the rest of the results to be in a div with no id. I have been messing around with this for ages now and am not getting anywere.

  16. Then since it works for me have you tried just echoing out the session variable for "username"?


    i.e. remove all the other code and just start your session and echo out that variable to make sure it's getting passed in correctly.


    This code works perfectly for me:



    $_SESSION['username'] = "twinky"; // set this to test the variable
    $username = $_SESSION['username'];
    // require "header.php";
    <?php if ($username){?>
    echo "<br/><br/>"."Welcome <b>$username</b>, <a href='logout.php'>Logout</a href>"."<br /><br />";
    echo "<center><h2>Hey $username! What do you want to do?</h2></center>";
    <div id="ahome">
    <form action="createnews" method="post">
    <td>Title of Article<td>
    <td><input type="text" size="45" name="newstitle"/><td>
    <td>Author of Article<td>
    <td><input type="text" size="40" name="by"/><td>
    <td>Body of Article<td>
    <td><textarea cols="45" rows="25" name="newsbody"></textarea><td>
    <td><input type="submit" name="submitbtn" value="Add News"/><td>
    <div id="rhome">
    New Admin Stuff Coming Soon....<br></br>
    <a href="#">Create a New Page</a><br></br>
    <a href="#">Edit a Review</a>
    echo "<font color='red'><center><h1>You must be logged in to view this page.</h1></center></font>";
    //require "footer.php";



    its just the html header format

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