Jump to content

RichardRotterdam

Members
  • Posts

    1,509
  • Joined

  • Last visited

Everything posted by RichardRotterdam

  1. you could create a query that inserts multiple entries instead of doing a query multiple times. That would faster
  2. thats not that complicated. First of you display has nothing to do with you database design. You separate the cars alphabetically using php. You use a query to fetch all cars or all cars starting with a letter. your database table would be like cars car_id (int primairy key) brand_id (int foreign key) car_name (varchar) car_description (text) car_image_url (varchar 255) brands brand_id brand_name if you want a car to have multiple images then have a separate table for that
  3. I was just going to ask that. What result do you want in the end can you give a discription. Looking at your code it looks a bit messy
  4. http://www.phpfreaks.com/forums/index.php/topic,237828.0.html
  5. maybe your looking for something like this <?php if($condition1){ //condition1 }elseif($condition2){ //condition2 }else{ //other } ?> or look into switch statement
  6. hmmm then you still dont use javascript. A trick I usually see here is a 1px image thats not even a pixel but a call to an external script for example <img src="getinfo.php?data=info" style="width:1px;height:1px" /> You could just make php write and image and save data to a database. To make it link simply put it in anchor tags <a href="somelink.html"><img src="getinfo.php?data=info" /></a> you still dont need javascript here
  7. you dont need js for that. why not simply use an anchor with an image inside <a href="othersite?extradata="><img src="something.jpg" /></a>
  8. use round edit oh nevermind you dont want to do that. You could do a split on the . if the last one is 0 then use round
  9. something like this i guess <?php $dbValue="Bob Segat"; $selected=(isset($_POST['submit'])?$selected:$dbValue; $selectItems=array("Bob Segat","Lorenzo Lamas","Chuck Noris","Mr - T"); ?> <select> <?php foreach($selectItems as $item): ?> <option <?php echo($item==$selected)?"selected":"";?> value="<?php echo $item;?>"><?php echo $item;?></option> <?php endforeach; ?> </select>
  10. Uhm ok your description confuses me and the VB code doesn't help. But are you asking for a way to set the selected attribute in a select element? So when the page loads the item was selected is selected in the HTML.
  11. Or parse it using the DOMdocument class domdocument
  12. Well most cases I dislike that syntax too. How ever if you use it where there is a lot of html between it, then the readability does improve. That and I had less complaints from the designers who read my code.
  13. I'm pretty sure or you could simply test it. have a look on the manual elseif and look at the second code block. It also would make sense if you compare it to python syntax
  14. Using curly brackets in this is probably a better option. You are using an alternative if else syntax. so if you use and alternative if else you should not place the semicolon after the if line. instead use : if($condition): //output if else: //output else endif;
  15. Depends if that external page is on a different domain javascript can't be cross domain. Even if it is on the same server PHP is probably better to use. You can use cURL or just parse the page to a string. Then you could do a regex to fetch the element you want. Or use DOM
  16. That or PDO making it less database dependent
  17. ok here goes, layout Don't see any layout related things in your code and this question can be interpreted on more then one way. But I'm guessing you don't mean html and css. If you mean in a php way then there are a couple of things you could do. Use a framework which will separate logic, models and html output Use a template engine like smarty Try to avoid echoing out html One other thing which could be handy is using alternative php syntax for if statements and loops etc. I'll give one example <?php $items=array('item 1','item 2','item 3','item 4','item 5','item 6','item 7'); ?> <table> <?php foreach($items as $item): ?> <tr> <td><strong>Name:</strong></td> <td><?php echo $item; ?></td> </tr> <?php endforeach; ?> </table> In this example I use endforeach to end the loop. Now imagine if there is a lot more html between the foreach loop and it ends with a } curly bracket. Then you'd see a curly bracket but have to scroll back up in your code to see what the curly bracket ends. efficency That depends on your code if it is very complex and you use a database you try not to use more queries then you need. And you could think of using a break to only loop when it is necessary. Otherwise it's more about readability rather then efficiency. Security The best way to learn about security is by understanding the basics of hacking. Try some basic hacking tutorials on a site like hackthissite.org . It will give you a better understanding why you need to secure something and you'll be more aware of the security leaks when building something. In your code I also noticed you check if the password posted was empty or not. Why not restrict it a little more by accepting only alphanumeric values. any other advice Last tip is to look for a form validation class. When building webapps building form validation can be quite time consuming and repetitive. Why not safe yourself some time and use a form validation class. hope it was usefull and if I am wrong on any point feel welcome to point it out.
  18. look into javascript galleries. I had an earlier topic about this http://www.phpfreaks.com/forums/index.php/topic,233177.0.html
  19. read this please http://www.phpfreaks.com/page/forum-rules Various things not to do
  20. that's your browser's source which is pointless. Show the source of the php. You probably have an include missing
  21. maybe the array is all lower case try $rows['profile_picture'] or maybe that array entry doesnt exist in that case try while($rows=mysql_fetch_array($result)){ echo "<pre>"; print_r($rows) echo "</pre>";
  22. it means there are more then one category_id fields to select. if you assign the table name on it then it might work change: WHERE category_id = {$categoryId} to: WHERE c.category_id = {$categoryId}
  23. This should be under javascript though but if I read the documentation on http://developer.yahoo.com/yui/calendar/ and that is the calendar you're using, then simply put php between it var myCalendar = new YAHOO.widget.Calendar("myCalendar", "myCalendarContainer"); myCalendar.cfg.setProperty("selected","<?php echo($date);?>",false); myCalendar.render(); You would have to format the date right if this is what you mean
  24. my bad Daniel is right change the following to see if you get errors $result = mysql_query($query); to $result = mysql_query($query)or die(mysql_error()); also try to echo your query like so echo $query; then you see if that query has errors. if you don't see any errors try to run that query in mysql query browser or phpmyadmin to see what errors that produces. and did you change your db like the suggested. If so does it have data in the database?
  25. I'd make it more readable above your html tags for better sepration of logic and html output <?php $categoryId=(int)$_GET['category_id']; $query = "SELECT SELECT p.*, u.*, c.* FROM poems p INNER JOIN users u USING (user_id) INNER JOIN categories c USING (category_id) WHERE category_id = {$categoryId}; ORDER BY p.poem_name DESC"; $result = mysql_query($query): ?> inside your html <ul> <?php while($row = mysql_fetch_array($result)) : ?> <li> <a href="testgedicht.php?poem_id=<?php echo $row['p.poem_id']; ?>"> <?php echo $row['p.poem_name']." | ".$row['u.user_name']; ?> </a> </li> <?php endwhile; ?> </ul>
×
×
  • 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.