Computer Webmaster Gaming Console Graphics Forum

Welcome to the Computer Webmaster Gaming Console Graphics Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

MK PitStop Main Earn $25 Earn Money Posting Extras Members Blogs Image Hosting User Pages
Go Back   Computer Webmaster Gaming Console Graphics Forum > Webmaster Forum > Website Coding > PHP
Register FAQ/Rules Become A V.I.P. Member Search Today's Posts Mark Forums Read

PHP PHP for some can be one of the hardest website programming codes, so do you need help on your PHP script, if it is php4, php5 or lower this is the place for you for any PHP help.

Google
Closed Thread
 
LinkBack Thread Tools Display Modes
Old 07-01-2007, 5:12 PM   #1
Jeffrey Ellis
 
Jeffrey Ellis's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Missing Record

Hi--

Well, I have progressed quite a bit with all this, but now I seem to have
something wrong with my while loop.

It seems that every time the script is run, it is missing either the first
(or is it last??) record.

What this script does is do a GET from a link as:

getdbcat.php?categoryh=downloading

So there are several records with that as categoryh. But when actually
executed, there will always be one record missing (not displayed). I have
records 1-90 as having that as a categoryh, and my database unsorted goes
from 90 to 1. It is always record 90 that is missing...so I think that would
be the first it sees.

I believe there must be something wrong with my while statement which is
repeated below:

$i = 0;
while($row = mysql_fetch_array($query)) {
$row_class = (($i % 2) == 0) ? $colorblue : $colorwhite;

echo "<tr bgcolor =\"$row_class\">";

$i++;


Here's the complete script:

<?php

$categoryh = addslashes($_GET['categoryh']);

if(empty($categoryh) ) {
echo "Sorry. We couldn't find any ", $categoryh, " Category. Please try
again.";
}
else {
//connect to host

$sConn = mysql_connect("host", "user", "password");
if (!$sConn)
echo "Unable to connect to database server because ".mysql_error();
else {
$dConn = mysql_select_db("db", $sConn);
if (!$dConn)
echo "Unable to connect to database because ".mysql_error();
else {

//find which record has been sent by the GET

$query = mysql_query ("SELECT * FROM articles WHERE
categoryh='$categoryh'" );
$category = ucwords($category);
$row = mysql_fetch_array($query);

?>


<table width="100%" border="0" cellspacing="1" cellpadding="3"
bgcolor="#dcdcdc">
<tr>
<td bgcolor="#3d80e9"><font color="white">Drumbeat TIL
Articles</font></font></td>

</tr>
</table> <table width="100%" border="0" cellspacing="1"
cellpadding="9" bgcolor="#dcdcdc" height="90%">
<tr>
<td valign="top" bgcolor="white"><b><span
class="evenbigger">
<?php
if($categoryh == "gettingstarted")
echo "<b>&quot;I need help ",$row[category],"!&quot;<br><br></b>";
else {
echo "<b>&quot;I need help with
",$row[category],"!&quot;<br><br></b>";
}

}
}
}
?>

</span></b><br>
<br>
<table width="100%" border="0" cellspacing="0"
cellpadding="0">
<tr>
<td valign="top">To navigate to other main topic
areas, select a topic from the list above or click the button to the right.
Click a link below to view the support document related to your query.
Contents of this topic area are as follows:</td>
<td valign="top"><a href="indexnew.html"><img
src="/images/support-index.gif" alt="" width="108" height="31" align="right"
border="0"></a></td>
</tr>
</table>
<div align="center">
<br>
<table width="90%" border="0" cellspacing="1"
cellpadding="3" bgcolor="silver">
<tr>
<td nowrap bgcolor="#3d80e9"><font
color="white"><b>TIL #</b></font></td>
<td bgcolor="#3d80e9"><font
color="white"><b>Article Subject</b></font></td>
<td bgcolor="#3d80e9"><font
color="white"><b>Last Modified</b></font></td>
</tr>
<?php

$colorblue = "eff3fe";
$colorwhite = "FFFFFF";

$i = 0;
while($row = mysql_fetch_array($query)) {
$row_class = (($i % 2) == 0) ? $colorblue : $colorwhite;

echo "<tr bgcolor =\"$row_class\">";

$i++;

{

?>
<td>
<p><?php echo $row["til_id"]; ?></p>
</td>
<td>
<p><?php echo $row["referrence"]; ?></p>
</td>
<td>
<p><?php echo $row["modified"]; ?></p>
</td>

</tr>

<?php
}

}

echo "</table>";

?>

 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Old 07-01-2007, 5:12 PM   #2
Jeffrey Ellis
 
Jeffrey Ellis's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Missing Record

in article bhr1ud$29chg$1@ID-175424.news.uni-berlin.de, Jon Kraft at
jon@jonux.co.uk wrote on 8/18/03 10:20 AM:

> Jeffrey Ellis wrote:
>
>> It seems that every time the script is run, it is missing either the first
>> (or is it last??) record.
>>
>> <?php
>>
>> $categoryh = addslashes($_GET['categoryh']);
>>
>> if(empty($categoryh) ) {
>> echo "Sorry. We couldn't find any ", $categoryh, " Category. Please try
>> again.";
>> }
>> else {
>> //connect to host
>>
>> $sConn = mysql_connect("host", "user", "password");
>> if (!$sConn)
>> echo "Unable to connect to database server because ".mysql_error();
>> else {
>> $dConn = mysql_select_db("db", $sConn);
>> if (!$dConn)
>> echo "Unable to connect to database because ".mysql_error();
>> else {
>>
>> //find which record has been sent by the GET
>>
>> $query = mysql_query ("SELECT * FROM articles WHERE
>> categoryh='$categoryh'" );
>> $category = ucwords($category);
>> $row = mysql_fetch_array($query);

>
> Hi Jeffrey,
>
> Above you get the first row, and later you start the while loop, which then
> obviously starts at the second row returned.
>
> HTH;
> JOn



Hi, Jon--

Ah! okay...that explains it. However, the reason I put in the line above was
so that the lines just below would work. So although now it is retrieving
all the records correctly, it doesn't seem to be able to fill in the two
echo statements, and so they are blank. Is there any way I can do both?


<?php
if($categoryh == "gettingstarted")
echo "<b>&quot;I need help ",$row[category],"!&quot;<br><br></b>";
else {
echo "<b>&quot;I need help with
",$row[category],"!&quot;<br><br></b>";
}

Thanks again!

All My Best,
Jeffrey




 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Featured Websites
Free Space
Free Space
Free Space Free Space
Closed Thread
Tags: ,




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding record to a MYSQL DB using PHP ? James PHP 1 07-01-2007 3:32 PM
UPDATE a record in MYSQL DB with PHP James PHP 1 07-01-2007 3:32 PM
Random Record Disco PHP 0 07-01-2007 3:11 PM
Is it possible to update a record if it does not exist? Jeff Silverman Database 1 06-10-2007 12:21 AM
Am i missing something here... Ridwan Hughes Ebay Technical Questions 2 05-30-2007 2:09 AM


Featured Websites




All times are GMT +1. The time now is 7:32 PM.


Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.0.0
Cheap Computers
MK PitStop Copyright 2005 - 2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98