Jump to content

output in html table question


lilbadger25

Recommended Posts

sKunKbad, I appreciate your helpful response. I HAVE read a book, and I CAN do basic PHP but my brain is completely fried at the moment and I was just looking for a little help - friendly reminder of how to do it. I'm under the wire with another application and someone asked me to do this before I left tonight. I can't, for the life of me, clear my head enough to sort it out at the moment. Silly me for extending my hand for a little help on a help forum. I didn't want anyone to do it for me, but to point me in the right direction so I can get out of work in time to open the boxing club.

 

Was it even worth the energy spent typing a response, with no help whatesoever other than the intent to cut me down? I hope you gave yourself a hearty pat on the back for that gem.

 

rhodesa, thanks for the link. It reminded me of what needed to be done and I'm on my way.

Link to comment
Share on other sites

You can read any tutorial out there on how to do this - but here is a quick example.

 

<?php
$host="";
$username="";
$password="";

mysql_connect($host, $username, $password);
@mysql_select_db('yourdatabasename') or die("Oops!  That database isn't available");
$q="SELECT * from yourdatabasetable WHERE adatabasefield='whatevervaluethatyouaresearchingfor'";

$result=mysql_query($q) or die(mysql_error());

// Going to assume that you have a table with 2 colums...just username and password for this example


echo "<table border='0' cellspacing='0' cellpadding='0'>;

while($row=mysql_fetch_array($result)){

echo "<tr>";
echo "<td>".$row['username']."</td>";
echo "<td>".$row['password']."</td>";
echo "</tr>";
}

echo "</table>";

?>

 

 

Link to comment
Share on other sites

Thanks, nafetski, for your response. I appreciate your time.

 

Let me clarify, again. I know how to echo information into a table. I can echo one field in one <td>, I can echo two fields in two <td>s. What I want to do is echo one field and have the output split into two <td>s. I dont want one looooong column, I want two columns, that are evenly distributed with clients' names.

 

I have a db table that has multiple fields BUT I want to list ONLY the clients' names (a SINGLE field in my table) and I would like to echo it so it shows up in two tables on the web page.

 

List all the clients (ONLY), in two columns on the webpage.

 

Does that clarify what I'm asking?

Link to comment
Share on other sites

Thanks, nafetski, for your response. I appreciate your time.

 

Let me clarify, again. I know how to echo information into a table. I can echo one field in one <td>, I can echo two fields in two <td>s. What I want to do is echo one field and have the output split into two <td>s. I dont want one looooong column, I want two columns, that are evenly distributed with clients' names.

 

I have a db table that has multiple fields BUT I want to list ONLY the clients' names (a SINGLE field in my table) and I would like to echo it so it shows up in two tables on the web page.

 

List all the clients (ONLY), in two columns on the webpage.

 

Does that clarify what I'm asking?

 

Hey superdude,

 

Try this peace of code, it will in 2 columns:

 

echo "<table cellspacing=7 border=0 cellpadding=3><tr valign=bottom>";
$i=1;
while ($row = mysql_fetch_array($rezultat)){
echo "<td align=center width='25%' valign=top>";
if ($row["imgdata"])
	echo "<a href='images/".$row["imgdata"]."'><img border=0 src='images/".$row["imgdata"]."' alt='".$row["title"]."' witdh='100' height='100'><br><div style='font-size:1px; margin-top:4px;'> </div><a href='images/".$row["imgdata"]."'>";
echo $row["title"];
echo "</td>";
if ($i%2==0) echo "</tr><tr><td> </td></tr><tr valign=bottom>"; // If you put instead 2 number 4 you will get 4 columns
$i++;
}
echo "</tr></table>";

 

Let me know if that is what you wanted!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.