lilbadger25 Posted January 31, 2008 Share Posted January 31, 2008 if i have a db table that contains client names, how would i output the results to a web page in a table with two columns? Quote Link to comment https://forums.phpfreaks.com/topic/88779-output-in-html-table-question/ Share on other sites More sharing options...
sKunKbad Posted January 31, 2008 Share Posted January 31, 2008 This is the most basic of all web database application programming. You should read a php/mysql book. Quote Link to comment https://forums.phpfreaks.com/topic/88779-output-in-html-table-question/#findComment-454713 Share on other sites More sharing options...
rhodesa Posted January 31, 2008 Share Posted January 31, 2008 It's pretty much copy/paste from Example #1 on http://us3.php.net/mysql Quote Link to comment https://forums.phpfreaks.com/topic/88779-output-in-html-table-question/#findComment-454720 Share on other sites More sharing options...
lilbadger25 Posted January 31, 2008 Author Share Posted January 31, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/88779-output-in-html-table-question/#findComment-454747 Share on other sites More sharing options...
lilbadger25 Posted January 31, 2008 Author Share Posted January 31, 2008 To clarify, I can format output in a table with a single column. I would like to format the output from one field into TWO columns. That is what i can't wrap my head around right now. Quote Link to comment https://forums.phpfreaks.com/topic/88779-output-in-html-table-question/#findComment-454763 Share on other sites More sharing options...
nafetski Posted January 31, 2008 Share Posted January 31, 2008 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>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/88779-output-in-html-table-question/#findComment-454784 Share on other sites More sharing options...
lilbadger25 Posted February 1, 2008 Author Share Posted February 1, 2008 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? Quote Link to comment https://forums.phpfreaks.com/topic/88779-output-in-html-table-question/#findComment-454886 Share on other sites More sharing options...
budimir Posted February 2, 2008 Share Posted February 2, 2008 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! Quote Link to comment https://forums.phpfreaks.com/topic/88779-output-in-html-table-question/#findComment-456094 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.