Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




Database Question - ID Number


Please forgive me if this sounds stupid. I'm new to the programming
world. I want to start creating a database of products, their
descriptions, images, etc. to be pulled up from individual product
pages (well over 100), programmed with PHP. From the examples that
I've seen out of books and on the net, the ID number is usually
automatic. However, the products have numbers. Should it be a row for:
Product ID (1, 2, 3, etc) and then Item Number; or should there be
only a row for Item number to serve as the identifying number.




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Database Stores Default Number Everytime, But I Havent Set A Default Number??
Im having some problems with my database. Everytime i store a number which is longer than 10 numbers the script or database puts this number into the database: 2147483647. Its does this everytime no mather how i write the numbers and nomather how long the number is, it just needs to be over 10.

I have set any default value in the database and to be sure i havent i tried deleting the table, but same thing happends again???

Incrementing Number In Database
Is it possible to increment a value stored in the database? In my datebase I have the number of times the page was viewed, now each time a page is viewed I would like to add 1 to that total....but can I do this without having to first query the database? i.e could I do something like this: PHP Code:

" INSERT INTO search SET searchterm = '$serch_term', number = + 1 " 

Getting The Total Number Of Rows In SQL Database.
I know it's a bonehead question but what would a query in PHP look like that would return the total number of existing rows in a database.

How To Change A Number Entry In A Database
I need to change an entry in a database and I don't know how...they said..i should use update..but still ..it's all too vague for me... See, I need to modify a function which deletes ads. The ads are grouped in one table aptly named "ads".

Now, in a seperate table "category" is where I have saved the total number of ads in a record aptly titled = "total". These two tables have two things in common, they are joined by the category number=catid

Now, my problem is that whenever somebody deletes an ad. It just does that. It deletes the ad in table "ads". Now I need to change the total number of ads ("total") in table "category". Please do tell me how do i do this?

Getting The Number Of Items In MySQL Database Table.
Is there an easier way to get the number of items in a database table than
selecting all the records in it and then running mysql_num_rows on the
result?

Limiting Number Of Records Stored In Database
Is there a way I can limit the number of records that are stored in a database? I am using a PHP guestbook script for personal use and only want to save say the last 100 messages.

Large Number Of Looped Database Inserts Fails
I'm reading the pixels of an image and storing them in a database table which has an auto incremented key (the code is being executed by a browser page). Every time I get to approximately 3000 rows (the number is never the same) the code stops. No error. It just stops.

The echo of $sqlstring works right up to the point where it stops. It only happens for large enough values of $scale, e.g 10 is fine (presumably because it only has 100 iterations) but 100 fails because there should be 10000 iterations. $source is the name of the black and white image and it has the same dimensions as $scale. Code:

Replace Hex Number Or Decimal Number In A String ?
String may contain alphanumeric values. What is the bestway to replace a hex number such as 0x122aaa and decimal number such as 5678 with a string "blah" Example: I want to replace below--

wr_thru1 data or mask mismatch!! for addr=0x00000b73a0540 & mdfid:11
with
wr_thru1 data or mask mismatch!! for addr=hexVal & mdfid:decVal

Order Number Or Tracking Number
I need to create some kind of random number within a persons session that can be inserted into a customer id column for their orders, customer, and credit card tables.

Unless their is a better way to link a customers information together between a few tables besides using auto increment. Things could get screwed up for me if I use auto increment, especially if someone submits their information but does not actually place an order.

My question is " How can I create a random order number that can be used within a persons session and will stay the same throughout the whole program for that one person? "

What Is Indexing In Mysql And How It Will Be Useful And How We Can Retrieve Database Content Easily From A Database Table Containing About 5lakhs Datas
I need to select data from a database table containing huge amount of
data. Now I am storing data using one primary key and I am just using
simple select statement, and this process gives me the output but it is
taking long to execute the query. As much I had heared I want to use
some indexing or cluster indexing which might help me but I am not so
familiar with these things.

Images In Database Vs. Image References In Database
i kept all of the uploaded images as files on the server, and created links to them in the database. I have been changing things around now (especially directories) and I am thinking of storing the images in the actual database. I read somewhere that this can be considered a bad practice, so i was wondering what the consensus here was. In my opinion, modifying all of the code to point to the correct directories everytime a page location changes seems like a pain in the a**.

Database Search -text Database...
Can anybody tell me how to search a flat file database delimited by |. I have exploded the data and managed to get it into a table but want to restrict the final table contents by a search.

The table code at the moment is below - I'd be using a htm file to submit the data. and hopefully be able to search by partial searches eg big would return big and bigfoot. Code:

Number For Each Value
What I am doing is getting values from a database and what I need to do is print out each of them and print a number for each one, like this.

Odd Even Number
if I have a for loop :
for ($i=0; $i<count($replyDetails); $i++){
...
bgcolor = 123 (OR 456)...
...
}
and will show bgcolor = 123 if $i is an even number or $i=0
and will show bgcolor = 456 if $i is an odd number

Number St Nd Rd Th
How can I have a number variable and see whether it needs a st, nd, rd, or th at the end?like 1st, 2nd, 3rd, 4th... I originally thought I could select the last number but for example if it equaled 11, 12 or 13 the idea wouldn't work as they take th.

Number Of Records
I want to find out how many records, but I am using LIMIT in mySQL so if set the limit to 20 and I have 56 records then it will display 20 instead of 56.

I have been using:
mysql_num_rows

What should I be using?

Help With Getting A Number Of Posts
Hi, I've been trying to make a message board of sorts, and I'm having trouble getting the number of posts in each forum to show correctly. The two tables in mysql im trying to use in order to do this are a table called info, and a table called forumlist. Forumlist has two columns, one with forum_id, and one with forumname. Right now it has three entries, Test Thread, Game Thread, and Discussion Thread, with forum_ids of 1, 2, and 3 respecitively. In the table info, there is a bunch of columns pertaining to the author, the description, but those don't really matter, the one column that does in info is the column forum_id which is an integer I am using to keep track of which thread is in which forum.

Right now there is only one entry in the info table, and that has a forum_id of 1. I have been trying to get it to show that there is one total post in the Test Thread, and 0 in the two others, but for some reason it keeps saying there is one in the Game Thread, and 0 in the others. I tried changing the forum_id to 2 in the info table, but then it said that I had one post in the Discussion Thread and 0 in the others. It seems to be jumping ahead by one for some reason. I could use some help, here is my code:

Number Into Month With St,nd,rd,th
Is there a shorter faster way to do this...? PHP Code:

Most Recent By ID Number
Is there anyway to get the 5 most recent links added by using the field ID that I have in my database?

Format Number To 01 And Not 1
How do i format numbers to two digit all the time : eg. 01 instead of just 1 .... 02 instead of 2 ..... but 11 is just 11.

Number Sorting
I have a database from which I extract the top ten rows, dependent on a certain value. However, when two entrys have the same value they get the same placement in the "top ten" thingie. I know I can sort them first by position, then by for example name, but that doesn't do it for me.

(1) Printing the values gets me;

1. Malmö
2. Limhamn
3. Jönköping
4. Stockholm
4. Västerås
5. Sjöbo
5. Södertälje
6. Väsby
6. Ystad
6. Örebro

(2) The problem is that it SHOULD say;

1. Malmö
2. Limhamn
3. Jönköping
4. Stockholm
4. Västerås
6. Sjöbo
6. Södertälje
8. Väsby
8. Ystad
8. Örebro

You see the difference? In (1) "5. Sjöbo" should actually be "6. Sjöbo", since it's the sixth value, cause there are two cities sharing the number 4 spot.

The code I'm using;
Code:
while($row = mysql_fetch_object($result)) {
if ($prev_value == $row->name) $i=$i-1;
echo $i.". ".$row->city_name."
";
$prev_value = $row->name;
$i++;
}

Add Number In List
I am outputing a list of 10 values.

10, 20, 30, 40, etc

I can add 15 to one of the values then reorder the values from smallest
to highest but i want to update every single value and assign it values
increamenting by 10

so after the update the second number of 20 and add 15 I get

10, 30, 35, 40

now i want to re output the values above as

10, 20, 30, 40

Number Of Lines
Is there a function that returns the number of lines in a text
file? If so, what is it?

Random Number In PHP
<?php
srand( microtime() * 1000000);
$num = rand(1,100);
echo("Random Number:".$num."<br/>");
?>

Every time, it generates number 1... Why?

Get Number Of Rows?
Is there a way to get the number of rows returned from a query? (database used: MySQL)

Converting A Number With PHP ?
I have a bit of script that will convert a number from one currency to another: Code: <body onload="euroconv()">
<script language="JavaScript">
function euroconv() {
document.convert.temp.value=Math.round(document.convert.result.value)* 2;
}</script>

<form name="convert">
<input size="6" name="result" value="40">
<input size="6" name="temp"></form>

This executes client-side I assume, and I need to convert a value that is given to me by PHP on the page server-side. I still want to format the number with PHP ( number_format($value) ) before I display it, so I need to do everything server-side.
I need to do with PHP what I am doing with the JavaScript here.

Incrementing A Number
My understanding was that "++" incremented a number by one. PHP Code:

Sorting By Number
What I am looking for is a way to sort either a few variables or an array.

i.e I have an array
$myarray[1] = 12
$myarray[2] = 76
$myarray[3] = 3
$myarray[4] = 27
$myarray[5] = 52

Now I want to be able to sort the array by the value of it, so it would come out as.

52
76
27
12
3
Anyideas how to do this?

Prime Number
if there any function or refrence that i can find out the prime number that within the number user key in?

How To Number 42 Lines 1-14
I have 3 sonnets (14-line poems, fyi) in a file without blank lines and I want to tack line numbers onto the end of each line so that the first 14 lines will be numbered 1-14, as will the second 14 lines and the third. I've exploded the file by "
" so that I have each line as an array value. I've been using various loop fuinctions (for, foreach, while) to try to put individual numbers at the end of each corresponding line, but something either loops too much or not at all.

This is just an example. I know I could number 42 lines by hand, but I'd like an automated system to do it for much more line numbers.

Looking For A PHP PIN Number Generator
I am looking for a script that generates PIN Numbers.

Is there one available somewhere out there? I don't mind algorithms if
they will be easy to implement in PHP.

Number Format ?
I have this number: 52000000 (52 million ) I would like to show it as 52,000,000 how can I do that?

Auto Number
How to generate auto number for php? For example, every time I submit the details to another page, the number will add from 10001 to 10002.

Number Format
I have this number 1, and want to format like this 000000001, how is it possible.

Number Of Characters
How do I count the numbers of charaters in a string/variabele?

Number Checker
I have a problem on programming, Iam trying to create a function that
can check whether a number is

0 1 2
6 7 8
12 13 14
18 19 20
24 25 26

the function will just return true if the number is one of the above
but without mentioning the numbers staticly

meaning not like this:
if( $num==0 && $num==1 && $num==2 && $num==6 ..and so on )

but something like this:
function progression( $num, $diffBetween )
{
if( $num%2 )
return true ;
else
return false ;
}

can anyone help?....

Number Format
I have a loop that selects prices from a database, prints each price out individually and then adds it to a variable, the "final price".

$thisprice = $row[ITEM_PRICE] * $row[SEL_ITEM_QTY];
$thisprice = number_format($thisprice, 2);
echo("$thisprice")
$finalprice = $finalprice + $thisprice;

But for some reason, when the $finalprice variable is set to more than $999, it won't display the correct price. Does anyone have any idea why this is? Does it have to do with the comma in the price? How can I fix this?

Formatting Number
Can sombody tell me the best way to format a number in this way.

456.45657 must be 456,46

So the point becoms a comma and I would have 2 digits i.pv. 5

Ereg [a Number Between 1 And 100]
last time, ereg specialists did help me, so I ask again:

base pattern: some texte her [a number between 1 and 100]
result: the number alone ...

PHP And Number Formatting
When I add 2 items in the cart less than $1000.00, the formatting of the numbers display fine. When for example I got 2 items that cost 3475.00, the total cost the the two items is displayed as 6, and NOT 3475.00.

I am using the the sprintf function, and I believe my problem lies in the fact that I don't know the correct format to display numbers in excess of 1000.00?

Number Transformation
How can I eliminate everything behind the coma of a number. Like say, i have a 6.79012, I want to have 6, or I have 126578.21, I want to have 126578. Is there any easy way to eliminate everything behind the coma (and not rounding the number, which would make 7 out of 6.79012).

Number Of Logins
Anyone know a way to have a site list the usernames of those logged in?
It could be done by writing to a db when a session is started and
ended but it would be nicer if there is some global session that I can
go through an array of users. Is that possible or is it against the
whole spirit of sessions?

How To Round A Number
How can I round a number to 2 signs after coma? (Ex: 2.12323432 -> 2.13)

Formatting Number.
I am trying to display prices on a shopping cart system, but need to be able to display the prices in the form £x.yy, at the moment I am getting things like:

£4
£4.2
£4.123

How can I make PHP display a floating point number with only/at least 2 decimcal places?

Go To Page Number
how I could go about this using dropdowns that would select from table limit by like 10 or 15 results per page. I kind of get prev next.

Random Number
i am trying to find a random number but keep getting zero here is the code i am using.
PHP Code:

Spliting Number
I'm trying to figure out a way to split up a number, something like the following
$Number="123,345.78";

// do something

$Number[0] would now equal 1
$Number[1] would now equal 2
$Number[2] would now equal 3
$Number[3] would now equal ,

and so on...

I'm looking through the manual now and I can't find any specific function for this and I can't use explode() or split() because I need a patern, anyone have any suggestions as to how I might accomplish this (Yes I do need to retain the comma and period).

PHP VIN NUMBER DECODER
I have been searching for a PHP application to decode vehicle Vin numbers

Using a SQL Database data included with an update feature to add a Vin
not decoded

I do not want to subscribe to a service.

Number Question
Is there a way to "round" (bad use of the word) a number to the nearest 5
eg
4 => 5
7 => 10
1 => 5
12 => 15


Copyright © 2005-08 www.BigResource.com, All rights reserved