-
Posts
579 -
Joined
-
Last visited
Everything posted by Drongo_III
-
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.
-
No more than 14 and no less than 5 charactars is always given
Drongo_III replied to MrCostari's topic in PHP Coding Help
You are calling strlen on the string $gebruikersnaam . But where is that getting set? -
$_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: Yourfile.php?id=32; 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.
-
Can i link an echoed row from a table to another row in another table?
Drongo_III replied to kleb's topic in PHP Coding Help
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! -
Hmm ok. Go into myadmin and click on structure then click to modify the column for time stamp. In there there's a drop down for DEFAULT with a dropdown. Select CURRENT_TIMESTAMP from the drop down. Hopefully that'll fix it
-
Can i link an echoed row from a table to another row in another table?
Drongo_III replied to kleb's topic in PHP Coding Help
Hi Kleb. No worries. How does the user ID come into this? Do you want to echo out some info about the user who created the topic? If so does that mean you have two tables: - One for users -One for topic and content ?? -
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.
-
or $today = date("F j, Y, g:i a"); echo $today; But personally i would leave it to the database to do it. If you can pass something to database to process you probably should. Just my opinion.
-
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.
-
Can i link an echoed row from a table to another row in another table?
Drongo_III replied to kleb's topic in PHP Coding Help
Well they'd all be in the same row so yes. So you'd have ID Topic Content 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. -
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.
-
OR you could dumb it down still further just to test it and do if(empty($_POST['loginname']) && empty($_POST['loginpass'])) { echo "Display form"; } else{ echo "process form data"; } I suggest this because sometimes white space can mean a var isset even when it's not
-
Can i link an echoed row from a table to another row in another table?
Drongo_III replied to kleb's topic in PHP Coding Help
Well if you just have three columns in your table and you're not planning on extending this too much you could put it all in one and have ID, Topic and Content. Then you'd just have to do one single sql query and you won't have to worry about joining the tables etc. It depends how much you're planning to scale this really. -
Try add the following before you echo: $reminders= count($reminders);
-
Can i link an echoed row from a table to another row in another table?
Drongo_III replied to kleb's topic in PHP Coding Help
hehe sorry i might be confusing you becuse i am assuming you have two tables. Try it your way and see how it goes -
Can i link an echoed row from a table to another row in another table?
Drongo_III replied to kleb's topic in PHP Coding Help
sorry change postID to just ID. So $id=$_GET['id']; Why are you still trying to join the tables? -
Can i link an echoed row from a table to another row in another table?
Drongo_III replied to kleb's topic in PHP Coding Help
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... -
Can i link an echoed row from a table to another row in another table?
Drongo_III replied to kleb's topic in PHP Coding Help
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 Then ID 1 will be Content on Animals - in the Content table Do you get that? -
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.
-
Having one item in a while loop diffrent from the rest
Drongo_III replied to son.of.the.morning's topic in Javascript Help
It might be clearer if you post your code mate -
Can i link an echoed row from a table to another row in another table?
Drongo_III replied to kleb's topic in PHP Coding Help
The two tables should share a key. So the ID for the topics should match the ID for the Contents. Do you want the user to click through to a new page to view the topic's content? -
So you want it to display the persons profile then display the search results if the user has done a search? Not quite following what you're trying to achieve.
-
sorry i just meant start the session with session_start() like you have and then echo out the $_session['username'] to ensure a value is actually being passed to it.
-
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: <?php session_start(); $_SESSION['username'] = "twinky"; // set this to test the variable $username = $_SESSION['username']; ?> <?php // require "header.php"; ?> <?php if ($username){?> <?php echo "<br/><br/>"."Welcome <b>$username</b>, <a href='logout.php'>Logout</a href>"."<br /><br />"; ?> <?php echo "<center><h2>Hey $username! What do you want to do?</h2></center>"; ?> <div id="ahome"> <table> <form action="createnews" method="post"> <tr> <td><td> <td><td> </tr> <tr> <td>Title of Article<td> <td><input type="text" size="45" name="newstitle"/><td> </tr> <tr> <td>Author of Article<td> <td><input type="text" size="40" name="by"/><td> </tr> <tr> <td>Body of Article<td> <td><textarea cols="45" rows="25" name="newsbody"></textarea><td> </tr> <tr> <td><td> <td><input type="submit" name="submitbtn" value="Add News"/><td> </tr> </form></table> </div> <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> </div> <?php } else echo "<font color='red'><center><h1>You must be logged in to view this page.</h1></center></font>"; ?> <?php //require "footer.php"; ?>