Jump to content
Larry Ullman's Book Forums

Search the Community

Showing results for tags 'update'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Single Editions
    • Modern Javascript: Develop and Design
    • The Yii Book
    • Effortless Flex 4 Development
    • Building a Web Site with Ajax: Visual QuickProject
    • Ruby: Visual QuickStart Guide
    • C++ Programming: Visual QuickStart Guide
    • C Programming: Visual QuickStart Guide
    • Adobe AIR: Visual QuickPro Guide
  • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (5th Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (4th Edition)
    • PHP 6 and MySQL 5 for Dynamic Web Sites: Visual QuickPro Guide (3rd Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (2nd Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (1st Edition)
  • PHP for the Web: Visual QuickStart Guide
    • PHP for the Web: Visual QuickStart Guide (5th Edition)
    • PHP for the Web: Visual QuickStart Guide (4th Edition)
    • PHP for the Web: Visual QuickStart Guide (3rd Edition)
    • PHP for the World Wide Web: Visual QuickStart Guide (2nd Edition)
    • PHP for the World Wide Web: Visual QuickStart Guide (1st Edition)
  • Effortless E-commerce with PHP and MySQL
    • Effortless E-Commerce with PHP and MySQL (2nd Edition)
    • Effortless E-Commerce with PHP and MySQL
  • PHP Advanced: Visual QuickPro Guide
    • PHP Advanced and Object-Oriented Programming: Visual QuickPro Guide (3rd Edition)
    • PHP 5 Advanced: Visual QuickPro Guide (2nd Edition)
    • PHP Advanced: Visual QuickPro Guide
  • MySQL: Visual QuickStart Guide
    • MySQL: Visual QuickStart Guide (2nd Edition)
    • MySQL: Visual QuickStart Guide (1st Edition)
  • Other
    • Announcements
    • Newsletter, Blog, and Other Topics
    • Forum Issues
    • Social

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Found 4 results

  1. I'm not sure if this is even possible but I would like to modify script 10.3. I have created a simple running log where users can input the details of their run using a form that includes text input, radio buttons and drop-down menus. Is it possible to use the same or similar form to edit/update their records? I have no problem retrieving the values for the text boxes but I don't know how the form is supposed to show the values from the drop down menus or to "select" the appropriate radio button. Any help would be appreciated. Thanks!
  2. Hello again, I'm wondering if it is possible to insert to a table and then update to that table in the same php script. What I want to do is insert a location address, then geocode it with a location update immediately after the insert with the form action as the same page. However, I suspect that I will need to do this through a hidden submit input that takes me to another page because I have been scratching my head over it for a few hours now. Here is the location insert $q = 'INSERT INTO location (loc_address, loc_address2, loc_city, loc_state, loc_zip, loc_country, coll_id, country_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?)'; $stmt = mysqli_prepare($dbc, $q); mysqli_stmt_bind_param($stmt, 'ssssssii', $addr1, $addr2, $city, $state, $zip, $sn, $c, $coun); mysqli_stmt_execute($stmt); //Check the results if (mysqli_stmt_affected_rows($stmt)== 1){ echo '<p>The location has been added</p>'; $locid = mysqli_stmt_insert_id($stmt);//Get the location ID }else{//Error! $errors[] = 'the location could not be added to the database.'; } //Close this prepared statement mysqli_stmt_close($stmt); and here is the geocoding with the update query //geocode it $geoloc="$addr1, $city, $state, $zip, $sn"; $georesult=file_get_contents("http://maps.googleapis.com/maps/api/geocode/json?sensor=false&address=" . urlencode($location) ); $geocodedinfo=json_decode($result); print_r($geocodedinfo); $lat = $geocodedinfo->results[0]->geometry->location->lat; $lng = $geocodedinfo->results[0]->geometry->location->lng; $query = "UPDATE location SET loc_address='$addr1', loc_address2='$addr2', loc_city='$city', loc_state='$state',loc_zip='$zip', loc_country='$sn', lat='$lat',lng='$lng' WHERE loc_id='$locid'"; $result = mysqli_query($query); if ($result){ echo "<h2><b><strong>OMG it worked!</strong></b></h2>"; }else { echo "<p>No geocode (mope)" . mysqli_error() . "</p>"; } can I force the insert submit to go first and then run the update? if so, what do you suggest? I came across one article that said something about making each query into a function, but it wasn't explained very well. And do I need to create a separate pre-populated hidden form somehow for the second submit?
  3. Chapter 3 of the 3rd Edition of this book includes some work with a database of US zipcodes borrowed from US census bureau or some similar organization. The database is located here (the smaller database): http://www.federalgo...mentzipcodes.us Some of the latitude and longitude values in the database are empty, which can be checked by running the following query: SELECT * FROM zip_codes WHERE latitude=''; Which outputs a number of results. (Showing rows 0 - 29 (648 total, Query took 0.0042 sec)) Larry offers to replace the empty values with NULL, by running this query: UPDATE zip_codes SET latitude=NULL, longitude=NULL WHERE latitude=''; But nothing happens! (0 row(s) affected. ( Query took 0.0993 sec )) Is there an error in the UPDATE query? What am I missing, why does it fail to update? Would be grateful for your help, as always!
  4. Hi all. Im trying go abit beyond the chapters of the yii-book, and im struggeling with the update of a database. I cant seem to figure out how i update an existing row. So im trying to build a e-mail verification, a user registers and gets an email with a link to myproject.com/verify?id=ID&verificationcode=VERIFICATIONCODE, and the verifypage picks it up and runs my actionVerify() method: public function actionVerify() { $model=User::model()->findByPk($_POST['id']); $model->attributes=$_POST['Verify']; if($model->validate()) { Yii::app()->user->setFlash('validated','<h2>Your E-mail is validated!</h2><p>You can now log in using the form below.</p>'); $model->save(); $this->redirect(Yii::app()->homeUrl/login); } } I've tried for a few hours now, starting of with using $model = new User, that ofcourse generates an error as you cant update an existing row with the creation of a new object. The code i have pasted over here generates the following error: Undefined index: id So im kinda stuck here, and im sure the solution is close to something i've tried. I have googled this alot, but the lack of well-explained articles kills me. I just dont have the understandment of yii/oop to use the manual or short articles just yet. Any help is appriciated, thanks in advance.
×
×
  • Create New...