Jump to content

Help needed with php and mysql


doenci

Recommended Posts

 

I am such a beginner but I had gone this far....

Here is the code:

 

<?php

 

$url = "http://www.website.com/";      // The simple url

$name = "11215";                      // this data coming from database

$newUrl = $url . "$name";    // appending the new url

header("location:$newUrl"); //the new url redirected

exit;

 

?>

 

 

So I'd like to get a $name variable (zipcode) received from a database or any file.

Everytime the url/site refreshes the next or randomly picked zipcode should be the new variable for $name

and the one was just used should be deleted from the database. I guess it's like an array...

I have a mysql database on my server set up which I have to connect to....help would be nice there too ;).

I am wondering if I could run the database from my local computer without connecting to any server.

 

Any help would be great!

 

Thank you guys...

 

doenci

Link to comment
Share on other sites

I don't think you want to delete the zipcode from the database after each refresh. If you do, eventually all zipcodes will be removed, leaving you with nothing. To pull a random zipcode, all you need is a SELECT statement to pull the data from the table that contains the zipcode and use RAND() at the end to pull a random result each time.

Link to comment
Share on other sites

As previously said, why delete the zip code when u can keep it.

 

I have a mysql database on my server set up which I have to connect to....help would be nice there too

 

mysql_connect() will connect u to the db server and mysql_select_db() will select the db u want to use.

 

I am wondering if I could run the database from my local computer without connecting to any server

 

If u mean testing data locally before uploading to a real environment, install php, mysql and apache on your pc and ull be able to work pretty smoothly. There's also a package for beginners by  ApacheFriend which will setup a (X)AMPP system for u.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.