returning data to a table

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Vicious
Forum Contributor
Posts: 105
Joined: Fri Jun 20, 2003 12:40 pm

returning data to a table

Post by Vicious »

Hey I got a script but its not the table I want. I dont know how to make a table and whenever I do it says unwanted bracket. This is the script.
<?
$db=mysql_connect("localhost","","") or die ("cant connect");
mysql_select_db("team101",$db) or die ("cant change");
$news=mysql_query("select * from team101_news ORDER BY date DESC LIMIT 8") or die ("cant get em");
while($rows=mysql_fetch_array($news)){
$date=$rows["date"];
$author=$rows["author"];
$title1=$rows["title"];
$content=$rows["content"];
$number="100%";

printf("<table cellpadding=2 cellspacing=0 border=0 width=%s>",$number);
echo "<td bgcolor=#DC9322 class='first'><b>$title1</b></td>";
echo "<td align=right bgcolor=#DC9322 class='first'>$date</td><tr>";
echo "$content";
echo "<td colspan=2><i>by <A href=\"mailto:$email\">$author</a></i><br>;
</td></table><p>";
}
?>
Vicious
Forum Contributor
Posts: 105
Joined: Fri Jun 20, 2003 12:40 pm

Post by Vicious »

Also u can see it at http://www.team101.net
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

Post by ol4pr0 »

I do not follow youre complete question exempt you dont know how to create a table?

What table do you want?
Vicious
Forum Contributor
Posts: 105
Joined: Fri Jun 20, 2003 12:40 pm

Post by Vicious »

let me make one Just a sec
Vicious
Forum Contributor
Posts: 105
Joined: Fri Jun 20, 2003 12:40 pm

Post by Vicious »

User avatar
Derfel Cadarn
Forum Contributor
Posts: 193
Joined: Thu Jul 17, 2003 12:02 pm
Location: Berlin, Germany

Post by Derfel Cadarn »

I suggest you read a bit more about HTML, e.g. at W3Schools. They have a great help about HTML, including about tables.
You're missing the row-tag <tr>!!
Vicious
Forum Contributor
Posts: 105
Joined: Fri Jun 20, 2003 12:40 pm

Post by Vicious »

i know what im doing with html, Whenever i delete the table it comes up with an error. And if i change the table to something else it comes up with a different error.
User avatar
Derfel Cadarn
Forum Contributor
Posts: 193
Joined: Thu Jul 17, 2003 12:02 pm
Location: Berlin, Germany

Post by Derfel Cadarn »

i know what im doing with htm
You said yourself that you do not:
I dont know how to make a table and whenever I do it says unwanted bracket.
:twisted: [/quote]
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

Post by ol4pr0 »

This is a part of some script in one of my history books ( the compleet script is somewhere on this forum tho ;-) )

however it does describe how to create such a table as you have in youre table.htm ( are you using a frontpage ? ) i hate those... they make everthing easy but also unclear !!

MY CODE:

Code: Select all

/*
 just change the class="r" in align=right  class="v" in bgcolor=''" 
*/
 echo "<tr class="V"> ";
 echo "<td width="100" class="v"> ";
 echo "<div class="r">Numero Paquete</div> ";
 echo "</td>\n ";
 echo "<td width="150"> ";
 echo $row['Paqnr'];
 echo "		</td>\n ";
 echo "	   </tr>\n ";
Decided to show you how my table works ... ofcourse you do need to edit some things.. but it basicly works the same as you have it all the way up.

Code: Select all

<?
require ("include/styles.php");

// formulario, solo pone el codigo paquete
ECHO <<<HTML
<html>
<head>
<body class="v">
<form name="retrieve" action={$_SERVER['PHP_SELF']} method="GET" class="center">
<table width="250" border="0" class="center" cellpading="3">
 <tr>
  <td>
   <div class="center"><b>Informacion de to Consulta</b></div>
   </td>
  </tr>
  Enter Paq. number:<input type="text" name="Paqnr">
  <br>
  <Div class="r"><input name="submit" type="submit" ID="Paqnr" WIDTH="5"
  CLASSID="CLSID:B6FC3A14-F837-11D0-9CC8-006008058734"></div>
HTML;

// connectarse con el sql

$dbase ="home";
$tablename ="pongo";
$connect= mysql_connect('localhost')
	or die("Cant connect: " .mysql_error());

// connectarse con el base datos

mysql_select_db($dbase, $connect); 

// consultar el tabla pongo ( cambiar cuando listo )
if (isset($_GET['Paqnr'])) { // Only execute this code if the Paqnr variable isset 
   
$query = "SELECT * FROM pongo WHERE Paqnr='" .$_GET['Paqnr']. "'";
$result = mysql_query($query);
if($row = mysql_fetch_array($result))
{
 echo "<tr class="V"> ";
 echo "<td width="100" class="v"> ";
 echo "<div class="r">Numero Paquete</div> ";
 echo "</td>\n ";
 echo "<td width="150"> ";
 echo $row['Paqnr'];
 echo "		</td>\n ";
 echo "	   </tr>\n ";	
 echo "<tr class="V"> ";
 echo "<td width="100" class="v"> ";
 echo "<div class="r">Empresa</div> ";
 echo "</td>\n ";
 echo "<td width="150"> ";
 echo $row['Empresa'];
 echo "		</td>\n ";
 echo "	   </tr>\n ";	
 echo "<tr class="V"> ";
 echo "<td width="100" class="v"> ";
 echo "<div class="r">Codigo</div> ";
 echo "</td>\n ";
 echo "<td width="150"> ";
 echo $row['Codigo'];
 echo "		</td>\n ";
 echo "	   </tr>\n ";	
 echo "<tr class="V"> ";
 echo "<td width="100" class="v"> ";
 echo "<div class="r">Envio</div> ";
 echo "</td>\n ";
 echo "<td width="150"> ";
 echo $row['Envio'];
 echo "		</td>\n ";
 echo "	   </tr>\n ";	
 echo "<tr class="V"> ";
 echo "<td width="100" class="v"> ";
 echo "<div class="r">Desde</div> ";
 echo "</td>\n ";
 echo "<td width="150"> ";
 echo $row['Desde'];
 echo "		</td>\n ";
 echo "	   </tr>\n ";	
 echo "<tr class="V"> ";
 echo "<td width="100" class="v"> ";
 echo "<div class="r">Comentario</div> ";
 echo "</td>\n ";
 echo "<td width="150"> ";
 echo $row['Comentario'];
 echo "		</td>\n ";
 echo "	   </tr>\n ";
 echo "<tr class="V"> ";
 echo "<td width="100" class="v"> ";
 echo "<div class="r">Informacion</div> ";
 echo "</td>\n ";
 echo "<td width="150"> ";
 echo $row['Information'];
 echo "		</td>\n ";
 echo "	   </tr>\n ";	
 echo "<tr class="V"> ";
 echo "<td width="100" class="v"> ";
 echo "<div class="r">Peso Total</div> ";
 echo "</td>\n ";
 echo "<td width="150"> ";
 echo $row['Peso_Total'];
 echo "		</td>\n ";
 echo "	   </tr>\n ";
 echo "<tr class="V"> ";
 echo "<td width="100" class="v"> ";
 echo "<div class="r">Valor</div> ";
 echo "</td>\n ";
 echo "<td width="150"> ";
 echo $row['Valor'];
 echo "		</td>\n ";
 echo "	   </tr>\n ";	
 echo "<tr class="V"> ";
 echo "<td width="100" class="v"> ";
 echo "<div class="r">Peso</div> ";
 echo "</td>\n ";
 echo "<td width="150"> ";
 echo $row['Peso'];
 echo "		</td>\n ";
 echo "	   </tr>\n ";	
}
}
echo "</td>\n"; 
echo "</tr>\n";
echo " </table>\n";
echo " </form>\n";
?>
Vicious
Forum Contributor
Posts: 105
Joined: Fri Jun 20, 2003 12:40 pm

Post by Vicious »

ok u seen my news script what I want is for all the information to go the included table file which is http://www.team101.net/table.htm I want that included for it to display the news. So at anytime if i want to change this I can. Are you getting me now?
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

Post by ol4pr0 »

Yes i do know what you mean. however what you basicly ask us to do is to code youre script / youre table.

As you can see in the example above it has basicly all the basics you need. And yes you do need to edit a couple of lines to make it youre own.

But it will be minor changes.

Somebody on this forum said on some page the following

Read it, Than Read it Again, And Again! Than ask youre questions

( wont have it quoted sinds i do not know the exact words )
Vicious
Forum Contributor
Posts: 105
Joined: Fri Jun 20, 2003 12:40 pm

Post by Vicious »

Ive tried and tried for more then 4 hours. I have not a clue on what to do.
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

Post by ol4pr0 »

WEll i really suggest like Darfel did, that you read up on these.

Tables http://www.w3schools.com/html/html_tables.asp

And start here on how to code in PHP.

Learn PHP http://www.php.net/manual/en/
Vicious
Forum Contributor
Posts: 105
Joined: Fri Jun 20, 2003 12:40 pm

Post by Vicious »

ok stop with the tables im using dreamweaver for html. And those tutorials are crap. Ive read about 5 of them.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Okay I'm confused.... what are you asking?
Post Reply