RichardRotterdam
Members-
Posts
1,509 -
Joined
-
Last visited
Everything posted by RichardRotterdam
-
How do you add multiple entries to db from form processing
RichardRotterdam replied to phpdragon's topic in PHP Coding Help
you could create a query that inserts multiple entries instead of doing a query multiple times. That would faster -
[SOLVED] Complicated Project. Need Advice on How to Start
RichardRotterdam replied to Fluoresce's topic in PHP Coding Help
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 -
If / Else Multiple conditions? Is this possible?
RichardRotterdam replied to Skipjackrick's topic in PHP Coding Help
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 -
[SOLVED] flash changing a variable in a php doc
RichardRotterdam replied to dad00's topic in PHP Coding Help
http://www.phpfreaks.com/forums/index.php/topic,237828.0.html -
If / Else Multiple conditions? Is this possible?
RichardRotterdam replied to Skipjackrick's topic in PHP Coding Help
maybe your looking for something like this <?php if($condition1){ //condition1 }elseif($condition2){ //condition2 }else{ //other } ?> or look into switch statement -
[SOLVED] Little JS widgets to collect data
RichardRotterdam replied to therealwesfoster's topic in Javascript Help
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 -
[SOLVED] Little JS widgets to collect data
RichardRotterdam replied to therealwesfoster's topic in Javascript Help
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> -
[SOLVED] remove decimal point if zero
RichardRotterdam replied to hassank1's topic in PHP Coding Help
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 -
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>
-
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.
-
Get text from element on external page
RichardRotterdam replied to marklarah's topic in Javascript Help
Or parse it using the DOMdocument class domdocument -
Get text from element on external page
RichardRotterdam replied to marklarah's topic in Javascript Help
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 -
That or PDO making it less database dependent
-
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.
-
look into javascript galleries. I had an earlier topic about this http://www.phpfreaks.com/forums/index.php/topic,233177.0.html
-
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>";
-
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}
-
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
-
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?
-
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>