[CS-FSLUG] Looking for tips

David M. dave at edificationweb.com
Fri Jul 2 12:11:15 CDT 2004


On Friday 02 July 2004 12:43 pm, David M. wrote:
> On Friday 02 July 2004 10:51 am, Steven Fricke wrote:
> > Still got it wrong!
> >
> > I should never reply to emails with code the day before vacation!
> >
> > if ($datareturned > '') {
> > echo "<table>
> > bla bla bla
> > </table>";
> > }
> >
> > Actually, you can take it a little father with an else
> >
> > if ($datareturned > '') {
> > echo "<table>
> > bla bla bla
> > </table>";
> > } else {
> > echo "There is no data\n";
> > }
> >
> > I will be happy to send you the code for a page or two where I do this.
>
> Thanks Steven, I'd appreciate it.
>
> I was about to throw together a simple page to test my hand at this and I
> am slightly stuck and highly mad at myself for not coding in the past few
> months and now I have totally forgot how to use my sql statements.
>
> I am very fusturated right now, cuz this once was a simple task, now turned
> into almost a complete headache.
>
> I am so mad at myself right now. I cannot figure why this code keeps
> displaying "Resource Id #3" on the page instead of the contents of the
> field.
>
> mysql_select_db('testing', $connect);
> $myquery = "SELECT * FROM phpstore";
> $result = mysql_query($myquery, $connect);
> while ($row = mysql_fetch_row($result));
> echo $result;
>
> I've even tried:
> echo $row[1];
> echo $row["1"];
> echo $row[0];
>
> Still I either get the output "Resource Id #3" or nothing at all instead of
> the desired contents of the "name" field.
>
> I am very upset with this.

now after a couple minutes of looking and looking at the code, I finally 
realized some of my errors, and here's working code now:

mysql_select_db('testing');
$myquery = "SELECT * FROM phpstore";
$result = mysql_query($myquery);
while ($row = mysql_fetch_array($result)){
echo $row[0]; 
}

But this isn't what im trying to achieve.

What im trying to achieve is being able to use:
echo $result, so I can have all the data fields displayed.

So, since it's been so long since I've actually done this, some of it is 
starting to come back to me after I finally correct the above.

Now I think to solve my actual problem is to use a for loop instead of the 
while loop.

-- 
David M.




More information about the Christiansource mailing list