Jump to content

[SOLVED] Unsure


FirePhoenix

Recommended Posts

Something is wrong but I cant find it can some one help...

 

<font color="#C0C0C0">SDTV Lineup</font><table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%">
<?php
      mysql_connect($dbhost,$dbuser,$dbpass) or die("Unable to connect");
      @mysql_select_db($dbname) or die ("Unable to select database");
      $query="SELECT * FROM $tbl_packages";
      $result=mysql_query($query);

      $num=mysql_numrows($result);

      $i=0;
      while ($i < $num) {

      $name=mysql_result($result,$i,"name");
      $page=mysql_result($result,$i,"page");
      $short=mysql_result($result,$i,"short");
      $price=mysql_result($result,$i,"price");

      mysql_close(mysql_connect($dbhost,$dbuser,$dbpass)); 

?>

          <tr>
            <td width="50%" bgcolor="#9DB2E7"><font color="#FFFFFF"><? echo $name; ?></font></td>
            <td width="50%" bgcolor="#9DB2E7">
            <p align="right"><font color="#FFFFFF">Monthly Price:<? echo $price; ?></font></td>
          </tr>
          <tr>
            <td width="50%"><font color="#C0C0C0"><? echo $short; ?></font></td>
            <td width="50%">
            <p align="right"><font color="#C0C0C0"><a href="<? echo $page; ?>">View More...</a></font></td>
          </tr>
<?
$i++;
}
?>          
</table>

it wont create the table or anything no out put at all I have never done this before please help

Link to comment
https://forums.phpfreaks.com/topic/40187-solved-unsure/
Share on other sites

That's not the desired way to iterate though the result set... mysql_fetch_assoc() keeps an internal pointer to the next record.

 

or there is:

 

$query = mysql_query("INSERT QUERY HERE");
if (mysql_num_rows($query) > 0) {
while($data = mysql_fetch_array($query)){
	... DO STUFF HERE
}
}

 

change part of your script

 

$result=mysql_query($query) or die(mysql_error());

 

your query doesn't look right.

Link to comment
https://forums.phpfreaks.com/topic/40187-solved-unsure/#findComment-194511
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.