[PHP] Re: Need help to create HTML table with 2 columns.

2001-08-26 Thread Alex Sofronie

Try this:
printf("");
while($row=...fetch()) {
printf("%s%s",$string_variable1,
$string_variable2);
}


- Original Message -
From: "John Bass" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, August 23, 2001 6:29 PM
Subject: Re: [PHP] Need help to create HTML table with 2 columns.


> second column should print next record that was returned from the query.
>
> Thanks.
>
> John
>
> >From: "Jeff Lewis" <[EMAIL PROTECTED]>
> >Reply-To: "Jeff Lewis" <[EMAIL PROTECTED]>
> >To: "John Bass" <[EMAIL PROTECTED]>, <[EMAIL PROTECTED]>
> >Subject: Re: [PHP] Need help to create HTML table with 2 columns.
> >Date: Thu, 23 Aug 2001 11:29:36 -0400
> >
> >What did you want in the second column?  I was just going by what you had
> >listed below:  $row->image_link,
> > > > > $row->web_url,$row->image_link, $row->web_url);
> >
> >
> >Jeff
> >- Original Message -
> >From: "John Bass" <[EMAIL PROTECTED]>
> >To: <[EMAIL PROTECTED]>
> >Sent: Thursday, August 23, 2001 11:16 AM
> >Subject: Re: [PHP] Need help to create HTML table with 2 columns.
> >
> >
> > > Hi,
> > >
> > > Thank you for the email.  I tried your code, but first column is
> >printing
> > > image_link & web_url fields correctly and second column is repeating
> >values
> > > of the first column.
> > >
> > > Other records or rows are printing same way.
> > >
> > > Regards,
> > >
> > > John Bass
> > >
> > > >From: "Jeff Lewis" <[EMAIL PROTECTED]>
> > > >Reply-To: "Jeff Lewis" <[EMAIL PROTECTED]>
> > > >To: "John Bass" <[EMAIL PROTECTED]>,
<[EMAIL PROTECTED]>
> > > >Subject: Re: [PHP] Need help to create HTML table with 2 columns.
> > > >Date: Thu, 23 Aug 2001 10:41:08 -0400
> > > >
> > > >John,
> > > >
> > > >Try this:
> > > >
> > > >
> > > > > > >$query = "SELECT image_link, web_url FROM testdata";
> > > >$result = mysql_query ($query) or die ("Query Failed");
> > > >while ($row = mysql_fetch_object ($result))
> > > >  {
> > > >  printf ("".$row->image_links."".$row->web_url."
> > > >".$row->image_link."".$row->web_url."\n");
> > > >  }
> > > >  ?>
> > > >  
> > > >
> > > >- Original Message -
> > > >From: "John Bass" <[EMAIL PROTECTED]>
> > > >To: <[EMAIL PROTECTED]>
> > > >Sent: Thursday, August 23, 2001 10:30 AM
> > > >Subject: [PHP] Need help to create HTML table with 2 columns.
> > > >
> > > >
> > > > > Hi All,
> > > > >
> > > > > I am trying to generate a table with two columns.  Each column
> >should
> > > >print
> > > > > 2 fields named image_link and web_url.  Have spent over week
looking
> > > > > documentations and trying different coding but nothing is working.
> >Any
> > > >help
> > > > > will be greatly appreciated.
> > > > >
> > > > > 
> > > > >  > > > > $query = "SELECT image_link, web_url FROM testdata";
> > > > > $result = mysql_query ($query) or die ("Query Failed");
> > > > > while ($row = mysql_fetch_object ($result))
> > > > > {
> > > > > printf ("%s%s %s%s\n",
> >$row->image_link,
> > > > > $row->web_url,$row->image_link, $row->web_url);
> > > > > }
> > > > > ?>
> > > > > 
> > > > >
> > > > > Regards,
> > > > >
> > > > > John Bass
> > > > >
> > > > > _
> > > > > Get your FREE download of MSN Explorer at
> > > >http://explorer.msn.com/intl.asp
> > > > >
> > > > >
> > > > > --
> > > > > PHP General Mailing List (http://www.php.net/)
> > > > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > > > For additional commands, e-mail: [EMAIL PROTECTED]
> > > > > To contact the list administrators, e-mail:
> >[EMAIL PROTECTED]
> > > > >
> > > > >
> > > > >
> > > >
> > > >
> > > >--
> > > >PHP General Mailing List (http://www.php.net/)
> > > >To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > >For additional commands, e-mail: [EMAIL PROTECTED]
> > > >To contact the list administrators, e-mail:
> >[EMAIL PROTECTED]
> > > >
> > >
> > >
> > > _
> > > Get your FREE download of MSN Explorer at
> >http://explorer.msn.com/intl.asp
> > >
> > >
> > > --
> > > PHP General Mailing List (http://www.php.net/)
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, e-mail: [EMAIL PROTECTED]
> > > To contact the list administrators, e-mail:
[EMAIL PROTECTED]
> > >
> > >
> > >
> >
>
>
> _
> Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: Need help to create HTML table with 2 columns.

2001-08-23 Thread Hugh Bothwell


"John Bass" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Hi All,
>
> I am trying to generate a table with two columns.  Each column should
print
> 2 fields named image_link and web_url.  Have spent over week looking
> documentations and trying different coding but nothing is working.  Any
help
> will be greatly appreciated.

The other answers are generally correct but a bit hard to follow.
Try this:

";
}

// === fn addColumn ==
function addColumn($str) {
global $col, $numcols;

// first column? start row
if ($col == 0)
echo "\n\t";

// echo cell contents
echo "\n\t\t$str";

// last column? end row and reset
$col++;
if ($col == $numcols) {
echo "\n\t";
$col = 0;
}
}

//  fn endTable ===
function endTable() {
global $col, $numcols;

// pad the table as necessary
for ($i = $col; $i < $numcols; $i++)
addColumn(' ');

// end table
echo "\n";
}


// === MAIN =

mysql_connect("host", "user", "pwd")
or die("Error connecting: ".mysql_error());

$query = "SELECT image_link,web_url FROM testdata";
$result = mysql_db_query("db", $query)
or die("Error querying: ".mysql_error());

startTable(2);
while ($row = mysql_fetch_array($result))
addColumn( $row["image_link"].''.$row["web_url"] );
endTable();
?>

How's that?



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]