473,395 Members | 1,649 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

It's my birthday... Please help me!

Aaaaaaaaaaaahhhhhhhhhhhhh

I can't figure out how to get the results to display in a multi-column
table, no matter how I try to format things I still get just one big
long line of images and links...

Ideally I'd like to break the results into a 4x5 table...

-----------------------------------------------------------------------

$result = mysql_query($sql, $conn) or die(mysql_error());
// go through each row in the result set and display data

while ($newArray = mysql_fetch_array($result)) {
// give a name to each of the fields
$id = $newArray['ProductID'];
$producturl = $newArray['ProductURL'];
$artist = $newArray['Artist'];
$price = $newArray['Price'];
$imageurl = $newArray['ImageURL'];
$title = $newArray['Title'];

//echo the results onscreen

echo "<table width=\"100%\"><tr><td align=\"center\">$id<br><a
href=\"$producturl\">$title</a><br><a href=\"$producturl\"><img
src=\"$imageurl\" border=\"0\"></a></td></tr></table>";
}
?>
Thanks to anyone and everyone that is willing to help.

Don Bedford.
p ------------------------------------------------------ 9
| _ _ |
| / *-* ( ... Play guitar? |
| ( | (O) |=|=|=|=|=(:::} http://www.donnybravos.com |
| \_ .-._( ''' Take a peek! |
| |
b--------------------------------------------------------d
Jul 20 '05 #1
8 1227
Webmaster wrote:
I can't figure out how to get the results to display in a multi-column
table, no matter how I try to format things I still get just one big
long line of images and links...


This is not a problem with MySQL, it is a problem with either html or
with php.

Happy birthday and next time, plese use better subject line.
Jul 20 '05 #2
Webmaster wrote:
I can't figure out how to get the results to display in a multi-column
table, no matter how I try to format things I still get just one big
long line of images and links...


This is not a problem with MySQL, it is a problem with either html or
with php.

Happy birthday and next time, plese use better subject line.
Jul 20 '05 #3
"Webmaster" <do*@donnybravos.com> wrote
Ideally I'd like to break the results into a 4x5 table...

Okay...you have six variables...but a 4X5 table has 20 spaces. Can you
explain a bit more about how you want the table to look?
Jul 20 '05 #4
"Webmaster" <do*@donnybravos.com> wrote
Ideally I'd like to break the results into a 4x5 table...

Okay...you have six variables...but a 4X5 table has 20 spaces. Can you
explain a bit more about how you want the table to look?
Jul 20 '05 #5
"Experienced but Undocumented" <e0*@removethis.toao.net> wrote in message
Okay...you have six variables...but a 4X5 table has 20 spaces. Can you
explain a bit more about how you want the table to look?


....

Thanks for your reply. I'll do my best to describe what I'd like to
do with the table...

I've got a database table set up so that each row represents a product
with each field containing information for the product.

I'm using the variables to produce the Image, link, description etc...
one product per cell in a table.

It's working... the image, link, and description etc show up, one
product per cell, but I can't figure out how to script it so that the
table isn't just 50 cells wide. I think what I need the script to do
is count each occurence of <td></td> and every 4 occurences have it
echo </tr><tr>?

But I haven't a clue as to how to go about doing that.

Am I even on the right track?

Thanks again!

Don Bedford.
<?php

// open connection
$conn = mysql_connect("localhost", "my_username", "pass");

// pick database
mysql_select_db("my_database",$conn);

// sql statement
$sql = "SELECT * FROM mytable";

// execute the sql statement
$result = mysql_query($sql, $conn) or die(mysql_error());

// go through each row in the result set and display data
while ($newArray = mysql_fetch_array($result))

{

// give a name to each of the fields
$producturl = $newArray['ProductURL'];
$imageurl = $newArray['ImageURL'];
$title = $newArray['Title'];

//echo the results onscreen
echo "<a href=\"$producturl\"><img
src=\"$imageurl\" border=\"0\"></a><br><a
href=\"$producturl\">$title</a></td><td>";

}

?>
</tr>
</table>
Jul 20 '05 #6
"Experienced but Undocumented" <e0*@removethis.toao.net> wrote in message
Okay...you have six variables...but a 4X5 table has 20 spaces. Can you
explain a bit more about how you want the table to look?


....

Thanks for your reply. I'll do my best to describe what I'd like to
do with the table...

I've got a database table set up so that each row represents a product
with each field containing information for the product.

I'm using the variables to produce the Image, link, description etc...
one product per cell in a table.

It's working... the image, link, and description etc show up, one
product per cell, but I can't figure out how to script it so that the
table isn't just 50 cells wide. I think what I need the script to do
is count each occurence of <td></td> and every 4 occurences have it
echo </tr><tr>?

But I haven't a clue as to how to go about doing that.

Am I even on the right track?

Thanks again!

Don Bedford.
<?php

// open connection
$conn = mysql_connect("localhost", "my_username", "pass");

// pick database
mysql_select_db("my_database",$conn);

// sql statement
$sql = "SELECT * FROM mytable";

// execute the sql statement
$result = mysql_query($sql, $conn) or die(mysql_error());

// go through each row in the result set and display data
while ($newArray = mysql_fetch_array($result))

{

// give a name to each of the fields
$producturl = $newArray['ProductURL'];
$imageurl = $newArray['ImageURL'];
$title = $newArray['Title'];

//echo the results onscreen
echo "<a href=\"$producturl\"><img
src=\"$imageurl\" border=\"0\"></a><br><a
href=\"$producturl\">$title</a></td><td>";

}

?>
</tr>
</table>
Jul 20 '05 #7
"Webmaster" <do*@donnybravos.com> wrote in message
news:df**************************@posting.google.c om...
It's working... the image, link, and description etc show up, one
product per cell, but I can't figure out how to script it so that the
table isn't just 50 cells wide. I think what I need the script to do
is count each occurence of <td></td> and every 4 occurences have it
echo </tr><tr>?

Okay, how about this:

<?PHP

$number_of_columns = 4;

$result = mysql_query($sql, $conn) or die(mysql_error());
// go through each row in the result set and display data

echo "<TABLE width='100%' cellspacing='0' cellpadding='0'>\n";
echo "<TR>\n";

$count = 0;

while ($newArray = mysql_fetch_array($result)) {
// give a name to each of the fields
$id = $newArray['ProductID'];
$producturl = $newArray['ProductURL'];
$artist = $newArray['Artist'];
$price = $newArray['Price'];
$imageurl = $newArray['ImageURL'];
$title = $newArray['Title'];

// echo the results onscreen
echo "<TD>$id<br><a href='$producturl'>$title</a><br><a
href='$producturl'><imgsrc='$imageurl' border='0'></a></TD>\n";

// Increment the count so we can see which column we're in
$count++;

// If it's the fourth column, start a new row
if ($count == $number_of_columns) {
echo "</TR><TR>\n";
$count = 0;
}

}
// Tidy up the last few cells
if ($count != 0) {
for ($i = 0; $i < $number_of_columns - $count; $i++) { echo
"<TD>&nbsp;</TD>"; }
}

echo "</TR></TABLE>";

?>
Jul 20 '05 #8
"Webmaster" <do*@donnybravos.com> wrote in message
news:df**************************@posting.google.c om...
It's working... the image, link, and description etc show up, one
product per cell, but I can't figure out how to script it so that the
table isn't just 50 cells wide. I think what I need the script to do
is count each occurence of <td></td> and every 4 occurences have it
echo </tr><tr>?

Okay, how about this:

<?PHP

$number_of_columns = 4;

$result = mysql_query($sql, $conn) or die(mysql_error());
// go through each row in the result set and display data

echo "<TABLE width='100%' cellspacing='0' cellpadding='0'>\n";
echo "<TR>\n";

$count = 0;

while ($newArray = mysql_fetch_array($result)) {
// give a name to each of the fields
$id = $newArray['ProductID'];
$producturl = $newArray['ProductURL'];
$artist = $newArray['Artist'];
$price = $newArray['Price'];
$imageurl = $newArray['ImageURL'];
$title = $newArray['Title'];

// echo the results onscreen
echo "<TD>$id<br><a href='$producturl'>$title</a><br><a
href='$producturl'><imgsrc='$imageurl' border='0'></a></TD>\n";

// Increment the count so we can see which column we're in
$count++;

// If it's the fourth column, start a new row
if ($count == $number_of_columns) {
echo "</TR><TR>\n";
$count = 0;
}

}
// Tidy up the last few cells
if ($count != 0) {
for ($i = 0; $i < $number_of_columns - $count; $i++) { echo
"<TD>&nbsp;</TD>"; }
}

echo "</TR></TABLE>";

?>
Jul 20 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

51
by: Sandra | last post by:
I was given this problem for extra credit and I am just stuck ! BTW - I am not asking for source code and I am not asking anyone to do my homework as I do want to learn .. I just need a hint or two...
1
by: Claude Alain | last post by:
Hello! We are a small non-profit organisation with about 400 members. We have created a database using Access97 which contains tombstone information on our members, including home adresses and...
2
by: edwin van rutten | last post by:
Hi I have a personal database of all adresses etceteras of personal contacts and want to sort the birthday dates in such a way that I have a chronological list for this years birthdays. The...
5
by: NomoreSpam4Me | last post by:
Hi, i did a search and find the way to get the birthday without the year. My field is yyyy/mm/dd, (birthday). I also have a day field (1 to 31) and a month field. (1 to 12) My problem is: I...
6
by: kwangbok.kim | last post by:
Hi. I'm major in computer science. While studying with the what kind of document, the problem got. Please help me. The lower part is the program... Programming with visual c++ 6.0 at windows xp...
1
by: natvarmalpani | last post by:
i have table contact which have the userinfo and dateof birth now i have birthday.asp file on which i want to show the birthday in next 7 day ex: current systemdate and currentsystemdate +7 i...
2
by: Paul H | last post by:
I have a db that stores people and their birth dates. On any given day, I need to know who has a 40th birthday one month from now. I will only be running the query on week days but of course some...
1
by: sourabhmca | last post by:
hi friend , I want a store procedure for serching and sending mail whose have birthday. if i find then automatically mail should send to person with msg "happy birthday" this procedure is fired...
1
by: TWX | last post by:
Hi there. I need to create a PHP programme that will return a person's birthday when his class and index number is keyed. I have the neccesary information but I only know how to create the frame of...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.