Jump to content

outatime

New Members
  • Posts

    4
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

outatime's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. phpMyAdmin 2.6.3-pl1 I'm trying to upload a picture to a database. The part I'm really confused about is if the database will actually hold the file or do I need to upload it to the server then somehow put the link in the database. Here is some of the code that I found to use. And how much of this code do I actually need? Thanks if ($act=='view'){ $sql="SELECT * FROM tbl_image where id=$id"; $rst=mysql_query($sql) or die('gagal'); $data=mysql_fetch_array($rst); $type=$data[type]; Header("Content-type: $type"); echo $data[image]; } if ($act=='del'){ $sql="DELETE FROM tbl_image where id=$id"; $rst=mysql_query($sql) or die('gagal'); } if($submit) { $type = $_FILES['file']['type']; copy ($_FILES['file']['tmp_name'], "tmp/tmp.jpg") or die ("Could not copy"); $filer="tmp/tmp.jpg"; $handle = fopen($filer, "r"); $pure = addslashes(fread($handle, filesize($filer))); $sql = "insert into tbl_image(image,type) values('$pure','$type')"; $result = mysql_query($sql,$cn)or die(mysql_error()); } $sql="SELECT * FROM tbl_image"; $rst=mysql_query($sql) or die('gagal'); while ($data=mysql_fetch_array($rst)){ $id=$data[id]; echo "picture no $id <a href='./image.php?act=del&id=$id'>delete</a><br><img src='./image.php?act=view&id=$id'><br><br>"; }
  2. I'm not sure if this is the right forum. But I have a database of products that I want to display. But with PHP/MySql isn't there a way to make the pages generate themselves instead of having to make each page individually, and adding the mysql code to pull the data from the database? I can't remember if there is a way to do this. If so can anyone point me to a tutorial or something? Thanks.
  3. That fixed everything. Thanks a lot!
  4. Hi everyone. I've been trying to figure this out for the last six hours. I'm trying to call info from a database into a table. I want to have alternating colors for the rows which I have succeeded in doing. My problem is that its repeating each line 4 times before it lists the next one. Here is the link: http://southernpartsequipment.com/dasher/minutes.php Here is my code. Hope someone can help. Thanks. <?php $con = mysql_connect("mysql","***","***"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("dasher", $con); $result = mysql_query("SELECT * FROM minutes"); $num_rows = mysql_num_rows($result); echo "<center><table border='0' cellspacing='3' cellpadding='1'> <th>Event</th> <th>Date</th> <th>Minutes</th> <th>PDF</th> </tr>";while($row = mysql_fetch_array($result)) { $num = $result; for($i=0;$i<$num;$i++){ if($i % 2 ==0) { $bgcolor='#adc5c8'; } else { $bgcolor='#eeeeee'; } echo "<tr bgcolor=$bgcolor>"; echo "<td>" . $row['event'] . "</td>"; echo "<td>" . $row['date'] . "</td>"; echo "<td>" . $row['minutes'] . "</td>"; echo "<td>" . "<a href=\"{$row['pdf']}\">Download</a>" . "</td>"; echo "</tr>"; } } echo "</table></center>";mysql_close($con); ?>
×
×
  • 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.