DarkendSoul Posted January 7, 2007 Share Posted January 7, 2007 That would be because theres no posts. I edited my text... now... i got to be going so someone else has to pick up from where i left off...the problem may be in the structure of your table. last advice i can give. cya Quote Link to comment https://forums.phpfreaks.com/topic/33148-solved-dynamic-urls/page/2/#findComment-154694 Share on other sites More sharing options...
john010117 Posted January 7, 2007 Author Share Posted January 7, 2007 Ok. Thanks for all the help. Now, can anybody else help me ??? : :-\ Quote Link to comment https://forums.phpfreaks.com/topic/33148-solved-dynamic-urls/page/2/#findComment-154698 Share on other sites More sharing options...
john010117 Posted January 7, 2007 Author Share Posted January 7, 2007 I'm getting confused with this... ??? Quote Link to comment https://forums.phpfreaks.com/topic/33148-solved-dynamic-urls/page/2/#findComment-154712 Share on other sites More sharing options...
john010117 Posted January 7, 2007 Author Share Posted January 7, 2007 Can anybody please help me with this? help will be much appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/33148-solved-dynamic-urls/page/2/#findComment-154781 Share on other sites More sharing options...
Jessica Posted January 7, 2007 Share Posted January 7, 2007 Help you with what? After all your bumps, I'm confused as to what the actual problem you still need help with is. Quote Link to comment https://forums.phpfreaks.com/topic/33148-solved-dynamic-urls/page/2/#findComment-154794 Share on other sites More sharing options...
john010117 Posted January 7, 2007 Author Share Posted January 7, 2007 Sorry about those bumps. I need a way to put data in a MySQL table using a form. Then I need a code to display the data. Quote Link to comment https://forums.phpfreaks.com/topic/33148-solved-dynamic-urls/page/2/#findComment-154802 Share on other sites More sharing options...
Jessica Posted January 7, 2007 Share Posted January 7, 2007 Then you need to read some tutorials. This is simple stuff which there are plenty of resources for. Quote Link to comment https://forums.phpfreaks.com/topic/33148-solved-dynamic-urls/page/2/#findComment-154804 Share on other sites More sharing options...
trq Posted January 7, 2007 Share Posted January 7, 2007 Ide suggest you read [url=http://hudzilla.org/phpwiki/index.php?title=Main_Page]this[/url]. Quote Link to comment https://forums.phpfreaks.com/topic/33148-solved-dynamic-urls/page/2/#findComment-154806 Share on other sites More sharing options...
john010117 Posted January 8, 2007 Author Share Posted January 8, 2007 Ok, I have the following.[code]<?php// Connection information$db_host = "localhost"; $db_user = "**"; $db_pass = "**"; $db_name = "**"; // Connect to server$dbac = mysql_connect($db_host,$db_user,$db_pass); // Select databasemysql_select_db ($db_name) or die ("Cannot connect to database"); $result = mysql_query("SELECT * FROM news WHERE Date");if ($result && mysql_num_rows($result)) { $numrows = mysql_num_rows($result); $rowcount = 1; while ($row = mysql_fetch_assoc($result)) { while(list($var, $val) = each($row)) { print "<B>$var</B>: $val<br />"; } print "<br />"; ++$rowcount; } }?>[/code]I have a table named "news", and 3 fields: "News", "Posted_by", "Date" (in DATE format). I can retrieve the data from the database. All I need is a way to only view the news posted for that day using dynamic URL's (index.php?Date=2007-01-07) should only show news posted on Jan. 7, 2007. Can anybody point me the right way? Quote Link to comment https://forums.phpfreaks.com/topic/33148-solved-dynamic-urls/page/2/#findComment-155519 Share on other sites More sharing options...
DarkendSoul Posted January 8, 2007 Share Posted January 8, 2007 [code]<?php// Connection information$db_host = "localhost"; $db_user = "**"; $db_pass = "**"; $db_name = "**"; // Connect to server$dbac = mysql_connect($db_host,$db_user,$db_pass); // Select databasemysql_select_db ($db_name) or die ("Cannot connect to database"); // Change is here added [ = '{$_GET['date']}' ] to end. Which get ?date=____ from url.$result = mysql_query("SELECT * FROM news WHERE Date = '{$_GET['date']}'");if ($result && mysql_num_rows($result)) { $numrows = mysql_num_rows($result); $rowcount = 1; while ($row = mysql_fetch_assoc($result)) { while(list($var, $val) = each($row)) { print "<B>$var</B>: $val<br />"; } print "<br />"; ++$rowcount; } }?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/33148-solved-dynamic-urls/page/2/#findComment-155526 Share on other sites More sharing options...
DarkendSoul Posted January 8, 2007 Share Posted January 8, 2007 Okay i think i misread what you want, you want. let me repost.This would go in a new page.[code]<?php// Connection information$db_host = "localhost"; $db_user = "**"; $db_pass = "**"; $db_name = "**"; // Connect to server$dbac = mysql_connect($db_host,$db_user,$db_pass); // Select databasemysql_select_db ($db_name) or die ("Cannot connect to database"); // Change is here added [ = '{$_GET['date']}' ] to end. Which get ?date=____ from url.$result = mysql_query("SELECT news, Posted_by, date FROM news WHERE Date = '{$_GET['date']}'");if ($result && mysql_num_rows($result)) { $numrows = mysql_num_rows($result); $rowcount = 1; while ($row = mysql_fetch_assoc($result)) { while(list($new, $by, $date) = each($row)) { print "<span align='right' style='font-size:13px'><B>$date</B></span><br />"; print "<span align='right' style='font-size:9px'>$by</span><br />"; print "$news<br />"; } print "<br />"; ++$rowcount; } }?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/33148-solved-dynamic-urls/page/2/#findComment-155527 Share on other sites More sharing options...
Clarkey_Boy Posted January 8, 2007 Share Posted January 8, 2007 ummm... I have read most of these posts and I hate to be a pain an all but... is it not a sensible idea to check that john knows how to CONNECT to a database before going any further with this topic?John, do you know how to connect to a database, or what a connection string is?RC Quote Link to comment https://forums.phpfreaks.com/topic/33148-solved-dynamic-urls/page/2/#findComment-155528 Share on other sites More sharing options...
john010117 Posted January 8, 2007 Author Share Posted January 8, 2007 It's in the last code. Quote Link to comment https://forums.phpfreaks.com/topic/33148-solved-dynamic-urls/page/2/#findComment-155529 Share on other sites More sharing options...
Clarkey_Boy Posted January 8, 2007 Share Posted January 8, 2007 sorry... Im new to this forum and not used to the layout - the page numbers are usually on the right hand side (Ive never seen them on the left) so naturally I thought it was only 1 page lolRC Quote Link to comment https://forums.phpfreaks.com/topic/33148-solved-dynamic-urls/page/2/#findComment-155530 Share on other sites More sharing options...
john010117 Posted January 8, 2007 Author Share Posted January 8, 2007 So, can you help? Quote Link to comment https://forums.phpfreaks.com/topic/33148-solved-dynamic-urls/page/2/#findComment-155534 Share on other sites More sharing options...
DarkendSoul Posted January 8, 2007 Share Posted January 8, 2007 Code posted in last comment, We really shouldn't be doing everything for you though. You need to learn on your own too.I also put a spiffy little design. Untested. Quote Link to comment https://forums.phpfreaks.com/topic/33148-solved-dynamic-urls/page/2/#findComment-155536 Share on other sites More sharing options...
Clarkey_Boy Posted January 8, 2007 Share Posted January 8, 2007 You need a table (call it "newsentries", for sake of argument), with columns "news" (text, 255 chars), "timeadded" (text, 15 chars) and "dateadded" (long integer) (do NOT use "date" or "time" as a field name as they are reserved words in SQL). You need to connect to the database through php. Lets say the connection string is called $conn. Use something similar to the following...Set the dateadded column to the day, month and year the news was added all in a row, for instance today would be 08012007. The timeadded column should be formatted as 12:53:45 (hour:min:sec). I dont bother with setting the field to date format - I just use code to "segment" it if need be.The following code is php, followed by SQL.$date = date("dmY");for($selectnews = $conn->Execute("SELECT * FROM newsentries WHERE dateadded = $date"); !$selectnews->EOF; $selectnews->MoveNext()){ $newstext = $selectnews->Fields("news")->Value; //text - needs a "->Value" at the end $timeadded = $selectnews->Fields("timeadded")->Value; //although its mainly number, it is a text field in the table so still need a "->Value" at the end echo $newstext."<br>".$timeadded."<br><br>";}This will print all news entries for the current day, with a linebreak straight afterwards, then the time it was added, then 2 line breaks.Hope this helps. Some things I left out so it would not be ALL there for you to just use - such as submitting into the table in the first place.RC Quote Link to comment https://forums.phpfreaks.com/topic/33148-solved-dynamic-urls/page/2/#findComment-155541 Share on other sites More sharing options...
john010117 Posted January 8, 2007 Author Share Posted January 8, 2007 Strangely, your first code worked. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/33148-solved-dynamic-urls/page/2/#findComment-155544 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.