tags:

views:

85

answers:

4

hi guys i want to display all my data in table format

i try following code but it gives error :" Fatal error: Maximum execution time of 30 seconds exceeded in C:\Temp\5Aug2010\test.php on line 35 "

this is my code :

<?php    
// Connects to your Database 

    mysql_connect("localhost", "root", "") or die(mysql_error()); 
    mysql_select_db("spip210x100726120331") or die(mysql_error()); 

    $select = "select nom from spip_meta where impt='non'";
    $add_news = mysql_query($select) or trigger_error(mysql_error().$select);



    mysql_close();
    ?>
    <table border="0">
           <tr><td>nom</td></tr>
    <?php
    while($num=mysql_numrows($add_news))
            {
                $userid = $num['nom'];
               ?> 
        <tr>
                <td width="30px"> <?php $userid ?></td>


            </tr>
         <?php   } ?>

        </table> 
+6  A: 
Sarfraz
the error is gone but it can not display data,page is blank
Pratikg88
@Pratikg88: See my updated answer please.
Sarfraz
hey thanks dude , its work.now if i want to give hyperlink to every data which are listed on page.what should i do?can you plz tell me,if possible.
Pratikg88
You mean this: `<a href="url here"><?php echo $userid; ?></a>'
Sarfraz
A: 

Try to increase execution time: ini_set('max_execution_time', 420); //420 seconds = 7 minutes

Centurion
+2  A: 

The line while($num=mysql_numrows($add_news)) is wrong - have a look at it. There, you wrote an infinite loop ...

Marius Schulz
+1  A: 

Hi, Kindly find the code below to the run the operation on the database successfully.

mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("spip210x100726120331") or die(mysql_error());

$select = "select nom from spip_meta where impt='non'";
$add_news = mysql_query($select) or trigger_error(mysql_error().$select);

?>
<table border="0">
       <tr><td>nom</td></tr>
<?php

// mysql_num_rows returns the number of rows for the result so to access the result you need to use the mysql_fetch_array() method. It returns the array for the result set.

while($num=mysql_fetch_array($add_news)) 
        {
            $userid = $num['nom'];
           ?> 
    <tr>
            <td width="30px"> <?php $userid ?></td>


        </tr>
     <?php   } ?>

    </table> 
Codemaster Darklord