Jump to content

PravinS

Members
  • Posts

    459
  • Joined

  • Last visited

  • Days Won

    2

Posts posted by PravinS

  1. use quotes around option value or use select box as

    <select name="charity_name" id="charity_name">
    <?php
        while ($row=mysql_fetch_array($charity))
        {
           echo '<option value="'.$row[charity_name].'">'.$row[charity_name].'</option>'; 
        }
    ?>
    </select>
    
    

    hope this will help you

  2. That solution isn't going to quite work since $row{"visivel"} comes from the first query.

     

     

    @magcr23 - That first query probably is not necessary. The update query will only change visivel when it is equal to zero.

     

    If you need to show the message about the product already being shown, you could use mysql_affected_rows(). More information about the function can be found here:

    http://php.net/manual/en/function.mysql-affected-rows.php

     

    oh sorry, i missed that

  3. You missed mysql_query() for UPDATE query, also SELECT query should be below UPDATE query, so you will get updated data

    <?php
    	require("bd/conexao.php");       
    	if ($row{"visivel"}== 0)
    	{
    		$update= "UPDATE produtos SET visivel = 1 WHERE visivel = 0";
    		mysql_query($update);
    		echo $update;
    	}
    	else
    	{
    		echo "o produto ja esta visivel";
    	}   
    
    	$sql = "SELECT * FROM produtos";
    	$resultado = mysql_query($sql);
    	$row = mysql_fetch_array($resultado);
    ?>
    
  4. Try this query

    SELECT username, count(username) AS post_count FROM TABLE_NAME 
    GROUP BY username
    ORDER BY count(username) DESC;

    you can apply LIMIT to get top records, as query will give sorted result according to max post count of user.

  5. Check this simple logic

     

    <table border="0" cellspacing="0" cellpadding="5">
    <tr>
    <?php
        $array = array(1,2,3,4,5,6);
        $i = 1;
        foreach($array as $val)
        {
            echo '<td>'.$val.'</td>';
            if ($i % 2 == 0)
                 echo "</td></tr>";
          $i++;
        }
    ?>
    </tr>
    </table>
    

    I hope this will help you

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.