Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Listing multiple DB entries
Old 08-14-2005, 09:15 PM Listing multiple DB entries
Junior Talker

Posts: 1
Trades: 0
Hello, I am working on a comic website. I am trying to get my news replies to list but for some reason it is only listing 1 of the replies for this comic. (Each news post/reply is stored by each comic_id to keep them together).

What I want, is for the all the replies to list under the main post. Currently my DB has 2 replies for comic_id 1. (This is comic 1)

I believe it's something simple I could be overlooking but I will bold the 'replies' part of my file.

The site URL is http://www.robobo.com/soon/index.php

You can see if you scroll down how only 1 reply shows up under the news post.

Any help, compadres?

PHP Code:
$query="SELECT * FROM replies WHERE comic_id='$comicid' ORDER BY reply_id ASC";
$mysql_stuff mysql_query($query);
if (
mysql_num_rows($mysql_stuff) == 0){
    print(
"");
}
while(
$roc mysql_fetch_row($mysql_stuff)){
    
$replyid=$roc[0];
    
$replyuser=$roc[2];
    
$replytitle=$roc[3];
    
$replytext=$roc[4];
    
$replytime=$roc[5];
    
$replyuseravatar=$roc[6];
    
$replyuseremail=$roc[7];
print(
"<tr><td><div align=\"left\"><font size=\"2\" face=\"Arial, Helvetica, sans-serif\"><strong>$replytitle</strong></font></div></td>
</tr>
<tr> 
<td height=\"68\"> <table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"3\">
<tr> 
<td width=\"8%\" height=\"68\" valign=\"bottom\"> 
<font size=\"2\" face=\"Arial, Helvetica, sans-serif\"><img src=\"
$replyuseravatar\"></font></td>
<td width=\"92%\"><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">Posted 
by: <a href=\"
$replyuseremail\">$replyuser</a><br>
Date: 
$replytime</font></td>
</tr>
</table></td>
</tr>
<tr> 
<td><div align=\"left\"><font size=\"2\" face=\"Arial, Helvetica, sans-serif\">
$replytext</font></div></td>
</tr>
<tr> 
<td><div align=\"center\"><img src=\"images/updatebreak-graphic.gif\" width=\"545\" height=\"20\"></div></td>
</tr>"
);

robobo is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-14-2005, 09:43 PM
asm
Extreme Talker

Posts: 217
Location: UK.Lancashire(true)
Trades: 0
hmm i think you should echo the number of rows to see if the problem is in the query or the loop, that way we will have a better idea where to look

$aNum = mysql_num_rows($mysql_stuff);
echo $aNum;
exit;

by the way this line never does anything
if (mysql_num_rows($mysql_stuff) == 0)
{
print("");
}
if true it prints nothing and if false it prints nothing, perhaps it is for debugging?
asm is offline
Reply With Quote
View Public Profile Visit asm's homepage!
 
Old 08-14-2005, 09:43 PM
amw_drizz's Avatar
Ultra Talker

Posts: 340
Name: Jon
Location: New York
Trades: 0
Look at my thread about what i was doing. here is my functional code. it displays different links that are in a mysql db
PHP Code:
<? 
require_once("config/mysql.php"); 
$submit_link $_GET['submitlink'];
if (
$submit_link == 1){
include(
"submit_link_form.php");
exit;
}
echo 
'<h1>Links</h1>
<br>To Submit a link <a href="?p=links&submitlink=1">Click Here</a>
<br>
<br>
<table width="798" height="93" border="0">
  <tr>
    <td width="163" height="32">Site Name </td>
    <td width="111">Link</td>
    <td width="179">Clicks In </td>
    <td width="189">Who Submited</td>
    <td width="134">Date Added </td>
  </tr>
  <tr>'
;

$color1 "#003333";
$color2 "#330000";
$limit 25;
if (isset(
$_GET['startnum'])){
    
$startrow $_GET['startnum'];
    
$endnum $startrow $limit;
}
else {
    
$startnum 0;
    
$endnum 25;
}
$int 25;
$nextnum = ++$endnum;
$previos $startnum $int;
$res "SELECT * FROM links WHERE activated = 1 LIMIT $startnum,$endnum";
$subres mysql_query($res) or die(mysql_error());
$num mysql_num_rows($subres) or die(mysql_error());

if (
$subres == 0){
echo 
"No Links";
exit;
}

$i=0;
while (
$row mysql_fetch_array($subres)) {

$id $row['id'];
$sitename $row['site_name'];
$link $row['link'];
$in $row['link_in'];
$submited $row['submiter'];
$date_added $row['date_submitted'];
$activated $row['activated'];

$row_color = ($i 2) ? $color1 $color2;


echo 
"<td bgcolor=$row_color><font face='Arial, Helvetica, sans-serif'>$sitename</font></td>
    <td bgcolor=
$row_color><font face='Arial, Helvetica, sans-serif'><a href='script/redirect.php?id=$id'>$sitename</a></font></td>
    <td bgcolor=
$row_color><font face='Arial, Helvetica, sans-serif'>$in</font></td>
    <td bgcolor=
$row_color><font face='Arial, Helvetica, sans-serif'>$submited</font></td>
    <td bgcolor=
$row_color><font face='Arial, Helvetica, sans-serif'>$date_added</font></td>
    </tr>"
;

$i++;

}


echo 
"</table>";
?>
<center><a href="?p=links&startnum=<? echo $previous?>">Previous</a>  <a href="?p=links&startnum=<? echo $nextnum?>">Next</a></center>
<p>&nbsp; </p>
</body>
</html>
Edit: Although mine is not as complicated as yours is
__________________
AMW_Drizz
Dev Machine:: Apache 2.2.6 PHP 5.2.6 MySQL 5.1
amw_drizz is offline
Reply With Quote
View Public Profile Visit amw_drizz's homepage!
 
Reply     « Reply to Listing multiple DB entries
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.17979 seconds with 12 queries