You are here: Re: NEWBIE to php « PHP SQL « IT news, forums, messages
Re: NEWBIE to php

Posted by Jim Michaels on 01/10/06 03:46

I guess I am not sure why the while loop on a COUNT(*). threw me off for a
bit. You don't really need it do you?
"Jim Michaels" <jmichae3@yahoo.com> wrote in message
news:JdSdneNhEa99jV7eRVn-ug@comcast.com...
> there is a function in the PHP manual under MySQL functions called
> mysql_num_rows(resource result)
> for example, mysql_num_rows($result)
> Jim
> <vncntj@hotmail.com> wrote in message
> news:1135397474.371278.241950@z14g2000cwz.googlegroups.com...
>>I apologize for asking such an easy question but I'm trying to check if
>> the recordcount is "1". If so, it should redirect the page.
>> <?php
>>
>> // Connecting, selecting database
>> $link=mysql_connect ("localhost", "user", "password") or die ('I cannot
>> connect to the database because: ' . mysql_error());
>> mysql_select_db ("dbData");
>> $slogin = trim($HTTP_POST_VARS["tlogin"]);
>> // Performing SQL query
>> $query = "SELECT Count(*) FROM tusernames WHERE logins = '$slogin'";
>> $result = mysql_query($query) or die('Query failed: ' . mysql_error());
>>
>>
>> if ($HTTP_POST_VARS["postback"]=="y") {
>> // Printing results in HTML
>>
>> echo "<table>\n";
>> echo "\t<tr>\n";
>> echo "\t</tr>\n";
>>
>> while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
>> echo "\t<tr>\n";
>> foreach ($line as $col_value) {
>> echo "\t\t<td>$col_value</td>\n";
>> }
>> echo "\t</tr>\n";
>> }
>> echo "</table>\n";
>> }
>>
>> // This is where I'm having difficulty....
>>
>> if ($col_value) == "1" {
>> header("www.espn.com"); /* Redirect browser */
>>
>> /* Make sure that code below does not get executed when we redirect. */
>> exit;
>> }
>>
>> // Free resultset
>> mysql_free_result($result);
>>
>> // Closing connection
>> mysql_close($link);
>> ?>
>> <form action="login.php" method="post">
>> <input type="hidden" name="postback" value="y">
>> <input name="tlogin" type="text" id="tlogin">
>> <br>
>> <input type="submit">
>> </form>
>> </body>
>> </html>
>>
>
>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация