SA-MP Forums Archive
PHP + Mysql help - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: Other (https://sampforum.blast.hk/forumdisplay.php?fid=7)
+--- Forum: Everything and Nothing (https://sampforum.blast.hk/forumdisplay.php?fid=23)
+--- Thread: PHP + Mysql help (/showthread.php?tid=453785)



PHP + Mysql help - thimo - 26.07.2013

Okay im trying to get the id from the database and set the link to that ID
this is what i got:
PHP код:
        $sql "SELECT * FROM Clubs"
        
$rs_result mysql_query ($sql,$connection); 
        
$id mysql_fetch_row($sql$connection);
        
$totalIds $row[0]; 
This is the thing i am using in the table:
PHP код:
        <td><? echo "<a href='Clubs.php?id=".$TotalIds."'>" $row["Name"] . "</a>"?></td>
But im getting this warning:
Код:
Warning: mysql_fetch_row() expects parameter 1 to be resource, string given in /home/ws02775/public_html/Clubs.php on line 57



Re: PHP + Mysql help - BlackBank - 26.07.2013

http://php.net/manual/en/function.mysql-fetch-row.php

You filled in the wrong information into mysql_fetch_row.
So:

PHP код:
  $sql "SELECT * FROM Clubs";  
        
$rs_result mysql_query ($sql,$connection);  
        
$row mysql_fetch_row($rs_result);
        
$totalIds $row[0]; 



Re: PHP + Mysql help - thimo - 26.07.2013

Now it shows an empty row table... This is my complete code:
PHP код:
            <div class="right">
<?php
        $sql 
"SELECT * FROM Clubs";   
            
$rs_result mysql_query ($sql,$connection);   
            
$row mysql_fetch_row($rs_result); 
            
$totalIds $row[0];
        while (
$row mysql_fetch_assoc($rs_result)) { 

?> 
<table border="1" width="550">
            <tr>
                <td><? echo $row["ID"]; ?></td>
        <td><? echo "<a href='Clubs.php?id=".$totalIds."'>" $row["Name"] . "</a>"?></td>
               <td><? echo $row["Owner"]; ?></td>
            </tr></table>
<?php 
}; 
?>
What is wrong here?


Re: PHP + Mysql help - GWMPT - 26.07.2013

First of all, don't use mysql, it is deprecated, use mysqli or pdo instead.
Second, try:
PHP код:
            <div class="right">
<table border="1" width="550">
<?php
        $sql 
"SELECT * FROM `Clubs`";   
        
$rs_result mysql_query ($sql,$connection);   
        while (
$row mysql_fetch_array($rs_result)) { 
?> 
            <tr>
                <td><?php echo $row["ID"]; ?></td>
        <td><?php echo "<a href='Clubs.php?id=".$row['ID']."'>" $row["Name"] . "</a>"?></td>
               <td><?php echo $row["Owner"]; ?></td>
            </tr>
<?php 
}
?>
</table>
The code should look something like that.


Re: PHP + Mysql help - thimo - 26.07.2013

Thank you! Thats what i needed!


Re: PHP + Mysql help - GWMPT - 26.07.2013

No problem, glad to help.
If you need help with something else, feel free to send me a pm.


Re: PHP + Mysql help - thimo - 26.07.2013

Sure will!