Current location: Hot Scripts Forums » Programming Languages » PHP » changings in showing results in php script


changings in showing results in php script

Reply
  #1 (permalink)  
Old 11-19-04, 11:05 AM
korro korro is offline
Newbie Coder
 
Join Date: Mar 2004
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
changings in showing results in php script

I have got a php script where people can add there birthday.
I wanne use this script in my forum because in my forum it is not possible to do that automatic.
The problem of this script is the way the results are showing

now the results are showing down under each other, example:
ikke1
ikke2
ikke3

The problem is that is not nice in my forum. I wanne have the results in one line. Between the results there must be a ,,
example: ikke1, ikke2, ikke3

I also wanne start this line with:: todays birtday
example: todays birtday: ikke1, ikke2, ikke3

Last question: How can I change the lettersize of the results that are showing??

Till now I tried to do something by myself like changing the 100% in a lower size but I get a problem in my forum with that.
I hope there is somebody who wanne help me with making this changings in this script part.

-------- script part ---------

<?php
require("include/config.php");
require("include/lang_$lang.php");


/*
Get todays's birthday in three steps
Thanks to Leon Atkinson <leon@leonatkinson.com>
Created by Ridder Roeland
Part of BirthSys 2.0
*/

// First: set the current day
$date = date( "d" );

// Second: get the right month and translate to used monthnames in MySQL table
$currentMonth = date( "n" );
$monthName = array(1=> "01", "02", "03",
"04", "05", "06", "07", "08",
"09", "10", "11", "12");

$month=("$monthName[$currentMonth]");

// Third: get the value from the MySQL database and put in a nice table
?>

<TABLE WIDTH="100%" border="0" cellspacing="0" cellpadding="2">
<?php

// Connect to database and display results

mysql_connect ("$servername", "$dbusername", "$dbpassword");
mysql_select_db ("$dbname");

$result = mysql_query("SELECT * FROM birthsys WHERE month= $month AND day= $date");

if ($row = mysql_fetch_array($result)) {
do{

$day = $row[day];
$name = $row[name];


echo "
<TR ALIGN=\"left\" VALIGN=\"top\">
</TD>
<TD><DIV ALIGN=\"left\">$name</DIV></TD></TR>
";
}
while($row = mysql_fetch_array($result));
}
else {
echo "$nobirthdate";
}
?>
</table>
Reply With Quote
  #2 (permalink)  
Old 11-19-04, 12:16 PM
<?Wille?> <?Wille?> is offline
Junior Code Guru
 
Join Date: Jan 2004
Location: Helsinki, Finland
Posts: 666
Thanks: 0
Thanked 0 Times in 0 Posts
change to this:
PHP Code:

#<TABLE WIDTH="100%" border="0" cellspacing="0" cellpadding="2"> // delete this row

<?php
$i 
1# add this
// Connect to database and display results

mysql_connect ("$servername""$dbusername""$dbpassword");
mysql_select_db ("$dbname");

$result mysql_query("SELECT * FROM birthsys WHERE month= $month AND day= $date");

#change
$n mysql_num_rows($result);
if (
$n) {
while (
$row mysql_fetch_array($result)) {
##
$day $row[day];
$name $row[name]; 

/*
echo "
<TR ALIGN=\"left\" VALIGN=\"top\">
</TD>
<TD><DIV ALIGN=\"left\">$name</DIV></TD></TR>
";*/ # change this block to:
###
echo $name.($i == $n '' ', ');
$i++;
###

#change

##
} else {
echo 
"$nobirthdate";
}

# </table> // delete this row
?>

Last edited by <?Wille?>; 11-19-04 at 12:33 PM.
Reply With Quote
  #3 (permalink)  
Old 11-19-04, 12:21 PM
perleo perleo is offline
Coding Addict
 
Join Date: Jul 2003
Location: Ireland
Posts: 269
Thanks: 0
Thanked 0 Times in 0 Posts
PHP Code:

<?php

require("include/config.php");
require(
"include/lang_$lang.php");


/*
Get todays's birthday in three steps
Thanks to Leon Atkinson <leon@leonatkinson.com>
Created by Ridder Roeland
Part of BirthSys 2.0
*/

// First: set the current day
$date date"d" );

// Second: get the right month and translate to used monthnames in MySQL table
$currentMonth date"n" );
$monthName = array(1=> "01""02""03",
"04""05""06""07""08",
"09""10""11""12");

$month=("$monthName[$currentMonth]");

// Third: get the value from the MySQL database and put in a nice table
?>

<TABLE WIDTH="100%" border="0" cellspacing="0" cellpadding="2">
<TR ALIGN=\"left\" VALIGN=\"top\">
</TD>
<TD><DIV ALIGN=\"left\">
<?php

// Connect to database and display results

mysql_connect ("$servername""$dbusername""$dbpassword");
mysql_select_db ("$dbname");

$result mysql_query("SELECT * FROM birthsys WHERE month= $month AND day= $date");
echo 
"<b>Today's Birthday: </b>";
if(
$result)
{
while(
$row mysql_fetch_array($result)) 
{

$day $row[day];
$name $row[name];


echo 
$name;
echo 
', &nbsp;';

}
}
elseif(!
$result) {
echo 
"$nobirthdate";
}
?>
</DIV></TD></TR></table>
i think that will work, basically, put the table stuff like <TD> outside where the results are printed.
What happening in your script theres a new row being made per result, you want them all in the one row.
Reply With Quote
  #4 (permalink)  
Old 11-19-04, 12:30 PM
<?Wille?> <?Wille?> is offline
Junior Code Guru
 
Join Date: Jan 2004
Location: Helsinki, Finland
Posts: 666
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by perleo
PHP Code:

if($result)

# . . .
} elseif(!$result) {
echo 
"$nobirthdate";

i think that will work, basically, put the table stuff like <TD> outside where the results are printed.
What happening in your script theres a new row being made per result, you want them all in the one row.
yea it will probably work but.. no offense but few things here that didnt seem to fit imo. why use elseif when the only possibility after $result is false is that its false.. that is a compare that doesint need to be there.. and well.. why use table for one cell?? but anyways.. i like trying to optimize code for performance.. specially with easy ones
Reply With Quote
  #5 (permalink)  
Old 11-20-04, 03:43 AM
korro korro is offline
Newbie Coder
 
Join Date: Mar 2004
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Thank you Perleo that works.
But where is the text when there is no birthday.
I put in now to testnames and that works but when there is nobody birthday the text is gone!!!!

I want to put this in my forum with an iframe, first i try to do that with include,
<?php include("http://www.kellystart.com/birthsys3php/date.php");?>
But people say when you wanne use include the server from the forum and the server from this script must be the same.
Is there another way???

I want to put it in my forum (http://50308.forum.onetwomax.de)
in the line: Welcome to our new member: sanclauds, Ho can I get the same lettersize as that text (also color black/blue black = today birtday, blue=names.

I hope there is somebody who wanne help me one more time.

Last edited by korro; 11-20-04 at 04:34 AM.
Reply With Quote
  #6 (permalink)  
Old 11-20-04, 04:43 AM
perleo perleo is offline
Coding Addict
 
Join Date: Jul 2003
Location: Ireland
Posts: 269
Thanks: 0
Thanked 0 Times in 0 Posts
PHP Code:

<?php

require("include/config.php");
require(
"include/lang_$lang.php");


/*
Get todays's birthday in three steps
Thanks to Leon Atkinson <leon@leonatkinson.com>
Created by Ridder Roeland
Part of BirthSys 2.0
*/

// First: set the current day
$date date"d" );

// Second: get the right month and translate to used monthnames in MySQL table
$currentMonth date"n" );
$monthName = array(1=> "01""02""03",
"04""05""06""07""08",
"09""10""11""12");

$month=("$monthName[$currentMonth]");

// Third: get the value from the MySQL database and put in a nice table
?>

<TABLE WIDTH="100%" border="0" cellspacing="0" cellpadding="2">
<TR ALIGN=\"left\" VALIGN=\"top\">
</TD>
<TD><DIV ALIGN=\"left\">
<?php

// Connect to database and display results

$conn mysql_connect ("$servername""$dbusername""$dbpassword");
mysql_select_db ("$dbname");

$result mysql_query("SELECT * FROM birthsys WHERE month= $month AND day= $date");
echo 
"<b>Today's Birthday: </b>";
if(
$result)
{
while(
$row mysql_fetch_array($result))
{

$day $row[day];
$name $row[name];


echo 
$name;
echo 
', &nbsp;';

}
}
elseif(!
$result) {
echo 
"<b>Sorry, no birthday's today</b>";
}
mysql_close($conn);
?>
</DIV></TD></TR></table>
i also added the mysql_close() to close the connection to mysql for optimizie
now if theres no birthday it will print Sorry, no birthday's today
you can change it if you want but you get the gist.

<?Willie?>
i use
PHP Code:

elseif(!$result
as a form as error checking really, we all have our different ways.

I dont know why theres a table in the script, keep it tidy I suppose.
Reply With Quote
  #7 (permalink)  
Old 11-20-04, 11:54 AM
korro korro is offline
Newbie Coder
 
Join Date: Mar 2004
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
I have put in the script part you said (Perleo) but still no text.
I have put it in my forum totaly on the end of the page.
http://50308.forum.onetwomax.de/

Last question the lettersize is to big in stead of the rest of the forum how do I change that??
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
trying to create my first simple (?) php script, need guidance HotShotPhoto PHP 1 09-06-04 08:12 PM
Run PHP Script Within PHP Script Reg PHP 1 06-29-04 09:09 AM
posting of results script Sir-ihlatrebon Script Requests 0 02-17-04 11:46 AM
100 Web Templates & 10 PHP Scripts for sale! HostersUK.co.uk General Advertisements 0 01-10-04 12:31 AM
Affiliate script (PHP) whtiebear Job Offers & Assistance 2 12-21-03 12:12 AM


All times are GMT -5. The time now is 05:14 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.