Page 1 of 2
returning data to a table
Posted: Wed Jan 28, 2004 11:23 am
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>";
}
?>
Posted: Wed Jan 28, 2004 11:25 am
by Vicious
Posted: Wed Jan 28, 2004 11:30 am
by ol4pr0
I do not follow youre complete question exempt you dont know how to create a table?
What table do you want?
Posted: Wed Jan 28, 2004 11:32 am
by Vicious
let me make one Just a sec
Posted: Wed Jan 28, 2004 11:36 am
by Vicious
Posted: Wed Jan 28, 2004 1:24 pm
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>!!
Posted: Wed Jan 28, 2004 1:32 pm
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.
Posted: Wed Jan 28, 2004 1:45 pm
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.

[/quote]
Posted: Wed Jan 28, 2004 1:51 pm
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";
?>
Posted: Wed Jan 28, 2004 2:53 pm
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?
Posted: Wed Jan 28, 2004 4:04 pm
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 )
Posted: Wed Jan 28, 2004 4:14 pm
by Vicious
Ive tried and tried for more then 4 hours. I have not a clue on what to do.
Posted: Wed Jan 28, 2004 4:25 pm
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/
Posted: Wed Jan 28, 2004 4:30 pm
by Vicious
ok stop with the tables im using dreamweaver for html. And those tutorials are crap. Ive read about 5 of them.
Posted: Wed Jan 28, 2004 6:55 pm
by John Cartwright
Okay I'm confused.... what are you asking?