Jump to content

opel

Members
  • Posts

    30
  • Joined

  • Last visited

    Never

Everything posted by opel

  1. I am working on a displaying a list of links in my admin system that I have entered into the Database. Each link is realted to a category that is in a separate table. I have written out an SQL statement that joins the 2 tables together however the variable information isn't writting out onto my page? Can anyone see my error I'm determined to learn how to hand code PHP and stay away from Dreamweavers toolkit. thanks for any help... [code]<table> <tr > <th>Item Description</th> <th>Category</th> <th>Edit</th> <th>Delete </th> </tr> <?php include ('connections/config.php'); include ('connections/dbconn.php'); $query  = "SELECT tbl_links.link_id, tbl_links.link_title, tbl_links.link_desc, tbl_links.category_id, tbl_links.link_display, categories.category_name FROM tbl_links INNER JOIN categories ON tbl_links.category_ID = categories.category_name ORDER BY link_title"; $result = mysql_query($query) or die("error querying database"); $i = 0; while($result_ar = mysql_fetch_assoc($result)){ ?> <tr <?php if($i%2 == 1){ echo "class='tablerow2'"; }else{echo "class='tablerow1'";}?>> <td> <?php echo $result_ar['link_title']; ?></td> <td> <?php echo $result_ar['category_name']; ?> </td> <td class="button"> <a href="edit_link_detail.php?ID=<?php echo $result_ar['link_id']; ?>" title="Edit This Link">Edit</a> </td> <td class="button"> <a href="delete_link.php?ID=<?php echo $result_ar['link_id']; ?>" title="Delete This Link">Delete</a> </td> </tr> <?php $i+=1;                     }?> </table>[/code]
  2. opel

    closing a DB

    sorry can you explain what you mean by adding slashes?
  3. I am learning how to use PHP by hand coding everything. my code below works to pull out a list of web links from the database and display them in a table. My question is should I have a DB close tag somewhere to close the DB for security reasons? Here is my code: [code]<?php include ('connections/config.php'); include ('connections/dbconn.php'); $query  = "SELECT link_id, link_title, link_desc, category_id, link_display FROM tbl_links WHERE link_display='Yes'"; $result = mysql_query($query) or die("error querying database"); $i = 0; while($result_ar = mysql_fetch_assoc($result)){ ?> <tr <?php if($i%2 == 1){ echo "class='tablerow2'"; }else{echo "class='tablerow1'";}?>> <td> <?php echo $result_ar['link_title']; ?></td> <td> <?php echo $result_ar['category_id']; ?> </td> <td class="button"> <a href="edit_link_detail.php?ID=<?php echo $result_ar['website']; ?>" title="Edit This Link">Edit</a> </td> <td class="button"> <a href="delete_link.php?ID=<?php echo $result_ar['website']; ?>" title="Delete This Link">Delete</a> </td> </tr> <?php $i+=1;                     }?> </table>[/code]
  4. cheers got it sorted with the string replace.  ;D
  5. Hi I am new to using PHP but have some experience of using ASP. I want to be able to use PHP to carry out a task similar to ASP's replace function that will look at a string in a variable and replace the first instance it finds of it. for example say my variable string is "t_image.jpg" I would use (replace(<%imagestring&>)value,"t_","",1,1) which would change the string to now just being "image.jpg" Is there a similiar function to this in PHP that will carry out the same task. Thanks for your help.. ;D
×
×
  • 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.