Re: [PHP] displaing news
first (quick) glance looks fine... what error are you getting? you didn't specify username/password for your mysql connection. you may be required to do that.. - Original Message - From: <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, September 12, 2001 6:12 PM Subject: Re: [PHP] displaing news > Thanks Tom, > > I'm still a newbie at this stuff though, so can you (or anyone) look this > over and tell me what I did wrong... > > //Connect to db > $db = mysql_pconnect("localhost"); > mysql_select_db("news",$db); > > $result1 = mysql_query("SELECT * FROM news,authors ORDER BY `id` DESC",$db); > > $is_first=true; > while($myrow=mysql_fetch_array($result1)) { > if($is_first) { > $lastdate=$myrow["date"]; > $thisdate=$myrow["date"]; > $is_first=false; > } > > if($thisdate==$lastdate) { > > echo "text here" . $myrow["headline"] . "Posted by mailto:"; > . $myrow["email"] . ">" . > $myrow["author"] . " at " . $myrow["time"] . $myrow["$tod"] . "" > . $myrow["news"] . > > ""; > } else { > echo "" . $myrow["date"] . "text here" . $myrow["headline"] . > "Posted by mailto:"; . $myrow["email"] . ">" . $myrow["author"] . > " at " . $myrow["time"] . $myrow["$tod"] . "" . $myrow["news"] . > > ""; > } > > $lastdate=$thisdate; > } > ?> > > I wasn't sure how to assign the $lastdate and $thisdate variables. > > > > - Original Message - > From: "Tom Carter" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> > Sent: Wednesday, September 12, 2001 9:37 AM > Subject: Re: [PHP] displaing news > > > > rough outline of what you would need to do. > > > > this is pseudocode.. I'm too tired to write correct php :) > > > > $is_first=true; > > whlie(get next result entry) { > > if($is_first) { > > $last-date=date of this entry; > > $this-date=date of this entry; > > $is_first=false; > > } > > > > if($this-date==$last-date) { > > just put the article after the current one > > } else { > > start a new section, displaying date etc > > } > > > > $last-date=$this-date; > > } > > > > - Original Message - > > From: <[EMAIL PROTECTED]> > > To: <[EMAIL PROTECTED]> > > Sent: Wednesday, September 12, 2001 5:24 PM > > Subject: [PHP] displaing news > > > > > > Hey all! > > > > I have a slight problem I was hoping you could help me with. I wrote > earlier > > but no response (so one last try). I'm writing a little news script for my > > site, and well here is the scenario: > > > > The SHORT: > > > > I have news,headline,author,date,time,etc. all in a table in a mysql db, > > that I use mysql_fetch_array to pull out of the db and display on a page. > It > > shows everything fine, but I was wondering, if there is more than one news > > entry per day, how can I display 1 date above the news entries for that > day. > > (Instead of a seperate date for each news entry). > > > > > > The LONG: > > > > I have 2 tables in a mysql database, one holds author information (name, > > email, password, etc.) > > The other table holds the news that they submit (news, date, time, > headline, > > etc.) > > > > Now I am trying to display the news on a page, ordered of course by date > (or > > id in this case) and well i'm using the code below. > > > > > > > $db = mysql_pconnect("localhost"); > > mysql_select_db("news",$db); > > > > $result1 = mysql_query("SELECT * FROM news,authors ORDER BY `id` > DESC",$db); > > > > while($myrow=mysql_fetch_array($result1)) > > { > > echo " > src=images/r13.gif> > > > width=100%>" . > > $myrow["headline"] . " > > Posted by mailto:"; . > > $myrow["email"] . ">" . > > > > $myrow["author"] . " at " . $myrow["time"] . $myrow["$tod"] . > > " > > > src=images/r15.gif> > FACE=verdana>" . $myrow["news"] . > > > > ""; > > } > > ?> > > > > So the results would look something like: > > > > $Headline > > Posted by $author at $time > > > > $news > > > > and it would of course just repeat, for however many entries there is. > > > > Now the problem: > > If I enter 4 news posts a day, I want to show 1 date above all the news > > posts. (Instead of 1 date next to each news post) Any idea how I can do > this > > (In easy to understand lingo/code please)? > > > > > > Thanks! > > > > Nate > > > > > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] displaing news
Thanks Tom, I'm still a newbie at this stuff though, so can you (or anyone) look this over and tell me what I did wrong... mailto:"; . $myrow["email"] . ">" . $myrow["author"] . " at " . $myrow["time"] . $myrow["$tod"] . "" . $myrow["news"] . ""; } else { echo "" . $myrow["date"] . "text here" . $myrow["headline"] . "Posted by mailto:"; . $myrow["email"] . ">" . $myrow["author"] . " at " . $myrow["time"] . $myrow["$tod"] . "" . $myrow["news"] . ""; } $lastdate=$thisdate; } ?> I wasn't sure how to assign the $lastdate and $thisdate variables. - Original Message - From: "Tom Carter" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Wednesday, September 12, 2001 9:37 AM Subject: Re: [PHP] displaing news > rough outline of what you would need to do. > > this is pseudocode.. I'm too tired to write correct php :) > > $is_first=true; > whlie(get next result entry) { > if($is_first) { > $last-date=date of this entry; > $this-date=date of this entry; > $is_first=false; > } > > if($this-date==$last-date) { > just put the article after the current one > } else { > start a new section, displaying date etc > } > > $last-date=$this-date; > } > > - Original Message - > From: <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Wednesday, September 12, 2001 5:24 PM > Subject: [PHP] displaing news > > > Hey all! > > I have a slight problem I was hoping you could help me with. I wrote earlier > but no response (so one last try). I'm writing a little news script for my > site, and well here is the scenario: > > The SHORT: > > I have news,headline,author,date,time,etc. all in a table in a mysql db, > that I use mysql_fetch_array to pull out of the db and display on a page. It > shows everything fine, but I was wondering, if there is more than one news > entry per day, how can I display 1 date above the news entries for that day. > (Instead of a seperate date for each news entry). > > > The LONG: > > I have 2 tables in a mysql database, one holds author information (name, > email, password, etc.) > The other table holds the news that they submit (news, date, time, headline, > etc.) > > Now I am trying to display the news on a page, ordered of course by date (or > id in this case) and well i'm using the code below. > > > $db = mysql_pconnect("localhost"); > mysql_select_db("news",$db); > > $result1 = mysql_query("SELECT * FROM news,authors ORDER BY `id` DESC",$db); > > while($myrow=mysql_fetch_array($result1)) > { > echo " src=images/r13.gif> > width=100%>" . > $myrow["headline"] . " > Posted by mailto:"; . > $myrow["email"] . ">" . > > $myrow["author"] . " at " . $myrow["time"] . $myrow["$tod"] . > " > src=images/r15.gif> FACE=verdana>" . $myrow["news"] . > > ""; > } > ?> > > So the results would look something like: > > $Headline > Posted by $author at $time > > $news > > and it would of course just repeat, for however many entries there is. > > Now the problem: > If I enter 4 news posts a day, I want to show 1 date above all the news > posts. (Instead of 1 date next to each news post) Any idea how I can do this > (In easy to understand lingo/code please)? > > > Thanks! > > Nate > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] displaing news
rough outline of what you would need to do. this is pseudocode.. I'm too tired to write correct php :) $is_first=true; whlie(get next result entry) { if($is_first) { $last-date=date of this entry; $this-date=date of this entry; $is_first=false; } if($this-date==$last-date) { just put the article after the current one } else { start a new section, displaying date etc } $last-date=$this-date; } - Original Message - From: <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, September 12, 2001 5:24 PM Subject: [PHP] displaing news Hey all! I have a slight problem I was hoping you could help me with. I wrote earlier but no response (so one last try). I'm writing a little news script for my site, and well here is the scenario: The SHORT: I have news,headline,author,date,time,etc. all in a table in a mysql db, that I use mysql_fetch_array to pull out of the db and display on a page. It shows everything fine, but I was wondering, if there is more than one news entry per day, how can I display 1 date above the news entries for that day. (Instead of a seperate date for each news entry). The LONG: I have 2 tables in a mysql database, one holds author information (name, email, password, etc.) The other table holds the news that they submit (news, date, time, headline, etc.) Now I am trying to display the news on a page, ordered of course by date (or id in this case) and well i'm using the code below. " . $myrow["headline"] . " Posted by mailto:"; . $myrow["email"] . ">" . $myrow["author"] . " at " . $myrow["time"] . $myrow["$tod"] . "" . $myrow["news"] . ""; } ?> So the results would look something like: $Headline Posted by $author at $time $news and it would of course just repeat, for however many entries there is. Now the problem: If I enter 4 news posts a day, I want to show 1 date above all the news posts. (Instead of 1 date next to each news post) Any idea how I can do this (In easy to understand lingo/code please)? Thanks! Nate -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] displaing news
Hey all! I have a slight problem I was hoping you could help me with. I wrote earlier but no response (so one last try). I'm writing a little news script for my site, and well here is the scenario: The SHORT: I have news,headline,author,date,time,etc. all in a table in a mysql db, that I use mysql_fetch_array to pull out of the db and display on a page. It shows everything fine, but I was wondering, if there is more than one news entry per day, how can I display 1 date above the news entries for that day. (Instead of a seperate date for each news entry). The LONG: I have 2 tables in a mysql database, one holds author information (name, email, password, etc.) The other table holds the news that they submit (news, date, time, headline, etc.) Now I am trying to display the news on a page, ordered of course by date (or id in this case) and well i'm using the code below. " . $myrow["headline"] . " Posted by mailto:"; . $myrow["email"] . ">" . $myrow["author"] . " at " . $myrow["time"] . $myrow["$tod"] . "" . $myrow["news"] . ""; } ?> So the results would look something like: $Headline Posted by $author at $time $news and it would of course just repeat, for however many entries there is. Now the problem: If I enter 4 news posts a day, I want to show 1 date above all the news posts. (Instead of 1 date next to each news post) Any idea how I can do this (In easy to understand lingo/code please)? Thanks! Nate