dear all,
trying to hack the joke database from K. Yank’s immortal “Build Your Own Database…” to more cranky needs of my own, I want Search Results display not only the joke text as programmed by Kevin in Chapter 7:
dear guido2004,
I really liked your brilliant plan, faith I do, and I even implemented your #1 suggestion before pleading for help. Unfortunately, I have no idea how to realize #2 & #3 (the latter sounds rather close to the country music) otherwise I wouldn’t bother the glorious geeks and other kinds of wise guys, would I?
dear all,
No matter how dearly love I “Build Your Own Database Driven Web Site Using PHP & MySQL” I still hezitate to come to a forum and say: Hey guys, go and read Kevin Yank’s book and see if you can help me.
But I don’t have to!
The instructions I got in this here forum were so clear-cut that the problem was solved:
<table border="1"> /*a wrapper table to keep additional columns on the same line with the initial one*/
<tr><td>
/*starts snippet from the book*/
<?php if(isset($jokes)):?>
<table><tr><th> Joke Text</th><th>Options</th></tr>
<?php foreach ($jokes as $joke):?>
<tr valign="top">
<td> <?php print($joke['text']);?></td>
<td>
<form action="" method="post">
<div>
<input type="hidden" name="id" value="<?php print($joke['id']);?>">
<input type="submit" name="action" value="Edit">
<input type="submit" name="action" value="Delete">
</div></form>
</td>
</tr>
<?php endforeach;?>
</table>
<?php endif;?>
</td>
/* the snippet ends and is followed by 2 additional td containing the values in db*/
<td>
<?php if(isset($jokes)):?>
<table>
<?php foreach ($jokes as $comment_pro):?>
<tr valign="top">
<td> <?php print($comment_pro['comment_pro']);?></td>
</tr>
<?php endforeach;?>
</table>
<?php endif;?>
</td>
<td>
<?php if(isset($jokes)):?>
<table>
<?php foreach ($jokes as $comment_con):?>
<tr valign="top">
<td> <?php print($comment_con['comment_con']);?></td>
</tr>
<?php endforeach;?>
</table>
<?php endif;?>
</td></tr></table>
Thank you guido2004!
But…
Well, it works ok, just as I wanted when starting this thread but now I wanna more!
What can I do to have the rows in the table retrived from database be easily distinguished by their background-color (stripes of white and gray, you know).
That trick was not covered in Kevin’s book and I don’t know where to look for the answer.
Dear Steve,
thank you ever so much for your kind attention and help.
Actually, css3 didn’t work for my case or maybe I didn’t implement it the right way in my tries.
The good news is I finally found a working PHP solution. Here is the link
‘http://www.phpro.org/examples/Alternating-Row-Colors.html’
The solution turned out to be so elegant and simple - here’s my hat to the programmer-guy.
All’s well that end’s well.
Good luck.
yours`
sehrguey