Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more

Go Back   Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more > Web Programming > PHP Development
User Name
Password

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 03-23-2008, 03:20 AM   #1 (permalink)
vginov
Junior Member
 
Join Date: Mar 2008
Posts: 6
Default I need the PHP code to display in the proper place in a table

<?php
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("ginsoft");

/* TO CREATE DATABASE
CREATE DATABASE `ginsoft` ; */


/* T0 CREATE TABLE
CREATE TABLE `ginsoft`.`movie` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`title` VARCHAR( 100 ) NOT NULL ,
`image` LONGBLOB NOT NULL ,
`FileType` varchar(32) DEFAULT NULL,
`note` LONGTEXT NOT NULL ,
`link1` LONGTEXT NOT NULL ,
`link2` LONGTEXT NULL ,
`link3` LONGTEXT NULL ,
`link4` LONGTEXT NULL ,
`link5` LONGTEXT NULL ,
PRIMARY KEY ( `id` )
) ENGINE = MYISAM */


?>
<head>
<title>testing</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<!-- ImageReady Slices (Untitled-1) -->
<table id="Table_01" width="181" height="166" border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
<img src="http://www.webmasterforums.com/images/corner1.gif" width="11" height="26" alt=""></td>
<td background="http://www.webmasterforums.com/images/title.gif"> Title should be printed here </td>
<td>
<img src="http://www.webmasterforums.com/images/corner2.gif" width="13" height="26" alt=""></td>
</tr>
<tr>
<td>
<img src="http://www.webmasterforums.com/images/side1.gif" width="11" height="82" alt=""></td>
<td background="http://www.webmasterforums.com/images/image.gif">The image should be printed here </td>
<td>
<img src="http://www.webmasterforums.com/images/side2.gif" width="13" height="82" alt=""></td>
</tr>
<tr>
<td>
<img src="http://www.webmasterforums.com/images/corner3.gif" width="11" height="58" alt=""></td>
<td background="http://www.webmasterforums.com/images/link.gif">The link should be printed here </td>
<td>
<img src="http://www.webmasterforums.com/images/corner4.gif" width="13" height="58" alt=""></td>
</tr>
</table>


<!-- End ImageReady Slices -->
</body>
</html>

<?
/* THE INSERT QUERY

<?php
if ($_POST['Submit']) {
if ($_POST['MAX_FILE_SIZE'] >= $_FILES['file']['size']) {
//print_r($_FILES);
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("ginsoft");
$title = $_POST['txtTitle'];
$link1 = $_POST['txtLink1'];
$link2 = $_POST['txtLink2'];
$link3 = $_POST['txtLink3'];
$link1 = $_POST['txtLink4'];
$link2 = $_POST['txtLink5'];
$photo = addslashes(fread(fopen($_FILES['file']['tmp_name'], "r"),
$_FILES['file']['size']));
$query = sprintf("INSERT INTO movie(title, image, filetype, link1, link2, link3, link4, link5)VALUES
('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')", $title, $photo, $_FILES['file']['type'], $note, $link1, $link2, $link3, $link4, $link5);
if (mysql_query($query)) {
$messages[] = "Your post has been sent to the admin desk";
} else {
$messages[]= mysql_error();
}
} else {
$messages[]="The file is bigger than the allowed size please resize";
}
}
?>

<table>
<form action="" method="post" enctype="multipart/form-data" name="form1">
<tr><td>Title</td><td><input type="text" name="txtTitle"></td></tr>
<tr><td>Image</td><td><input type="file" name="file">
<input type="hidden" name="MAX_FILE_SIZE" value="96000"></td></tr>
<tr><td>Note</td><td><textarea name="txtNote" rows="2" cols="110"></textarea></td></tr>
<tr><td>Link</td><td>
<input type="text" name="txtLink1">
<input type="text" name="txtLink2">
<input type="text" name="txtLink3">
<input type="text" name="txtLink4">
<input type="text" name="txtLink5">
<tr><td></td><td align="right"><input type="submit" name="Submit" value="Submit" onClick="return checkme();"></td></tr>
</form></table> */

?>

In this every row should have the table with the proper images and page should be limited with 10 rows

kindly help me with this.

Your help will save my time and improve my knowledge.

thanks a lot

Last edited by vginov : 03-23-2008 at 03:23 AM.
vginov is offline   Reply With Quote
Sponsored Links
Old 03-23-2008, 03:58 AM   #2 (permalink)
psychdev
Junior Member
 
Join Date: Mar 2008
Posts: 11
Default Re: I need the PHP code to display in the proper place in a table

You want to use a for loop and arrays.

in the form of

$data = array()

$getData = ("SELECT * FROM table")

while($row = @mysql_fetch_array($getData))
{
$data[$row[id]] = $row[columnName];
}

for($i = 0; $i <= (sizeof($data)-1); $i++)
{
echo "<table>";
echo "\n<tr><td>".$data[$i]."</td></tr>";
echo "</table>";
}
psychdev is offline   Reply With Quote
Old 03-23-2008, 04:14 AM   #3 (permalink)
vginov
Junior Member
 
Join Date: Mar 2008
Posts: 6
Default Re: I need the PHP code to display in the proper place in a table

Hi Thanks for the reply


As you said i am able to get the data into the table but i need it in a format as i explained above

<html>
<head><title>Your Page Title</title></head>
<body>
<?php
$database="ginsoft";
mysql_connect ("localhost", "root", "");
@mysql_select_db($database) or die( "Unable to select database");
$result = mysql_query( "SELECT * FROM movie LIMIT 10" )
or die("SELECT Error: ".mysql_error());
$num_rows = mysql_num_rows($result);
print "There are $num_rows records.<P>";
print "<table width=400 border=1>";
while ($get_info = mysql_fetch_row($result)){
print "<tr>";
foreach ($get_info as $field)
print "<td><font face=arial size=1/>$field</font></td>";
print "</tr>";
}
print "</table>";
?>
</body>
</html>


When i use the above code i am able to get the data from the table to the screen

But how can i get it in the exact place?

If you can correct my query that would be a great help

Thanks again
vginov is offline   Reply With Quote
Old 03-23-2008, 05:36 AM   #4 (permalink)
psychdev
Junior Member
 
Join Date: Mar 2008
Posts: 11
Default Re: I need the PHP code to display in the proper place in a table

I would replace this:

print "<table width=400 border=1>";
while ($get_info = mysql_fetch_row($result)){
print "<tr>";
foreach ($get_info as $field)
print "<td><font face=arial size=1/>$field</font></td>";
print "</tr>";
}
print "</table>";

with:

print "<table width=400 border=1>";
print "<tr>";
print "<td>column1name</td>";
print "<td>column2name</td>";
print "<td>column3name</td>";
print "</tr>";
while($row = @mysql_fetch_array($result))
{
print "<tr>";
print "<td>".$row[column1name]."</td>";
print "<td>".$row[column2name]."</td>";
print "<td>".$row[column3name]."</td>";
print "</tr>";
}
print "</table>";


When you use >>> $get_info as $field <<< all of the data is just plugged onto your site. when you use >>>@mysql_fetch_array<<< you can extract each individual columns value, per row. the loop repeats for as many times are there are rows
psychdev is offline   Reply With Quote
Old 03-23-2008, 05:45 AM   #5 (permalink)
vginov
Junior Member
 
Join Date: Mar 2008
Posts: 6
Default Re: I need the PHP code to display in the proper place in a table

Dear Yes

you help me to fix it in the proper place

Million thanks for that.

now when i take the image from the database using the above code, it prints the ascii value. How can i display the image from the database?

I am really glad that you help me a lot..

Thanks a lot..
vginov is offline   Reply With Quote
Old 03-23-2008, 06:50 AM   #6 (permalink)
vginov
Junior Member
 
Join Date: Mar 2008
Posts: 6
Default Re: I need the PHP code to display in the proper place in a table

Hi everyone

Here is the final code i was expecting. I sincerely thank psychdev for his constant help with my need


<html>
<head><title>testing the Display</title></head>
<body>
<?php
$database="ginsoft";
mysql_connect ("localhost", "root", "");
@mysql_select_db($database) or die( "Unable to select database");
$result = mysql_query( "SELECT * FROM movie LIMIT 10" )
or die("SELECT Error: ".mysql_error());
$num_rows = mysql_num_rows($result);
print "There are $num_rows Movies List avialbe.<P>";
print "<table>";
/*print "<tr>";
print "<td>Title</td>";
print "<td>note</td>";
print "<td>link</td>";
print "</tr>"; */
while($row = @mysql_fetch_array($result))
{
print "<tr>";
print "<td><img src=images/cor1.gif></td>";
print " <td background=images/title.gif>".$row[title]."</td>";
print "<td><img src=images/cor2.gif></td>";
print "</tr><tr>";
print "<td><img src=images/lborder.gif></td>";
print "<td>".$row[note]."</td>";
print "<td><img src=images/rborder.gif></td>";
print "</tr><tr>";
print "<td><img src=images/cor3.gif></td>";
print "<td align=center background=images/link.gif>".$row[link1]."<br>".$row[link2]."<br>".$row[link3]."</td>";
print "<td><img src=images/cor4.gif></td>";
print "</tr>";
}
print "</table>";
?>

</body>
</html>


The code in red color is the exact need of mine. I post the code here so that it may be useful or some one who is looking for a code similar to mine.

Now I need a code which can display the image from the database to the browser. If any one can please help me thing this

Thanks a lot
vginov is offline   Reply With Quote
Old 03-24-2008, 10:41 AM   #7 (permalink)
psychdev
Junior Member
 
Join Date: Mar 2008
Posts: 11
Default Re: I need the PHP code to display in the proper place in a table

Do you store the image in the database as text? ie

the database holds 'imagefile.jpg'
psychdev is offline   Reply With Quote
Old 03-24-2008, 10:47 AM   #8 (permalink)
vginov
Junior Member
 
Join Date: Mar 2008
Posts: 6
Default Re: I need the PHP code to display in the proper place in a table

`Image` longblob,

I am storing it as a longblob, But when i display it it is giving me as ascii value
i use print $row['image'];
but i do not know the formated string in printf

such as prinntf("%s",$row['image']);
vginov is offline   Reply With Quote
Old 03-25-2008, 01:36 PM   #9 (permalink)
psychdev
Junior Member
 
Join Date: Mar 2008
Posts: 11
Default Re: I need the PHP code to display in the proper place in a table

i don't think longblob is your best option here.. if possible change it to text string?
psychdev is offline   Reply With Quote
Old 03-25-2008, 02:29 PM   #10 (permalink)
vginov
Junior Member
 
Join Date: Mar 2008
Posts: 6
Default Re: I need the PHP code to display in the proper place in a table

let me try!
I am keep trying!!
vginov is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Points Per Thread View: 1.00
Points Per Thread: 11.00
Points Per Reply: 5.00



» Sponsors

» Links

» Affiliates
Web Hosting
Marketing Find
Merchant Select
SiteMap Builder
Host Compare
Dedicated Servers

» Links

» Sports Network
Paintball Forum
Football Forum
Hockey Forum
Golf Forum
Boxing Forum
Lacrosse Forum
Baseball Forum
SnowBoarding Forum
Soccer Forum
MMA Forum


All times are GMT -4. The time now is 07:12 AM.



LinkBacks Enabled by vBSEO 3.0.0 RC8
Webmaster Forums